Featured
-
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi -
Make UIImage White Background Transparent in iOS
If you came across to a requirement where you want
by ashish.nakoti -
User's location update on server when app is in background.
Code for those Apps where we need to update user's
by ashish.nakoti -
Animate button with zoom and bounce effect in ios
Many social apps are using bouncing effect for but
by ashish.nakoti -
Crop an image from UIImageView
With the following method stated below you can cro
by kuldeep.butola
Tags
Flutter Vs. Swift: Consider the Key Differences to Choose the Best Language for iOS Development
An age-old battle between native and hybrid apps has blurred the lines between app development frameworks. For example, Flutter framework has gained ground as an option to Swift for developing iOS apps. Be it budget constraints or faster developm...
Objective-C or Swift: Which Technology to Learn for iOS App Development?
Introduction
It’s no argument that mobile platforms are kicking desktop computers out of the limelight and according to the most recent statistics, these will gain a significantly greater offer of the market in th...
How to Register Realtime User Information at Firebase in iOS App
Firebase is a realtime database where we can store the information and can check whether data got saved or not in Firebase. Here is a simple example of creating a project and connection of the project with Firebase, so, here we go.
...
How to Show UICollectionView in UITableViewCell Using Swift in iOS App
We can easily create a simple table view to show the data in tabular format but if we need to show UICollectionView inside the UITableViewCell then it become a challenging task for the beginners. So here is an easy tutorial, to get the concept of...
Slice an Image into Tiles and Store in an Array Using Swift iOS App
This is a small sample of how we can split an image into multiple pieces/tiles and store these small pieces into an array and further we will show, how these pieces are rearranged to form an image.
So let start with s...
Customize UITabbarController by Collection View for iOS App in iPhone Device
As we have noticed that iPhone/iPad tab-bar display maximum five tabs and if we have more than 5 tabs then only 4 icons are visible with 5th one displaying more option. In case we need to display more than 5 tabs without more icon we need to cust...
5 Easy Steps to Set User Notification Feature in iOS Swift Application
User notification is a new local notification feature in iOS. It gives the additional functionality i.e. to remove pending notifications which is not possible in UILocalNotification. So lets start how it works.
As we know for schedul...
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on general purpose, a multi-paradigm compilation which has been developed by Apple Inc. Swift is basically developed for various operating systems including iOS, watchOS, macOS, Linux, and tvOS. It i...
Programmticaly Add AutoLayout by Visual Format Language in Swift
Auto layout adjusts the size and position of view according to the constraints applied to it. This approach dynamically changes our User Interface according to different screen sizes.
There are different ways for adding autolayout programmatical...
Get location from postal code in Swift 3.0
1. import coreLocation in your controller.
import CoreLocation
2. Add this function to your view controller.
func getLocationFromPostalCode(postalCode : String){
let geocoder = CLGeocoder()
geocoder.geocod...
How to login with Facebook in swift 3.0
To Implement Facebook login in swift 3.0, we can use following steps.
1. install pod
pod 'FacebookCore'
pod 'FacebookLogin'
2.Register your app on the Facebook developer account. After registration,Go to you info.plist, right ...
Convert NSDate from local timezone to UTC and vice versa in Swift 3.0
1. To convert UTC(Coordinated Universal Time) to Local timezone
func convertToLocalDateFromUTCDate(dateStr : String) -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
let...
UINotification in iOS10, Swift 3.0
To implement Notification in iOS 10, follow below steps.
Go to Project -> Target -> capabilities -> push notifications
enable push notification.
Now in Your AppDelegate Class do following steps -
1. Import UserNotifications.
2...
Convenience Initializer in Swift with Example
Convenience Initializer used in swift as a supporting initializer. By using the convenience initializer you can put multiple -init along with other and use whichever you want to use.
convenience initializers have the convenience keyw...
How to store user information in NSUserDefaults in swift language?
Hi Reader’s,
This blog includes the concept of how to store user information in NSUserDefaults in swift language. Below is the code in swift language for the same:-
import UIKit
import Foundation
class RegisterViewCont...
Add camera node in sceneKit
Adding Camera node provide us the point of view from which we view our scene. To add camera node we have to simply make the SCNCamera object and assign it to node’s camera property.
let ...
How to change voice using AVSpeechSynthesis in swift
This blog includes the use of -
AVSpeechSynthesisVoice
If we want to change the default voice i.e system voice then we need to use speechVoices{} array which contains the name of persons and locations. iOS has a nice method for sett...
Bottom pull to refesh for pagination in table view in Swift
Hi Readers,
Pagination is required in most of our apps in today scenario. We can achieve it either pull to refresh from top or bottom. UIRefreshControl is the feature if you want to implement it from top side and insert processed records into ...
How to parse JSON in Swift with ObjectMapper
Hi Readers,
Every app needs to parse JSON data coming from server and ObjectMapper is a powerful tool to achieve that. It can be easily done with provided pod which can be install by adding following line into podfile:
pod 'ObjectMa...
Blocks or closures in Swift
Hi Readers,
We used to code blocks in Objective C, mainly to implement callbacks. For that particular functionality we can use closures in Swift. That will work same as blocks in Objective C. Closures are enclosed in curly braces { } and are d...
How to download videos from YouTube in iOS
Hi Readers,
We can download video file from Youtube if we know youtube URL of the video. First you need to add attached files (HCYoutubeParser) into your project. Now you need to call following function into your code:
let video = HCYout...
How to download data Using NSOperations and NSOperationQueue
Hi Readers,
It is sometimes required to download files or images from server into local. We can perform these tasks by NSOperation and NSOperationQueue efficiently. The basic idea is to create each download operation separately and add these o...
How to decode HTML string coming from server to iOS readable string
Hi Readers,
Many time we will get HTML content in our API response which we need to load into our component like UILabel. We can convert this HTML content into normal string or more specifically NSAttributed string which we can set into ...
Adding Toolbar above keyboard
Hello Readers,
To add a toolbar above the keyboard we may use the following code snippet.
We will create a toolbar with the needed items and set as the input accessory View of the keyboard. In the below code we have added a done button on t...
How to send a request with parameters in Alamofire
Alamofire is HTTP networking library for iOS and Mac OS X, which is written in swift. Alamofire is based on NSURLSession,but it make network code much easy to write.
Following function is available in Alamofire.
.upload
.down...
How to create your own search bar in Swift (Not using UISearchBar)
Here is a small example of custom search bar
1. Go to storyboard, take TextField place it at below navigation bar (we will type text here to find any string)
2. Set delegate of TextField
Come to ViewController class now
Create I...
How to add new .pch file to your Xcode Project?
From Xcode6 and later .pch file is not created automatically. One has to create it manually.
Following are the steps to add/create a pch file in your xcode project:
Create a new file using: cmd+N
• &nbs...
UI Objects not visible in storyboard when changing height and width specifications
You may often come to a situation when your UIObject(say UIImageView) is not visible on storyboard.
It may be because you’ve dragged and dropped the UI Object for specification(say Regular Width - Regular Height) other than Any-Any.
&...
Use vibrancy effect in UITableViewCell like notification center.
1. It is must to import “NoticationCenter” so that we can use “notificationCenterVibrancyEffect”
import NotificationCenter
2. At the time of cell selection do following code in delegate method...
Collapsable UITableView header in Swift
To collapse table header in swift ->
1. Make a property of NSMutableSet, name it "collapsedSections", this property will be use to check Collapsed section in the UItableViewCell.
var collapsedSections:NSMutableSet =...
How to give border color to UIButton in objc and Swift.
To give border color to UIButton :-
1. Take UIButton as property .
2. Give corner radius and corner width to UIButton.
3. Now give border color to UIButton.
For Swift use :-
demoButton.backgroundColor = UIColor.clearColor()
demo...
Two Way Binding in Swift
Hi All,
Two Way Binding :- In two way binding, data flows in both direction, from object to UI and vice-versa. For instance, you can have a UITextField called as nameTF which is binded with an object having property nameValue. So when the obj...
Auto Layout Using Visual Format Language In Swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
Visual Format Language is one of the way is used to a...
Auto Layout Using NSLayoutConstraint In Swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
NSLayoutConstraint is one of the way is used to add autol...
Adding auto layout constraint dynamically in swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
Layout Anchor is one of the way is used to add autolayout...
NSTimer In Swift
Hi all,
You can use the NSTimer class to create timer objects or, more simply, timers. A timer can wait and call a method or selector after defined period of time. for example :- if you want show a seconds clock and stop when it completed 60 s...
How to create a UIAlertView in swift
Hello friends , To create UIAlertView in swift ->
UIAleartView is deprecated in iOS 9,
so you need to use UIAlertController instead .
let alertController = UIAlertController(title: test alert, message: this is a test alert, preferredS...
Adding Blur effect in swift
Hello friends,
To add blur effect in swift you may use the following code:
IBAction func blurImage(sender: AnyObject) {
// 1 Create an object of UIBlurEffect,you may change the value of style as per your requirement
var darkBlur = UIB...
Chaneg Textview height according to text
Hi All,
If you want to change height of textView according to content height than you can follow this code.
Use auto layout to set view in story board and make IBOutlet for textview . Assign delegate to textview and dont give height constra...
Show flags using Unicode
Hi All,
If you want to show flags in using unicode hex coding (U+XXXX) than you can follow this code .
UNICODE:- Unicode is a computing industry standard for the consistent encoding, representation, and handling of text expressed in most of...
Convert NSString to NSDate and vice versa
HI all,
If you want to convert NSString to NSDate ,then you must use NSDateFormatter to convert please follow this code .
NSString to NSDate
In Objective-C :-
NSString *dateString = @"11-11-2015";
NSDateFormatter *dateFormatter = [[...
How to create a UILabel & UIButton programmatically in Swift
hello friends,
this is how we can create a UIButton and UILabel in swift.
Set a UILabel in swift
var label = UILabel(frame: CGRectMake(100, 100, self.view.bounds.size.width, 50))
label.center = self.view.center
la...
Caputre Screen Shot in IPhone
if you want to capture the screen shot of the screen in swift use the code below. this function will return an image that can be used as background image of a view
The size of the captured image is same as the size of device.
func caputreSc...
Make a Call using swift
Hi All,
To call any number with code using swift you can use this function.
private func dialNumber(phoneNumber:String) {
let phoneUrl:NSURL = NSURL(string: "tel://\(phoneNumber)")!
let application:UIApplication = UIAppli...
Load custom cell(Xib) in UITableView in swift
hello friends,
if you would like to Load custom cell(Xib) in UITableView in swift ,you may use the following code ->
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count; //...
TableView in Swift
To create a tableView in swift please follow following steps:
Step 1: Add a tableView in viewController.
Step 2: set the dataSource and delegate
Step 3: Create a prototype cell
Step 4: Change the class of prototypecell to "TableView...
How to declare an Array in Swift
Hi Readers!
There are different ways to declare Array in Swift. I will write few examples below:
Example 1:
let a : Array? = ["hello","hi"]
Now in above example this is a constant array. You cannot add/append an element in it.
E...
how to merge objc and Swift code in same project
To use swift code in Objective-c project ->
1. Go to your objective-c project -> create a new file -> source -> Cocoa Touch Class -> change language to Swift -> create.
2. Now a alert will pop-up Would you like to configur...
Why to use tuples if we have Arrays in swift language and How it is different from Structures?
Hi Readers,
Before Moving ahead with the Topic,Lets us Briefly have a overlook what actually a Tuple is:
* In very simple language:
A tuple is a group of zero or more values represented as one value.
For example ("Pen", "50") ...
What is an Optional meant in Swift?
Hi Readers!
An Optional is just an enum in Swift.
enum Optional<T> {
case None
case Some(T)
}
Here <T> is generic similar to an Array<T>
<T> could be anything like Strings, Dictionary, Array etc.
...