Advanced iOS development (Tang Qiao) reading notes (a)

How to improve iOS development skills

1. Read the blog: https://github.com/tangqiaoboy/iOSBlogCN more than 40 iOS development blogger blog address
2, reading: reading one book a year to develop high-quality iOS
3, see the video WWDC
4, look at Apple official documentation
5, to see open source project code
6, write the code, think more about
7, and more and peer exchange
8 Share

The first part: iOS development tools

1, Reveal interface debugging tool

1, the virtual machine integrated
2, integrated real machine (iOS development of advanced P47)

vim ~/.lldbinit
command alias reveal_load_sim expr (void*)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
command alias reveal_load_dev expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle]               pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter]           postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter]            postNotificationName:@"IBARevealRequestStop" object:nil];

2, mobile statistical tools

Foreign: Flurry (not the wall)
Domestic: Friends of the Union

3, crash statistics tool

Crashlytics
Bugly (Tencent)

4, App Store statistical tools

App Annie

The second part: iOS development practices

1, CoreFoundation object memory management

  • CFStringRef
CFStringCreateWithCString(kCFAllocatorDefault, “Hello World”, kCFStringEncodingUTF8)
  • CF selected objects into the object OC

    1. __bridge: only type conversion, not modify object's reference count, the original CF objects when not need to call methods CFRelease
    2. __bridge_retained: After conversion type, the reference count is incremented related objects, the original CF objects when not need to call methods CFRelease
    3. __bridge_transfer: after type conversion, object reference count to the ARC management, CF objects when not in use, do not need to call the method CFRelease

2、GCD

  • The implementation of a
    dispatch_oncecode hints
  • Delay the execution of
    dispatch_aftercode hints
  • Custom queue
dispatch_queue_t urls_queue = dispatch_queue_create(“blog.devzhang.com”, NULL);
dispatch_async(urls_queue, ^{

});
dispatch_release(urls_queue);
  • Multi-threaded processing, final summary results (specific use?)
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
    // 并行执行的线程一
});
dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
    // 并行执行的线程二
});
dispatch_group_notify(group, dispatch_get_global_queue(0, 0), ^{
    // 汇总结果
});

1, NSJSONSerializationthan NSKeyArchiverbetter

When selecting persistence scheme, the system provides a NSJSONSerializationratio of NSKeyArchiverthe volume and efficiency are better.
NSJSONSerializationThan NSKeyArchiverfaster 7 times, small half
-line detailed test: https://github.com/randomsequence/NSSerialisationTests

2, caution Block

blockEasy to produce a circular reference problem
from an architectural perspective, if you are using blockwhen needed constant attention to avoid the circular reference problem. So might as well not use block. Use delegateto achieve to secure more

Note: class method can not produce a circular reference!

3, ignoring compiler warnings ⚠️

https://blog.csdn.net/denggun12345/article/details/83586790

Guess you like

Origin www.cnblogs.com/gfxxbk/p/11646802.html