iOS Development Advancement (Tang Qiao) Reading Notes

Keywords: iOS github vim Mobile

How to Improve iOS Development Skills

1. Reading blogs: https://github.com/tangqiaoboy/iOSBlogCN Blog addresses of more than 40 iOS development bloggers
2. Reading: Reading a high-quality iOS development book every year
3. Watch WWDC Video
4. Look at Apple's official documents
5. Look at the code for open source projects
6. Write more code and think more
7. Communicate with colleagues more often
8. Sharing

Part I: iOS development tools

1. Reveal Interface Debugging Tool

1. Virtual Machine Integration
2. True Machine Integration (iOS Development 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

Overseas: Flurry
Domestic: Alliance

3. crash Statistical Tool

Crashlytics
Bugly(Tencent)

4. App Store Statistical Tool

App Annie

Part II: iOS Development Practice

1. Memory management of CoreFoundation objects

  • CFStringRef
CFStringCreateWithCString(kCFAllocatorDefault, "Hello World", kCFStringEncodingUTF8)
  • Converting CF objects into OC objects

    1. _ bridge: Do type conversion only, do not modify the reference count of related objects. When the original CF object is not used, it needs to call the CFRelease method.
    2. _ bridge_retained: After type conversion, the reference count of the related object is added to 1. When the original CF object is not used, the CFRelease method needs to be called.
    3. _ bridge_transfer: After type conversion, the reference count of the object is handed over to ARC management, and the CF object does not need to call the CFRelease method when it is not in use.

2,GCD

  • Execute once
    Dispatch [once code prompt
  • Delayed execution
    dispatch_after code prompt
  • Custom queue
dispatch_queue_t urls_queue = dispatch_queue_create("blog.devzhang.com", NULL);
dispatch_async(urls_queue, ^{

});
dispatch_release(urls_queue);
  • Multithread processing, and finally summarize the results (specific use?)
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
    // Thread 1 for parallel execution
});
dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
    // Thread 2 for parallel execution
});
dispatch_group_notify(group, dispatch_get_global_queue(0, 0), ^{
    // Summarize the results
});

1. NSJSONSerialization is better than NSKey Archiver

When choosing a persistence solution, the NSJSONSerialization provided by the system is more efficient and volume-efficient than NSKey Archiver.
NSJSONSerialization is seven times faster and half smaller than NSKey Archiver.
Detailed tests are available online: https://github.com/randomsequence/NSSerialisationTests

2. Use Block cautiously

block is prone to circular reference problems
Architecturally, if you use a block, you need to always be careful to avoid circular references. So it's better not to use block. Using delegate to achieve much safer

Note: Class methods never produce circular references!

3. Ignore compilation warnings

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

Posted by Sonu Kapoor on Thu, 10 Oct 2019 04:53:56 -0700