iOS

Topics related to iOS:

Getting started with iOS

Notes

1- You do not need an Apple Developer Account to start developing iOS Apps. The documentation and tools are free to download with your Apple ID. You can also sign and install apps on your personal devices using that same Apple ID. If you want to distribute or sell apps on the App Store, you need to enroll the Apple Developer Program starting at 99 USD (This is the price at the time of writing and may change). This will also add code-level support incidents and beta testing for your apps via TestFlight.

2- Creating an Apple ID without a credit card requires a short process. If you don't mind associating a payment method as part of the sign up, go to https://appleid.apple.com/

Related Stack Overflow tags

  • xcode Apple's IDE (Integrated Development Environment) for developing iOS and macOS Apps
  • swift-language One of the main languages you can use to develop in iOS.
  • objective-c-language One of the main languages you can use to develop in iOS.
  • cocoa An Apple API for developing in iOS and macOS.
  • sprite-kit For 2D animated graphics.
  • core-data To store and retrieve relational data.

UILabel

Change Status Bar Color

Passing Data between View Controllers

Managing the Keyboard

UIButton

Button Types

A button’s type defines its basic appearance and behavior. After creating a button, you cannot change its type. The most commonly used button types are the Custom and System types, but use the other types when appropriate

  • UIButtonTypeCustom

    No button style.
    
  • UIButtonTypeSystem

    A system style button, such as those shown in navigation bars and toolbars.
    
  • UIButtonTypeDetailDisclosure

    A detail disclosure button.
    
  • UIButtonTypeInfoLight

    An information button that has a light background.
    
  • UIButtonTypeInfoDark

    An information button that has a dark background.
    
  • UIButtonTypeContactAdd

    A contact add button.
    

When creating a custom button—that is a button with the type custom—the frame of the button is set to (0, 0, 0, 0) initially. Before adding the button to your interface, you should update the frame to a more appropriate value.

UILocalNotification

UIImageView

Checking for Network Connectivity

The source code for Reachability.h and Reachability.m can be found on Apple's developer documentation site.

Caveats

Unlike other platforms, Apple is yet to provide a standard set of APIs to determine an iOS device's network status and offer only these code examples linked above. The source file change over time, but once imported into an app project, they are seldom updated by the developers.

For this reason most app developers tend to use one of the many Github/Cocoapod maintained libraries for reachability.

Apple also recommends, for requests made at the user’s behest, that you always attempt a connection first, before using Reachability/SCNetworkReachability to diagnose the failure or to wait for the connection to return.

Accessibility

UITableView

UITableView is a subclass of UIScrollView. Classes that follow the UITableViewDelegate protocol also follow the UIScrollViewDelegate protocol. UITableView can be useful for showing long or indeterminate lists through its cells, whilst UIScrollView is better for when the size of the views to be shown is known beforehand.

Auto Layout

UIView

The UIView class defines a rectangular area on the screen and the interfaces for managing the content in that area. At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content.

UIAlertController

MKMapView

UIColor

NSAttributedString

CAAnimation

CAAnimation is an abstract animation class. It provides the basic support for the CAMediaTiming and CAAction protocols. To animate Core Animation layers or Scene Kit objects, create instances of the concrete subclasses CABasicAnimation, CAKeyframeAnimation, CAAnimationGroup, or CATransition.

UITextView

UINavigationController

From the documentation:

The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This navigation interface makes it possible to present your data efficiently and makes it easier for the user to navigate that content. You generally use this class as-is but you may also subclass to customize the class behavior.

Concurrency

Whenever you do something on a separate thread, which happens when using queues, it's important to maintain thread safety. Some methods, in particular ones for UIViews, may not work and/or crash on threads other than main thread. Also, make sure not to change anything (variables, properties, etc.) that is also being used on the main thread, unless you are accounting for this change

CAGradientLayer

  • Use startPoint and endPoint to change the orientation of the CAGradientLayer.
  • Use the locations to affect the spread/positions of the colors.

UIGestureRecognizer

Custom UIViews from XIB files

From Apple: Creating a Custom View That Renders in Interface Builder

  • Note: Keep in mind that if you'd use fancy 'custom' fonts in your XIB elements (such UILabel, UITextField etc) then the initial loading time of your XIB will be longer depending on the font chosen and system version.

Safari Services

UIStackView

UIImage

UIWebView

UIWebView Delegate functions:-

Objective-C Declerations

- (BOOL)webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest *)request 
 navigationType:(UIWebViewNavigationType)navigationType;

- (void)webView:(UIWebView *)webView 
didFailLoadWithError:(NSError *)error;

- (void)webViewDidFinishLoad:(UIWebView *)webView;

- (void)webViewDidStartLoad:(UIWebView *)webView;

CALayer

iOS - Implementation of XMPP with Robbie Hanson framework

Swift and Objective-C interoperability

NSDate

There are different types of date format that you can set: Here is full list of them.

FormatMeaning/DescriptionExample1Example2
yA year with at least 1 digit.175 AD → “175”2016 AD → “2016”
yyA year with exactly 2 digits.5 AD → “05”2016 AD → “16”
yyyA year with at least 3 digits.5 AD → “005”2016 AD → “2016”
yyyyA year with at least 4 digits.5 AD → “0005”2016 AD → “2016”
MA month with at least 1 digit.July → “7”"November" → "11"
MMA month with at least 2 digits.July → “07”"November" → "11"
MMMThree letter month abbreviation.July → “Jul”"November" → "Nov"
MMMMFull name of month.July → “July”"November" → "November"
MMMMMOne letter month abbreviation(Jan,June,July all will have 'J').July → “J”"November" → "N"
dDay with at least one digit.8 → “8”29 → “29”
ddDay with at least two digits.8 → “08”29 → “29”
“E”, “EE”, or”EEE”3 letter day abbreviation of day name.Monday → “Mon”Thursday → “Thu”
EEEEFull Day name.Monday → “Monday”Thursday → “Thursday”
EEEEE1 letter day abbreviation of day name.(Thu and Tue will be 'T')Monday → “M”Thursday → “T”
EEEEEE2 letter day abbreviation of day name.Monday → “Mo”Thursday → “Th”
aPeriod of day (AM/PM).10 PM → “PM”2 AM → “AM”
hA 1-12 based hour with at least 1 digit.10 PM → “10”2 AM → “2”
hhA 1-12 based hour with at least 2 digits.10 PM → “10”2 AM → “02”
HA 0-23 based hour with at least 1 digit.10 PM → “14”2 AM → “2”
HHA 0-23 based hour with at least 2 digits.10 PM → “14”2 AM → “02”
mA minute with at least 1 digit.7 → “7”29 → “29”
mmA minute with at least 2 digits.7 → “07”29 → “29”
sA second with at least 1 digit.7 → “7”29 → “29”
ssA second with at least 2 digits.7 → “07”29 → “29”

There are many more, for getting different time based on zone(z), for getting time with millisecond details(S), etc.

Custom fonts

AVSpeechSynthesizer

UIBarButtonItem

Referencing self.navigationItem assumes that the UIViewController is embedded inside a UINavigationController.

UIScrollView

Localization

NSNotificationCenter

UITextField

Alamofire

UIViewController

iBeacon

Beacons are IOT objects. We are focusing on those which conform to iBeacon protocol a Apple standard. Each beacon is a one way device which transmits 3 things

  1. UUID
  2. Major
  3. Minor

We can scan iBeacons by setting up our CLLocation manager object to scan for beacons for particular UUID. All beacons with the given UUID will be scanned.

CLLocation manager also gives call on enter and exit of beacon region.

CLLocation

NSURLSession

The NSURLSession class and related classes provide an API for downloading content. This API provides a rich set of delegate methods for supporting authentication and gives your app the ability to perform background downloads when your app is not running or, in iOS, while your app is suspended.

At a high level, NSURLSession is based around the concept of sessions and tasks. A task represents a single request for a single URL (or a single upload to a single URL). A session is a group of related requests.

The operating system provides a single preexisting session—the shared session, which basically works like NSURLConnection. Additionally, you can create your own sessions in your app as needed.

Different apps use sessions in different ways. Many apps create a single session on launch and just keep reusing it. Other apps benefit from being able to cancel a group of related tasks (e.g. a web browser canceling all outstanding requests when you close a tab), and thus create one session to hold each group of related requests.

The first step when using NSURLSession is to create a session configuration object. The (usually) reusable object contains various session settings that you can tweak for your particular needs, such as maximum concurrency, extra headers to send with each request, whether to allow requests to be sent over the cellular radio (iOS only), timeouts, credential storage, minimum TLS version, and even proxy settings.

There are three types of session configurations, depending on how you want the resulting session to behave:

  • Default configurations create sessions that work much like NSURLConnection.
  • Background configurations create sessions in which requests happen out-of-process, allowing downloads to continue even when the app is no longer running.
  • Ephemeral configurations create sessions that do not cache anything to disk, do not store cookies to disk, etc. and thus are suitable for backing things like incognito browser windows.

When you create a background configuration, you must provide a session identifier that allows you to reassociate the background session later (if your app exits or is suspended or terminated by the OS). You must not have more than one instance of a session with the same identifier active in your app, so as a rule, these configurations are not reusable. All other session configurations can be reused to create as many sessions as you want. So if you need to create multiple sessions with similar settings, you can create the configuration once and reuse it every time you create a new session.

After you create a session, you can create tasks in that session. There are three types of tasks:

  • Data tasks return data as an NSData object. These are suitable for general use, but are not supported in background sessions.
  • Download tasks return data as a file on disk. These are suitable for larger requests, or for use in background sessions.
  • Upload tasks upload data from an NSData object or from a file on disk. You provide a data object or file that provides the POST body. The body data/file that you provide on the task overrides any body data/file provided in the NSURLRequest object (if applicable).

Each of these types lets you obtain the response data in a couple of different ways—either by using block-based callbacks or by providing a delegate on the session and implementing delegate methods.

Additionally NSURLSession lets you provide delegate methods for handling authentication, performing custom TLS certificate handling (both for client certificates and server validation), changing the caching behavior, and so on.

UISwitch

Checking iOS version

Universal Links

  1. When you support universal links, iOS 9 users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn’t installed, tapping a link to your website opens your website in Safari.
  2. Generally, any supported link clicked in Safari, or in instances of UIWebView/WKWebView should open the app.
  3. For iOS 9.2 and less, this will only work on a device. iOS 9.3 also supports the simulator.
  4. iOS remembers the user’s choice when opening Universal Links. If they tap the top-right breadcrumb to open the link in Safari, all further clicks will take them to Safari, and not the app. They can switch back to opening the app by default by choosing Open in the app banner on the website.

UICollectionView

PDF Creation in iOS

In-App Purchase

NSTimer

An NSTimer allows you to send a message to a target after a specified period of time elapses.

CGContext Reference

The CGContextRef opaque type represents a Quartz 2D drawing destination. A graphics context contains drawing parameters and all device-specific information needed to render the paint on a page to the destination, whether the destination is a window in an application, a bitmap image, a PDF document, or a printer.

UITabBarController

UISearchController

UIActivityViewController

Core Location

Simulate a Location at Runtime

  1. Run the app from Xcode.
  2. In the debug bar, click the "Simulate location" button.
  3. Choose a location from the menu.

Simulate location - debug

FacebookSDK

AFNetworking

CTCallCenter

UIImagePickerController

NSUserDefaults

UIControl - Event Handling with Blocks

UIBezierPath

UIPageViewController

UIAppearance

Push Notifications

Key Value Coding-Key Value Observation

KVC :- Key-Value Coding

Normally instance variables are accessed through properties or accessors but KVC gives another way to access variables in form of strings. In this way your class acts like a dictionary and your property name for example “age” becomes key and value that property holds becomes value for that key.

For example, you have employee class with "age" property. Normally we access like this.
emp.age = @”20″;
NSString age = emp.age; 

But KVC works like this: 
[emp valueForKey:@"age"]; 
[emp setValue:@"25" forKey:@"age"];

KVO :- Key-Value Observer

The mechanism through which objects are notified when there is change in any of property is called KVO. Ex.:keyboard notification

For example, person object is interested in getting notification when accountBalance property is changed in BankAccount object. To achieve this, Person Object must register as an observer of the BankAccount’s accountBalance property by sending an addObserver: forKeyPath: options: context: message.

Initialization idioms

Storyboard

Background Modes and Events

Fastlane

CAShapeLayer

The CAShapeLayer class draws a cubic Bezier spline in its coordinate space. The shape is composited between the layer's contents and its first sublayer.

WKWebView

UUID (Universally Unique Identifier)

To save the UUID we can use SSKeychainUtility. Example can be found on Github page

Categories

Categories can be used to override methods of a class. Even if the method is actually private. The overridden method cannot be accessed from the category or anywhere else. So it's important to make sure when adding methods to an existing class, that those methods don't exist already.

Handling URL Schemes

In iOS9 and above your app must list any URL schemes it will want to query. This is done by adding LSApplicationQueriesSchemes to Info.plist


iOS has built-in support for the tel, http/https ,sms, mailto, facetime schemes. It also supports http–based URLs for Youtube, Maps and iTunes apps.

Examples of built-in URL schemes:

tel: tel://123456890 or tel:123456890

http: http://www.google.com

facetime: facetime://[email protected]

mailto: mailto://[email protected]

sms: sms://123456890 or sms:123456890

Youtube: https://www.youtube.com/watch?v=-eCaif2QKfA

Maps:

  • Using address: http://maps.apple.com/?address=1,Infinite+Loop,Cupertino,California

  • Using coordinates: http://maps.apple.com/?ll=46.683155557,6.683155557

iTunes: https://itunes.apple.com/us/artist/randy-newman/id200900

Note: Not all special characters are supported in tel scheme (for example * or #). This is done because of security concerns to prevent users from unauthorized redirect of calls, so in this case Phone app won't be opened.

Realm

Adding a new RLMObject to an existing Realm - Schema and Migrations

Adding new model classes to a Realm does not require a migration or a schema version bump; only making changes to an existing Realm.

ARC (Automatic Reference Counting)

UIPickerView

Dynamic Type

// Content size category constants
UIContentSizeCategoryExtraSmall
UIContentSizeCategorySmall
UIContentSizeCategoryMedium
UIContentSizeCategoryLarge
UIContentSizeCategoryExtraLarge
UIContentSizeCategoryExtraExtraLarge
UIContentSizeCategoryExtraExtraExtraLarge

// Accessibility sizes
UIContentSizeCategoryAccessibilityMedium
UIContentSizeCategoryAccessibilityLarge
UIContentSizeCategoryAccessibilityExtraLarge
UIContentSizeCategoryAccessibilityExtraExtraLarge
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge

NSURL

SWRevealViewController

Snapshot of UIView

DispatchGroup

GCD (Grand Central Dispatch)

Size Classes and Adaptivity

As you build adaptive apps, keep in mind the limitations of size classes: they are generalizations, not specific guides for exact pixel sizes or devices. Never attempt to determine what device your app is running on, or whether it's in a split-screen mode, based on the size classes.

Instead, make high-level layout decisions on size class, and use Auto Layout to change precise view frames. (See also the UIViewController method viewWillTransition(to:with:) for a more precise notification of how big a controller's view will be after a transition.)

UIScrollView AutoLayout

IBOutlets

IBOutlet is neither a reserved word nor a variable or class, is syntactic sugar for Interface Builder. After the Objective-C source code is pre-processed it is resolved to nothing.

In Swift it's resolved as nil.

It's declared in <UIKit/UINibDeclarations.h> as

#ifndef IBOutlet
#define IBOutlet
#endif

AWS SDK

Debugging Crashes

UISplitViewController

UISplitViewController is a container class like UITabViewController, UINavigationController. It separates the main view into two View Controllers masterViewController(PrimaryViewController) and detailViewController(SecondaryViewController). we can send an array with two view controllers and Apple recommends to to UISplitViewController as a rootviewcontroller for your application. To interact between the viewcontrolers I use NSNotificationCenter.

UISplitViewController

In iOS 8 and later, you can use the UISplitViewController class on all iOS devices, in previous versions of iOS, the class is available only on iPad. UISplitViewController is a container class like UITabViewController, UINavigationController. It separates the main view into two UIViewControllers masterViewController(PrimaryViewController) and detailViewController(SecondaryViewController). we can send an NSArray with two UIViewControllers and Apple recommends UISplitViewController as a rootviewcontroller for your application. To interact between the UIViewControllers I use NSNotificationCenter.

UIDevice

The UIDevice class provides a Singleton instance representing the current device. From this instance you can obtain information about the device such as assigned name, device model, and operating-system name and version.

CloudKit

Supported Types

  • NSData
  • NSDate (Date)
  • NSNumber (Int / Double)
  • NSString (String)
  • NSArray (Array)
  • CLLocation
  • CKReference
  • CKAsset

More Details

CloudKit Dashboard

GameplayKit

Xcode Build & Archive From Command Line

Run xcodebuild from the directory containing your project to build an Xcode project. To build an Xcode workspace, you must pass both the -workspace and -scheme options to define the build. The parameters of the scheme will control which targets are built and how they are built, although you may pass other options to xcodebuild to override some parameters of the scheme.

XCTest framework - Unit Testing

NSData

AVPlayer and AVPlayerViewController

import AVKit, import AVFoundation.

Deep Linking in iOS

Useful Apple documentation with examples and clarification.

App Transport Security (ATS)

The App Transport Security is a security feature in iOS and macOS. It prevents apps from establishing unsecured connections. By default, apps can only use secure HTTPS connections.

If an app needs to connect to a server via HTTP, exceptions must be defined in the Info.plist. (see the examples for more information about that)

Note: In 2017, Apple will enforce ATS. That means, that you can no longer upload apps that have ATS-exceptions defined in the Info.plist. If you can provide good arguments, why you have to use HTTP, you can contact Apple and they might allow you to define exceptions. (Source: WWDC 2016 - Session 706)

More information on the App Transport Security configuration can be found in the CocoaKeys Documentation.

Core Graphics

Segues

UIDatePicker

UIDatePicker does not inherit from UIPickerView, but it manages a custom picker-view object as a subview.

NSPredicate

EventKit

NSBundle

SiriKit

Different types of Siri requests

  • Ride Booking (e.g. Get me a ride to New York via MyApp)

  • Messaging (e.g. Send a text to John using MyApp)

  • Photo Search (e.g. Look for beach photos taken last summer in MyApp)

  • Payments (e.g. Send $20 to John for dinner last night using MyApp)

  • VoIP Calling (e.g. Call Mike on my MyApp)

  • Workouts (e.g. Start my daily run workout from MyApp)

  • Climate and Radio (specifically designed for CarPlay, e.g. Set the heater to 72 degrees)

Contacts Framework

Dynamically updating a UIStackView

iOS 10 Speech Recognition API

NSURLConnection

StoreKit

Code signing

Create .ipa File to upload on appstore with Applicationloader

Resizing UIImage

Size Classes and Adaptivity

MKDistanceFormatter

3D Touch

GameCenter Leaderboards

Keychain

iOS stores private information such as passwords, encryption keys, certificates, and identities in a secure storage area called the Keychain. This storage area is managed completely by a co-processor called the Secure Enclave, which is embedded inside the application processor. Because the Keychain is sandboxed on iOS, keychain items may only be retrieved by the application that put them there in the first place.

In some cases you must turn on Keychain Sharing in Xcode capabilities in order to avoid errors.

In order to interact with the keychain, we use a c framework called Keychain Services. For more information, see Apple's Keychain Services Programming Guide.

Because Keychain Services is below the Foundation level, it is restricted to using CoreFoundation types. As a result, most objects are internally represented as CFDictionarys holding CFStrings as their keys and a variety of CoreFoundation types as their values.

While Keychain Services is included as a part of the Security framework, importing Foundation is usually a good option since it includes some helper functions in the backend.

Additionally, if you don't want to deal with Keychain Services directly, Apple provides the Generic Keychain Swift sample project that provides Swift types that use Keychain Services behind the scenes.

Handle Multiple Environment using Macro

Set View Background

Block

Content Hugging/Content Compression in Autolayout

Content Compression Resistance Priority

This value determines how resistant a view is to being compressed, or shrunk. A higher value here means the view will be less likely to be compressed and more likely to stay the same.

Content Hugging Priority

This value determines how resistant a view is to being expanded. You can imagine “hugging” here to mean “size to fit” – the bounds of the view will “hug” or be close to the intrinsic content size. A higher value here means the view will be less likely to grow and more likely to stay the same.

iOS Google Places API

Navigation Bar

UITextField Delegate

App wide operations

UILabel text underlining

Cut a UIImage into a circle

Make selective UIView corners rounded

Convert HTML to NSAttributed string and vice verse

Convert NSAttributedString to UIImage

CoreImage Filters

Face Detection Using CoreImage/OpenCV

MPMediaPickerDelegate

Please see the Apple Documentation for more information regarding privacy.

Make sure the Music app is available in your iPhone. It will not work in the simulator.

Graph (Coreplot)

NSHTTPCookieStorage

FCM Messaging in Swift

Create a Custom framework in iOS

Custom Keyboard

AirDrop

SLComposeViewController

AirPrint tutorial in iOS

UISlider

Carthage iOS Setup

Healthkit

Core SpotLight in iOS

UI Testing

Core Motion

QR Code Scanner

plist iOS

NSInvocation

UIRefreshControl TableView

WCSessionDelegate

AppDelegate

App Submission Process

MVVM

UIStoryboard

Basic text file I/O

iOS TTS

MPVolumeView

MPVolumeView only shows up when building and running on an actual iOS device and will not work in a simulator.

Objective-C Associated Objects

Passing Data between View Controllers (with MessageBox-Concept)

UIPheonix - easy, flexible, dynamic & highly scalable UI framework

  • Forget static layouts, constraint issues and warning explosions in the console.
  • Forget all the glue code, all the boilerplate code and all the very common overly engineered unnecessary pile of garbage code in your apps.
  • Build and make changes to your UI quickly in a snap.
  • Make your UI reusable.
  • Focus on creating your app, not fighting layout issues.
  • Minimal setup, minimal impact on your app, lightweight, no dependencies, no pain but so much gain!
  • Builds on top of collection views & table views, so you can easily mix and match.
  • Does not replace Apple technologies with custom implementations, so you will always be safe and up-to-date, and you can easily revert at any time.
  • Demo apps provided for macOS, iOS and tvOS (Kung Fu!)

Chain Blocks in a Queue (with MKBlockQueue)

Simulator

Different Types of Simulators

  • iOS Simulator
  • watchOS Simulator
  • tvOS Simulator
  • Touch Bar Simulator

There is no simulator for macOS, because Xcode is run on macOS and whenever needed, it will run the apps native.

Getting Help

You could always visit Simulator help at Help -> Simulator help:

enter image description here

Background Modes

NSArray

Once, current document gets approved, will add so many enhancement for other array utilites also. This is my first document and need your assistance and approval in my effort.

OpenGL

UIScrollView with StackView child

Cache online images

MVP Architecture

Components:

enter image description here

  • Model is an interface responsible for the domain data (to be displayed or otherwise acted upon in the GUI)
  • View is responsible for the presentation layer (GUI)
  • Presenter is the "middle-man" between Model and View. It reacts to the user’s actions performed on the View, retrieves data from the Model, and formats it for display in the View

Component duties:

ModelViewPresenter
Communicates with DB layerRenders dataPerforms queries to the Model
Raising appropriate eventsReceives eventsFormats data from Model
Very basic validation logicSends formatted data to the View
Complex validation logic

Differences between MVC and MVP:

  • View in MVC is tightly coupled with the Controller, the View part of the MVP consists of both UIViews and UIViewController
  • MVP View is as dumb as possible and contains almost no logic (like in MVVM), MVC View has some business logic and can query the Model
  • MVP View handles user gestures and delegates interaction to the Presenter, in MVC the Controller handles gestures and commands Model
  • MVP pattern highly supports Unit Testing, MVC has limited support
  • MVC Controller has lots of UIKit dependencies, MVP Presenter has none

Pros:

  • MVP makes UIViewController a part of the View component it's dumb, passive and...less massive ;]
  • Most of the business logic is incapsulated due to the dumb Views, this gives an excellent testability. Mock objects can be introduced to test the domain part.
  • Separated entities are easier to keep in head, responsibilities are clearly divided.

Cons

  • You will write more code.
  • Barrier for unexperienced developers or for those who don't yet work with the pattern.

UIKit Dynamics

An import thing to keep in mind when using UIKit Dynamics is views that are positioned by the animator cannot readily be positioned by other common iOS layout methods.

Newcomers to UIKit Dynamics often struggle with this important caveat. Placing constraints on a view that is also an item of a UIDynamicBehavior will likely cause confusion as a both the auto layout engine and the dynamic animator engine fight over the appropriate position. Similarly, attempting to set the frame directly of a view being controlled by the animator will typically result in jittery animation and unexpected placement. Adding a view as an item to a UIDynamicBehavior means that the animator will take on the responsibility of positioning a view and as such changes of view positions should be implemented through the animator.

A view's frame that is being updated by a dynamic animator can be set, but that should be immediately followed by messaging the animator to update the animator's internal model of the view hierarchy. For example, if I have UILabel, label that is an item of a UIGravityBehavior I can move it to the top of the screen to watch it fall again by saying:

Swift

label.frame = CGRect(x: 0.0, y: 0.0, width: label.intrinsicContentSize.width, height: label.intrinsicContentSize.height)
dynamicAnimator.updateItem(usingCurrentState: label)

Objective-C

self.label.frame = CGRectMake(0.0, 0.0, self.label.intrinsicContentSize.width, self.label.intrinsicContentSize.height);
[self.dynamicAnimator updateItemUsingCurrentState: self.label];

After which the animator will apply the gravity behavior from the label's new location.

Another common technique is to use UIDynamicBehaviors to position views. For example if positioning a view under a touch event is desired, creating a UIAttachmentBehavior and updating its anchorPoint in either touchesMoved or a UIGestureRecognizer's action is an effective strategy.

Configure Beacons with CoreBluetooth

Some important points

  • No capabilities are needed.
  • iPhone store bytes in Little Endian format, so check if bluetooth accessory use Little Endian too. Example:
    • intel CPU usually use little endian.
    • The ARM architecture was little-endian before version 3 when it became big-endian.
  • After a single or batch operation the connection will be lost, so you have to reconnect before continue.

Scan for SERVICE UUID

func SearchBLE(){
    cb_manager.scanForPeripherals(withServices:[service_uuid], options: nil)
    StopSearchBLE()
}

How to discover SERVICE UUID without documentation

func centralManager(_ central: CBCentralManager, didConnect peripheral:             
CBPeripheral) {
        peripheral.delegate = self
        peripheral.discoverServices(nil)
}

func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
    for service in peripheral.services! {
        print("Service: \(service)\n error: \(error)")
    }
}
  • discoverServices(nil) - NIL means that all services will be returned, which is not a good option.( READ Remarks 3)
  • If you haven't found the SERVICE UUID run your code and looking for in console enter image description here
  • I found have 3 services: Battery, Device information (Firmware) and FFF0
  • This uuid service isn't a standard one, a list with standards can find here
  • FFF0 is the SERVICE UUID in this case

Convert data to UInt16 and contrary

Add this extensions to your class

protocol DataConvertible {
    init?(data: Data)
    var data: Data { get }
}

extension DataConvertible {

    init?(data: Data) {
        guard data.count == MemoryLayout<Self>.size else { return nil }
        self = data.withUnsafeBytes { $0.pointee }
    }

    var data: Data {
        var value = self
        return Data(buffer: UnsafeBufferPointer(start: &value, count: 1))
    }
}
extension UInt16 : DataConvertible {
    init?(data: Data) {
        guard data.count == MemoryLayout<UInt16>.size else { return nil }
        self = data.withUnsafeBytes { $0.pointee }
    }
    var data: Data {
        var value = CFSwapInt16HostToBig(self)
        return Data(buffer: UnsafeBufferPointer(start: &value, count: 1))
    }
}

Core Data

Extension for rich Push Notification - iOS 10.

Profile with Instruments

Application rating/review request

MyLayout

UIFont

Simulator Builds

Simulating Location Using GPX files iOS

Custom methods of selection of UITableViewCells

Custom methods of selection of UITableViewCells

UISegmentedControl

SqlCipher integration

  1. Open the Terminal, switch into your project's root directory and checkout the SQLCipher project code using Git:
 $ git clone https://github.com/sqlcipher/sqlcipher.git
  1. Right click on the project and choose "Add Files to "My App"" (the label will vary depending on your app's name). Since we cloned SQLCipher directly into the same folder as your iOS app you should see a sqlcipher folder in your root project folder. Open this folder and select sqlcipher.xcodeproj

enter image description here

  1. Select the Build Settings pane. In the search field, type in "Header Search Paths". Double-click on the field under the target column and add the following path: $(PROJECT_DIR)/sqlcipher/src

  2. Start typing "Other Linker Flags" into the search field until the setting appears, double click to edit it, and add the following value: $(BUILT_PRODUCTS_DIR)/libsqlcipher.a

  3. Start typing "Other C Flags" into the search field until the setting appears, double click to edit it, and in the pop-up add the following value: -DSQLITE_HAS_CODEC

  4. Expand Target Dependencies and click on the + button at the end of the list. In the browser that opens, select the sqlcipher static library target:

enter image description here

  1. Expand Link Binary With Libraries, click on the +button at the end of the list, and select the libsqlcipher.a library.

enter image description here

  1. Finally, also under Link With Libraries, add Security.framework.

Custom UITextField

Security

Guideline to choose best iOS Architecture Patterns

UIFeedbackGenerator

UIKit Dynamics with UICollectionView

Multicast Delegates

Using Image Aseets

UITableViewCell

Runtime in Objective-C

ModelPresentationStyles

Always remember the following mention from Apple.

In a horizontally compact environment, modal view controllers are always presented full-screen. In a horizontally regular environment, there are several different presentation options.

CydiaSubstrate tweak

Create a video from images

Codable

FileHandle

NSUserActivity

Activity Types

Supported activity types must be defined in your app's Info.plist file under the NSUserActivityTypes key. Activities are tied to your Developer Team ID, meaning that activity coordination is restricted between apps that have the same Team ID (e.g. "Safari" could not accept a Handoff activity from "Chrome" or vice versa).

Becoming / Resigning the Current Activity

Marking an activity as current using becomeCurrent makes it available for Handoff or Spotlight Indexing. Only one activity may be current at a time. You may mark an activity as inactive without invalidating by calling resignCurrent.

If you invalidate an activity, the same instance may not be made current again.

Do not mark an activity as current when providing it for SiriKit.

Search Indexing

Activities are not to be used as a general-purpose indexing mechanism within your app. Instead, they should only be used in response to user-initiated actions. To index all content in your app, use CoreSpotlight.

Rich Notifications

Load images async

ADDING A SWIFT BRIDGING HEADER

Creating an App ID

Swift: Changing the rootViewController in AppDelegate to present main or login/onboarding flow

attributedText in UILabel

UITableViewController