IVGuide

  • phone_intro:
  • 1.Fundamentals:
    • differences between let and var:let represents a const but var represents an variable. you can’t reassign a let.
    • nil: nil represents an absence of value.in swift Optional ends up with a question mark.but non-optional ends up with a exclamatory mark. in swift, can use
    • differences between struct and class in swift: Classes are reference types.they will increase reference count when pass to function or assigned to variable.structs are value types.it will be copied instead of increase the reference count.
    • how is memory managed in iOS:OC uses Automatic Reference Counting.it increases count when assign instance types to variables or properties. and automatic dealloc when count comes to zero.
    • Reference Cycles:in swift, use weak or unowned to break Cycles.weak means the object may be nil,it’s an optional type. unowned means the object should not be nil it will have a value when init.
    • differences between properties and instance variables: a property can be used to get or set an instance variable.there are several keywords such as strong, weak, assign, readonly, readwrite that can be used to represents and do synthesize things. in OC, property can be used to use KVO.(swift equalization as willSet and didSet)
    • protocol: protocols are declarations of what a type that adopts them should implement.
    • category: a way to extend existing functionality of a class .category cannot add new stored properties. but it can be used to add some associated_objects .
    • closure/blocks: they capture a piece of executable code that launched at a later time.they are reference types and will strong reference everything otherwise specified. __block, __weakhttp://www.qingpingshan.com/rjbc/ios/293316.html, http://blog.csdn.net/abc649395594/article/details/45476925
    • MVC:software design pattern.
    • singletons: the class return one and only instance.(Xiachufang use currentUser as a singleton instance)
    • delegate: a kind of mechanism of event observation.
    • KVO:https://github.com/ChenYilong/iOSInterviewQuestions/blob/master/01%E3%80%8A%E6%8B%9B%E8%81%98%E4%B8%80%E4%B8%AA%E9%9D%A0%E8%B0%B1%E7%9A%84iOS%E3%80%8B%E9%9D%A2%E8%AF%95%E9%A2%98%E5%8F%82%E8%80%83%E7%AD%94%E6%A1%88/%E3%80%8A%E6%8B%9B%E8%81%98%E4%B8%80%E4%B8%AA%E9%9D%A0%E8%B0%B1%E7%9A%84iOS%E3%80%8B%E9%9D%A2%E8%AF%95%E9%A2%98%E5%8F%82%E8%80%83%E7%AD%94%E6%A1%88%EF%BC%88%E4%B8%8B%EF%BC%89.md#46-%E5%A6%82%E4%BD%95%E6%89%8B%E5%8A%A8%E8%A7%A6%E5%8F%91%E4%B8%80%E4%B8%AAvalue%E7%9A%84kvo, Key-Value observation and mechanics that can observe changes on properties. when assign a property it will call will Change Value for key and didChange Value for key and trigger the broadcast.FRP projects like ReactiveCocoa and RxSwift built on it.
    • lifecycle:UIApplicationDelegate protocol.
      • application:didFinishLaunchingWithOptions
      • applicationWillEnterForeGround
      • applicationDidBecomeActive
      • applicationWillResignActive
      • applicationDidEnterBackground
      • applicationWillTerminate
    • UIViewController:
      • the vc can be init with init constructors or load from a storyboard and call initWithCoder
      • loadView
      • viewDidLoad
      • viewWillAppear
      • viewWillLayoutSubviews
      • viewDidLayoutSubviews
      • viewDidAppear
      • viewWillDisappear
      • viewDidDisappear
      • didReceiveMemoryWarning
  • 2.networking

    • wht is HTTP(Hypertext Transfer Protocol) : 记住headers中的几个名字:Accept, Accept-Language, Cache-Control, Cookie, HOST, User-Agent
    • what is REST:REST is an API architecture that resolves around resources and HTTP verbs.
    • How do you typially implement networking in iOS:decouple all the HTTP in my app to a set of service and client objects that handle HTTP connection.all this includes:
      1.a networking manager of some kind
      2.an APIClient that be configured with this manager to perform the request to specific domain.the API Client is responsible for signing requests with auth token/credentials
      3.a set of service objects to each restful api so that they could compose params and other necessary data
    • the concerns and limitations of networking: battery and bandwidth.so we should use few requests as possible and retry requests if they fail due to a poor connection.it’s not advised to use wifi when download/upload large files.
    • what should go into the networking/service layer.(….)
    • what’s NSURLSession:since iOS7 introduced.a replacement for NSURLConnection.
    • AFNetworking/Alamofire:wrappers around NSURLSession.It’s easy to use and wrap some delegates api to blocks. and wraps a lot of apis such as progress give a block api.
    • handle multi-threading with networking on iOS:do not block the main UI thread. using background thread to progress network.(AFNetworking and alamofire had already have thread mechanics built in.)
    • how to serialize and map JSON data coming from the backend:NSJSONSerialization is the tool for JSON serialization. after the serialization to a dictionary. use like Mantle or ObjectMapper to map them into models.
    • how to download images on iOS: at the most of the time ,use thirdparty library that takes care of a lot of downloading and caching biolerplat.such as AFNetworking and Alamofire, tooks download, SDWebImage tooks downloading and caching.cause it has some UIImageView extensions
    • how would you cache images: 1.in-memory cache:NSCache 2.database storage: core data or realm or similar database to handle small images.3. disk storage
    • download files:1.work with received data in memory in the callback 2. received the file in a temporary folder for later use 3.store the file on the disk
    • socket&pubsub system:###
    • Restkit:used for rest api object mapping.request and response serializating.
    • mantle. JSONModel
    • how do you test network requests:unit testing generally do unit testing or mock data if really necessary.
  • 3.store data

    • storage layer: used for storing data and keeping track of state.typical set of classes: Keychain, NSUserDefault, file manager, AVFoundation , NSManagedObject, etc.
    • what can use to store data: In memory, NSUserdefaults/Keychain, File storage, CoreData, Realm, SQLite
    • what’s NSCoding:it’s a cocoa protocol that alows objects to be serialized
    • what’s NSUserDefaults: one of common tools used for lightweight storage.typically used to store user preferences and flags
    • Keychain:it’s a secure alternative to NSUserDefaults. main user case is to store small objects such as tokens and passwords, securely.
    • how do you save data on disk: NSFileManager
    • database options:CoreData, Realm, NSFetchResultController, SQLite
    • data mapping:db->raw data->data models. just like CoreData NSManaged Object, you must serialize them to intergrate with MVC other parts
    • in Core Data, you just need to add a new version .on other kinds of databases, you can write some migrate scripts.
  • 4.layouts

    • the chanllenges in working with UI on iOS: mutiple screen sizes. mutiple devices such as Phone, Pad,dynamic content of various sizes.
    • how to layout views correctly: old way ,setting frames.since iOS6, using autolayout.
    • what are cgrect frames:CGRect is a struct that represents a rectangle a view is placed at, it has origin with x, and y, and size with width and height.
    • what are autolayout:a technolgy that helps you define relationships between views.using NSLayoutConstraint, NSLayoutRelations, constants and priority.also some libraries built such as Masonry.
    • compression resistance and content hugging priorities:compression resistance defines how your view behave when under pressure of other constraints.hugging priority is the opposite of compression resistance.defines how grow under pressure of other constains.
    • how does autolayout work with multi threading:all UI changes must be done under main threads.every autolayout constraints addition or removal needs to be done under main thread.after change constraints, call setNeedsLayout.
    • advantages and disadvantages of creating autolayout in code vs. using storyboards:advantages of using xib drag-n-drop render the UI in interface builder. disadvantage: debug and work in a team of more than two.
    • how do you work with storyboard in large team:dont’ use storyboards.or split the storyboard into multiple.
    • how do you mix autolayout with frames:they can coexist only when you’re not mixing them directly.such as superview layoutit self and subview using constraints. view that needs to use frames override the layoutsubviews method.
    • what options you have with animations:1.UIKit justlike UIView.animateWithDuration 2.CoreAnimation CABasicAnimation 3.UIKit Dynamics works with UIDynamicItems
    • how do you work with UITableView:init it and implement the UITableViewDelegate and UITableViewDataSource.it has several sections, each section has UITableViewCell to reuse.UITableViewDelegate is response for calculating cell’s and cells heights. DataSource is the source of the data of the table.
    • how to optimize tableViews performance:it’s a big issue.cache height.or use IGListView
    • UICollectionView:uicollectionview datasource& delegate && uicollectionview layout.
    • UIStackView is available from 9.0
  • 5.patterns

    • what design patterns common used in iOS:MVC, Singleton(global state), Delegate, Observer
    • what’s MVC:
    • what’s MVVM:except mvc, we’ve also have view model plays an important role in data presentation.