Friday, 3 May 2019

iOS Topic wise code

Title
Description
Explanation
Link
Application Security.Application Security Musts for every iOS App.1. Don’t store sensitive in UserDefaults.

  1. By using a third party mac application like iMazing for the example, without even having to Jailbreak your device, you can easily view UserDefaults data for any app downloaded from the AppStore

  1. Keychain services API helps you solve these problems.

Create UILabel view outside viewDidLoad classCreate UILabel view outside viewDidLoad class and then add that view to your main view in viewDidLoad method.
1) Create UILabel view outside viewDidLoadclass and then add that view to your main view in viewDidLoad method.
lazy var myLabel: UILabel = {
    let label = UILabel(frame: CGRect(x: 10, y: 50, width: 230, height: 21))
    label.translatesAutoresizingMaskIntoConstraints = false
    label.text = "This is label view."
    label.font = UIFont.systemFont(ofSize: 12)
    return label
}()
2) And then add that view in viewDidLoad()
override func viewDidLoad() {
    super.viewDidLoad()
    view.addSubview(myLabel)
}
Variables creation
Let text: String
var response: String?
var temperature = 32.0
var width = 0.0, height = 0.0
let red, green, blue: Double


Call a function after some time

Option 1.
=======
    DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
        self.yourFuncHere()
    }
    //Your function here    
    func yourFuncHere() {
    
    }

Option 2.
=======
    perform(#selector(yourFuncHere2), with: nil, afterDelay: 5.0)
        
    //Your function here  
    @objc func yourFuncHere2() {
        print("this is...")
    }
        
Option 3.
=======
    Timer.scheduledTimer(timeInterval: 5.0, target: self, selector: #selector(yourFuncHere3), userInfo: nil, repeats: false)

    //Your function here  
    @objc func yourFuncHere3() {
        
    }

Option 4.
=======
    sleep(5)

Option 5.
=======
usleep(1000000)// will sleep for 1 sec
usleep(2000)//Will slepp 0.002 milliseconds
Open URL

if UIApplication.shared.canOpenURL(url) {
    //            UIApplication.shared.open(url, options: [:], completionHandler: nil)
    //If you want handle the completion block than
    UIApplication.shared.open(url, options: [:], completionHandler: { (success) in
             print("Open url : \(success)")
                    
     })
}

init()  {    }

//Initializers
    //Init example 1
    struct Fahrenheit {
        var temperature: Double
        init() {
            temperature = 32.0
        }
    }
    
    //Default Property Values
    //Init example 2
    struct Fahrenheit2 {
        var temperature = 32.0
    }
    
    //Initialization Parameters
    //Init example 3
    struct Celsius {
        var temperatureInCelsius: Double
        
        init(fromFahrenheit fahrenheit: Double) {
            temperatureInCelsius = (fahrenheit - 32.0) / 1.8
        }
        init(fromKelvin kelvin: Double) {
            temperatureInCelsius = kelvin - 273.15
        }
    }
    
    //Parameter Names and Argument Labels
    //Init example 4
    struct Color {
        let red, green, blue: Double
        init(red: Double, green: Double, blue: Double) {
            self.red   = red
            self.green = green
            self.blue  = blue
        }
        init(white: Double) {
            red   = white
            green = white
            blue  = white
        }
    }
    
    //Initializer Parameters Without Argument Labels
    //Init example 5
    struct Celsius2 {
        var temperatureInCelsius: Double
        init(fromFahrenheit fahrenheit: Double) {
            temperatureInCelsius = (fahrenheit - 32.0) / 1.8
        }
        init(fromKelvin kelvin: Double) {
            temperatureInCelsius = kelvin - 273.15
        }
        init(_ celsius: Double) {
            temperatureInCelsius = celsius
        }
    }
    
    //Initializer with init and function
    //Init example 6
    class SurveyQuestion {
        var text: String
        var response: String?
        init(text: String) {
            self.text = text
        }
        //Function
        func ask() {
            print(text)
        }
    }
        //In ViewDidLoad
        //Init example 1
        let f = Fahrenheit()
        print("The default temperature is \(f.temperature)° Fahrenheit")
        // Prints "The default temperature is 32.0° Fahrenheit"
    
        //Init example 2
        print(Fahrenheit2().temperature)
        
        //Init example 3
        let boilingPointOfWater = Celsius(fromFahrenheit: 210.0)
        // boilingPointOfWater.temperatureInCelsius is 100.0
        print(boilingPointOfWater)
        let freezingPointOfWater = Celsius(fromKelvin: 270.15)
        // freezingPointOfWater.temperatureInCelsius is 0.0
        print(freezingPointOfWater)
        
        //Init example 4
        let magenta = Color(red: 1.0, green: 0.0, blue: 1.0)
        print(magenta)
        let halfGray = Color(white: 0.5)
        print(halfGray)
        
        //Init example 5
        let bodyTemperature = Celsius2(37.0)
        // bodyTemperature.temperatureInCelsius is 37.0
        print(bodyTemperature)
        
        //Init example 6
        let cheeseQuestion = SurveyQuestion(text: "Do you like cheese?")
        cheeseQuestion.ask()
        // Prints "Do you like cheese?"
        cheeseQuestion.response = "Yes, I do like cheese."

        
FBSDK Integration tutorial


https://www.spaceotechnologies.com/integrate-facebook-sign-in-button-ios-app/
Get FB contacts list code


https://stackoverflow.com/questions/29428478/facebook-friends-list-api-for-swift-ios
Twitter Integration tutorial


https://www.brewit9.com/2017/10/twitter-login-integration-in-ios-using.html
LinkedIn Integration tutorial

https://www.appcoda.com/linkedin-sign-in/http://www.theappguruz.com/blog/integrate-linkedin-sdk-in-ios
Push notifications tutorial


https://medium.com/ios-os-x-development/learn-master-%EF%B8%8F-ios-remote-push-notifications-in-2018-in-under-10-minutes-825ca6bee092
How to use two versions of Xcode’s tutorial


https://medium.com/@hacknicity/working-with-multiple-versions-of-xcode-e331c01aa6bc
SafeAreaLayout tutorialhttps://medium.com/@kahseng.lee123/how-to-solve-the-most-common-interface-problems-when-adapting-apps-ui-for-iphone-x-44c0f3c80d84https://medium.com/@kahseng.lee123/creating-custom-navigation-bar-tab-bar-for-iphone-x-f03b1e1827d3


https://customersupport.doubledutch.me/hc/en-us/articles/360008823394-iOS-Client-Distribution-Process-for-New-Apps


UIView animationshttps://www.journaldev.com/22104/ios-uiview-animations






























1 comment:

  1. Thanks for sharing such a great blog... I am impressed with you taking time to post a nice info.
    iPad App Development Company
    Hybrid App Development Services

    ReplyDelete

Difference between == and ===

Difference between == and === https://stackoverflow.com/questions/24002819/difference-between-and == operator checks if their ...