Nikolay Blokhin Facebook Nikolay Blokhin Instagram Nikolay Blokhin Linkedin Nikolay Blokhin Twitter

Hi, I'm Nikolay Blokhin I build the cool things with Python and Swift

Swift articles

My collection of the best articles about Swift :)
All the articles I'm selecting manually and publish updates every day.

2018 January


Being an iOS Developer is a striking occupation, and we’ve composed this program to show you the aptitudes required to dispatch your profession. Regardless of whether you have past protest situated programming knowledge or you’re a total learner, you’ll take in the Swift programming language and make a large number of portfolio-commendable iOS applications to show your ability with iOS improvement.

iOS is continually getting things started and discharging new items and versions. Coverage incorporates iOS and Mac client guides, programming with Swift and Objective-C, improvement of new applications with Xcode, mix into big business and different conditions, investigating iOS on iPhone and iPad, and then some.

Regardless of whether you’re simply beginning programming your first iOS application, an accomplished engineer, or an iOS devotee searching for a manual for your new gadget, we will help you to take in your way around Apple’s most recent offerings.

Through the span of your iOS Developer you’ll construct five portfolio-commendable iOS applications that exhibit your aptitude as an iOS Developer. You’ll compose these applications in Swift, Apple’s custom programming language planned particularly to build iOS and OS X applications. You’ll get group and guide bolster all through, and in addition advantage from the meticulousness and quickness of our superior code audit framework. At long last, you’ll get profession direction as we survey your resume, review your online nearness, give you talk with preparing, and the sky is the limit from there. You’ll even partake in another program encouraging occupation situation.


Swift is another option to the Objective-C dialect that utilizes current programming-dialect hypothesis ideas and endeavors to display a more straightforward linguistic structure. Amid its presentation, it was portrayed just as “Objective-C without the C”

As a matter of course, Swift does not uncover pointers and other risky accessors, as opposed to Objective-C, which utilizes pointers inescapably to allude to question occasions. Likewise, Objective-C’s utilization of a Smalltalk-like sentence structure for making technique calls has been supplanted with a speck documentation style and namespace framework more well-known to developers from other basic protest situated (OO) dialects like Java or C#. Quick presents genuine named parameters and holds key Objective-C ideas, including conventions, terminations and classes, frequently supplanting previous linguistic structure with cleaner forms and enabling these ideas to be connected to other dialect structures, as identified kinds.

In many protest arranged dialects, objects are spoken to inside in two sections. The question is put away as a piece of information put on the pile, while the name (or “handle”) to that protest is spoken to by a pointer. Items are passed between techniques by replicating the estimation of the pointer, permitting the same basic information on the load to be gotten to by anybody with a duplicate. Interestingly, essential composes like whole numbers and skimming point esteems are spoken to specifically; the handle contains the information, not a pointer to it, and that information is passed straightforwardly to techniques by duplicating. These styles of access are named cruise by-reference on account of items, and cruise by-esteem for fundamental kinds.

The two ideas have their focal points and detriments. Items are helpful when the information is substantial, similar to the depiction of a window or the substance of a report. In these cases, access to that information is given by replicating a 32-or 64-bit esteem, as opposed to duplicating a whole information structure. Be that as it may, littler esteems like numbers are an indistinguishable size from pointers (commonly both are single word), so there is no favorable position to passing a pointer, as opposed to passing the esteem. Likewise, cruise by-reference characteristically requires a dereferencing operation, which can create perceptible overhead in a few operations, normally those utilized with these fundamental esteem composes, similar to arithmetic.

Additionally to C# and as opposed to most other OO languages, Swift offers worked in help for objects utilizing either cruise by-reference or cruise by-esteem semantics, the previous utilizing the class presentation and the last utilizing strut. Structs in Swift have all an indistinguishable highlights from classes: techniques, actualizing conventions, and utilizing the augmentation systems. Consequently, Apple terms all information blandly as examples, versus questions or qualities. Structs don’t bolster legacy, however. The software engineer is allowed to pick which semantics are more proper for every datum structure in the application. Bigger structures like windows would be characterized as classes, enabling them to be passed around as pointers. Littler structures, similar to a 2D point, can be characterized as struts, which will be cruise by-esteem and enable direct access to their inside information with no dereference. The execution change inborn to the cruise by-esteem idea is with the end goal that Swift App Development Course In Bangalore uses these sorts for every single basic datum writes, including Int and Double, and sorts regularly spoke to by objects, such as String and Array. Utilizing esteem composes can bring about huge execution enhancements in client applications too.

To guarantee that even the biggest structs don’t cause an execution punishment when they are given off, Swift uses duplicate on compose with the goal that the items are replicated just if and when the program endeavors to change an incentive in them. This implies the different assessors have what is in actuality a pointer to similar information stockpiling, yet this happens far underneath the level of the dialect, in the PC’s memory administration unit (MMU). So while the information is physically put away as one case in memory, at the level of the application, these qualities are partitioned, and physical detachment is authorized by duplicate on compose just if necessary.


Infocampus is the best iOS Training Institutes in Bangalore, with certified mentors Highly Talented with 8+ Years Experienced Trainers Well Equipped Class Rooms.

We provide real-time live projects and hands on experience.

Placement oriented App Development Course In Bangalore— Learn iOS App Development Bangalore .

For more details contact: 9738001024


to read it →

Feeling weird while do picking an image and cropping in Swift?

Keep reading, and you will find solutions to question above, else — write your thoughts in comments.

Step 1: Create your Xcode project.

Step 2: Design storyboard and create outlets and properties in ViewController class.

let picker = UIImagePickerController()
var circlePath = UIBezierPath()
@IBOutlet weak var crop: CropView!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var scroll: UIScrollView!

The property crop have custom UIView class. Add the below delegate function in it.

func point(inside point: CGPoint, with event:   UIEvent?) -> Bool{
return false

Step 3: Create extension for UIImage and UIImageView — refer. For zooming image, use delegate function viewForZooming ,then add UIScrollViewDelegate to class as the subtype and return imageView.

Pick image from gallery —

Step 4: Create IBAction, To pick an image from Album and set the picker source type as photo library use the code below

picker.sourceType = .photoLibrary
present(picker, animated: true, completion: nil)

and add UIImagePickerControllerDelegate to class as sub type. In viewDidLoad,

picker.delegate = self

Use didFinishPickingMediaWithInfo —UIImagePickerControllerDelegate function to set image to the view after picking image from album.

let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
imageView.image = chosenImage.resizeImage()
dismiss(animated:true, completion: nil)

To dismiss the photo album when you did cancel, use imagePickerControllerDidCancel delegate.

Shoot picture from camera —

Create IBAction to shoot an image from the camera. First, check whether SourceTypeAvailable in the device. If it is set picker camera capture mode as a photo. Else handle the action.Then set source type as camera and camera capture mode as the photo.

if UIImagePickerController.isSourceTypeAvailable(.camera){  
picker.sourceType =
picker.cameraCaptureMode =
picker.modalPresentationStyle = .custom
present(picker,animated: true,completion: nil)
//action performed if there is no camera in device.

That’s it! Now you can pick image from album, as well as camera to display in your app for further action.

Cropping —

Add sublayer:

Add subLayer to the picked image — this layer provides an area to fix crop frame.

let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.view.bounds.size.width, height: self.view.bounds.size.height), cornerRadius: 0)

Assign the path to the circle path property as of type UIBezierPath. Using BezierPath, you can change the crop frame into different shapes.

circlePath = UIBezierPath(roundedRect: CGRect(x: (self.view.frame.size.width / 2) - (size/2), y: (self.view.frame.size.height / 2) - (size / 2), width: size, height: size, cornerRadius: 0)

The CAShapeLayer that draws a cubic Bezier spline in its coordinate space.

let fillLayer = CAShapeLayer()
fillLayer.path = path.cgPath

Finally, add the layer to view,


Add crop area:

Create crop area. For that we need to set factor, dividing the imageView image width by view frame width set scale,

let factor = imageView.image!.size.width/view.frame.width

for zooming as scroll zoomScale .

let scale = 1/scroll.zoomScale

Then set crop area frame(x, y, width, height).

let x = (scroll.contentOffset.x + circlePath.bounds.origin.x - imageFrame.origin.x) * scale * factor
let y = (scroll.contentOffset.y + circlePath.bounds.origin.y - imageFrame.origin.y) * scale * factor
let width = circlePath.bounds.width * scale * factor
let height = circlePath.bounds.height * scale * factor

Finally , create a IBAction to crop the image.

let croppedCGImage = imageView.image?.cgImage?.cropping(to: croparea)
let croppedImage = UIImage(cgImage: croppedCGImage!)


That’s all!!!

Check out sample project on my Github repo.

“We tend to steer our lives in the direction of the lessons we need to learn.”

- Don Campbell

to read it →