kkbox-ios-dev 노트(8)-(끝)

6483 단어
실현NSCoding
  • NSCoding는 하나의 협의로 두 가지 방법밖에 없다.
  • encodeWithCoder:는 대상을 통과NSCoder를 통해NSData로 전환했다.
  • initWithCoder:를 통해NSCoder를 통과한 다음NSData를 대상으로 되돌려줍니다.
  • @protocol NSCoding

    • (void)encodeWithCoder:(NSCoder *)aCoder;
    • (id)initWithCoder:(NSCoder *)aDecoder;
      @end
    >  /  ,    ( )
    >
    >####State Preservation and Restoration
    >* iOS6    API,  APP         ,          APP     ,            ,    APP     /     。
    >* **  **:          ,  APP          ,           ,             ,     ,          。
    >
    >*         
    >  * `- (void)encodeRestorableStateWithCoder:(NSCoder *)coder`
    >  * `- (void)decodeRestorableStateWithCoder:(NSCoder *)coder`
    >*  `AppDelegate`    
    >  * `application: shouldSaveApplicationState:`
    >  * `application: shouldRestoreApplicationState:`
    >  * `application: willEncodeRestorableStateWithCoder:`
    >  * `application: didDecodeRestorableStateWithCoder:`
    >  * `application: willFinishLaunchingWithOptions:`
    > *   :
    >  *       ,    `application: shouldSaveApplicationState:`      ,   `BOOL`  。
    >  *         ,      `application:  shouldRestoreApplicationState:`,      `NSCoder`,          。   App           ,                ,     :
    > 
    >   ```swift
    >  - (void)application:(UIApplication *)application
    willEncodeRestorableStateWithCoder:(NSCoder *)coder
    {
            NSMutableArray *viewControllers = [self.navigationControllers
    .viewControllers copy];
            NSData *data = [NSKeyedArchiver archivedDataWithRootObject:v
    iewControllers];
            [coder encodeObject:data forKey:@"viewControllers"];
    }
    >  ```
    >  *         ,           `NSCoder`    ,    ` application: shouldRestoreApplicationState:`,           ,     。
    >  *    ,`application: didDecodeRestorableStateWithCoder:`      ,                 ,     :
    >  
    >  ```swift
    >  - (void)application:(UIApplication *)application
    didDecodeRestorableStateWithCoder:(NSCoder *)coder
    {
            NSData *data = [coder decodeObjectForKey:@"viewControllers"]
    ;
            NSArray *viewControllers = [NSKeyedUnarchiver unarchiveObjec
    tWithData:data];
            self.navigationController.viewControllers = viewControllers;
    }
    > ```
    
    ##Crash Reports(    )
    >####  `Xcode`  
    >*     ,  Xcode     ,   `Window` -> `Devices`。
    >
    ![Snip20170328_4.png](http://upload-images.jianshu.io/upload_images/2390274-eb53513f0cc8aa0f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    >
    ![Snip20170328_7.png](http://upload-images.jianshu.io/upload_images/2390274-b99d09c958f75fca.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    >*    `crash` , `console`                 。
    >
    ![Snip20170328_8.png](http://upload-images.jianshu.io/upload_images/2390274-68f5886d8189133c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    >
    >####  iTunes Connect  
    >*   `iTunes Connect`      APP       ,   ,       :**    **
    >*   Xcode      ,   `Window` -> `Organizer`,            ,       ,           。
    >
    ![Snip20170329_1.png](http://upload-images.jianshu.io/upload_images/2390274-8201f6ae8fb031fe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    >
    >####        ( )
    >####         ( )
    
    ##Core Animation
    >####CALayer
    >iOS     `view`   `CALayer`    。Mac   `NSView`    `CALayer`,    `NSView` `wantsLayer`   `YES`,        `CALayer`  ,  `NSView` `layer`  。
    >
    >####CALayer UIView   
    >* `UIView`     ,   `Core Animation`  ,   `UIView`   ,      `CALayer`   。
    >* `UIView`   `CALayer`            ,   `CALayer`     ,     0.25     ,  `UIKit`            。
    >* `drawRect:`       `view`,    `CALayer`   。
    >* `drawViewHierarchyInRect:afterScreenUpdates:`:iOS7   ,      UI                `View`,  `CALayer`            。    API        `UIKit`、`Quartz`、`OpenGL ES`、`SpriteKit`            。
    >
    > > ```swift
    > > + (UIImage *)screenshotOfView:(UIView *)view{
    > >     if (CGRectIsEmpty(view.frame)) {
            return nil;
        }
        UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, 0.0);
        if ([view respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
        // afterScreenUpdates        NO
           [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
        }
        else{
            [view.layer renderInContext:UIGraphicsGetCurrentContext()];
        }
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return image;
    }
    > > ```
    >  
    >
    >####  `CALayer`        
    >*               ,     `layer`  ,       `frame`,  `layer`  `super layer` ,                 。
    >* `CALayer`     ,        ,   `Retina Display`           。    `CALayer`          ,    `contentsScale`  
    >  * `layer.contentsScale = [UIScreen mainScreen].scale;`
    > 
    > ####  `drawInContext:`  
    > ```swift
    > - (void)drawInContext:(CGContextRef)ctx
    {
        UIGraphicsPushContext(ctx);
        // Your drawing code here.
        UIGraphicsPopContext();
    }
    > ```
    
    *                
    
    ##Audio APIs
    >####System Sound Services
    >*        
    >* `AudioServicesCreateSystemSoundID`   `AudioServicesPlaySystemSound`
    >
    >```swift
    >- (IBAction)testSystemSound:(id)sender 
    {
        SystemSoundID soundID;
        NSString *strSoundFile = [[NSBundle mainBundle] pathForResource:@"alertsound" ofType:@"wav"];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:strSoundFile],&soundID);
        AudioServicesPlaySystemSound(soundID);
    }
    >```
    >
    >####OpenAL
    >*                。
    >
    >####NSSound、QuickTime、AV Foundation
    >* `NSSound`:     `Mac`          ,        ,        ,    ,     。         `Audio Player`,                  
    >
    >* `AV Foundation`:        
    >  * `AVAudioPlayer`:      ,          ,       
    >  * `AVPlayer`:iOS4   ,          
    >  * `AVAudioEngine`
    > 
    > ####Audio Queue
    > *              C API
    > *          ,       。
    
    
    ##  
    *           ,              。
    *       ,       ,      ,    。
    
    >               ,          。                ,             ,        ,             。              。
    
    >     `Audio APIs`,  `KKBOX`        ,     `Audio`     。
    
    >            。
    >            ,    :         ,     。

    좋은 웹페이지 즐겨찾기