iOS Development Basics-Fragmentation 42

Source: Internet
Author: User

1: reported thread 1:exc_bad_access (code=1,address=0x70********) Flash back

This error is often a memory management problem, usually caused by access to an object that has already been disposed of, and the Zombie object (Zombie Objects) can be turned on to locate the problem:

In the Xcode menu:

Product->scheme->edit Scheme->run

In the options on the right, select Enable Zombie Objects to view detailed error messages;

2: Static library (SDK) knowledge points

1.1 Static libraries and the existence of dynamic libraries: static libraries:. A and. Framework dynamic libraries:. Dylib and. framework1.2 static libraries and dynamic libraries: the static library is completely copied to the executable when it is linked, Multiple copies are used multiple copies of the dynamic library: The link is not copied, the program is dynamically loaded into memory by the system, for program calls, the system is only loaded once, multiple programs shared, save memory Note: If you use a dynamic library in the project, Apple will reject 1.3 Static library file version (4 kinds) True-debug version true machine-release version simulator-debug version simulator-release version 1.3.1 Debug (Debug) version 1. Contains complete symbolic information to facilitate debugging 2. Code is not optimized 1.3.2 Release (release) Version 1. Does not contain complete symbol information 2. The execution code is optimized for 3. The size will be slightly smaller than the debug version of 4. The release version will be faster in terms of execution speed (but does not mean a significant improvement) so we typically package release releases in general development, providing the outside world with attention to two different mode and then merge; Introduction to the CPU architecture of the device (Supplemental knowledge) Simulator: 4s~5:i3865s~6plus:x86_64:3gs~4s:armv75~5c:armv7s (Static library only supports ARMV7, Can run on the armv7s architecture) 5s~6plus:arm64

A: Because the dynamic. Framework Apple shelves is not allowed, so only in a static way; Remember to select the iOS version that you want to run when you make a static library;

B: About the resource file bundle will be included after generating the framework, you can manually move the bundle out, and then to the caller, otherwise placed in the framework in the project can not introduce bundles, has not been recognized;

C: Check the currently supported CPU architectures, address correctly, then apply Lipo-info (below this is for the framework, if yes. A can be viewed directly to Lipo-info xxxx.a)

Framework Consolidation Directives

Lipo-create Debug-iphoneos/jiacoresdk_share.framework/jiacoresdk_share Debug-iphonesimulator/jiacoresdk_ Share.framework/jiacoresdk_share-output Jiacoresdk_share

Note that the framework merges the files inside the. Framework and then generates one, replacing it with one. Framework, this is the file we want;

A merger of. A can be found in the following article;

D:.A is different from the. Framework,. A to put open header files in the calling project, and. The framework can only open a header file, but the two public header files are still required;

E: When making Jingku, remember to set the Mach-o type of the build settings in Tagerts to the static Library.

F: Note the minimum iOS version of the. A or. Framework technology, which is generated and then merged on the real machine with the simulator at build time;

G: about how to create the. A and. Framework Knowledge Points:

Address: Http://www.jianshu.com/p/8f5b9855efb8 "IOS Static Library development"

Address: http://www.cnblogs.com/richard-youth/p/4856841.html "iOS Static Library summary-(YOOWEI)"

Address: Http://www.jianshu.com/p/c305175bfab2 "iOS Development and expansion-static library"

Address: Https://github.com/wujunyang/jiaCoreSDK "small instance"

Address: https://www.sdk.cn/news/3342 "Static library contains issues that other static library SDKs should be aware of"

Examples of 3:ios agents (protocol and Delegate)

Let's take a look at the code used by protocol and delegate to have a holistic understanding

Suppose there are two classes: Personone and Persontwo,

Personone is the principal, and Persontwo is the agent.

PesonOne.h

#import <Foundation/Foundation.h> @protocol something<nsobject>//need to be proxied event-(void) DoSomething: ( NSString *) someThing; @end @interface personone:nsobject//There's something you need someone to do for themselves//to replace their own people must do this thing, need to know about the relevant agreements; @property (weak ID <SomeThing> delegate;//weak: There's no need to allocate space for this delegate because it's done. ID: As long as it is an object can. @end

PersonTwo.h

#import <Foundation/Foundation.h> #import "PersonOne.h" @interface persontwo:nsobject<something>//Plus <SomeThine> indicates that the agent knows the relevant agreement and can take over the agent. @end

Persontwo.m

#import "PersonTwo.h" @implementation persontwo//agent began to do the things entrusted to the party (must be achieved)-(void) DoSomething: (nsstring*) something{        NSLog (@ "%@ ........", someThing);} @end

The real realization of the two sides is interrelated

Main.m

#import <Foundation/Foundation.h> #import "PersonTwo.h" #import "PersonOne.h" int main (INTARGC, const char * argv[] {     @autoreleasepool {  //TRUE implementation of the association between the agent and the principal    personone *pa = [[Personone alloc]init];             Persontwo *PB = [[Persontwo alloc]init];           PB instead of PA to complete event    pa.delegate = PB;  Use Pa.delegate to determine if PB  //is used [pa.delegate respondstoselector: @selector (dosomething:)] To determine whether PB implements the required method. if (pa.delegate && [pa.delegate respondstoselector: @selector (dosomething:)]) {  //PA provides a parameter to PB (only responsible for supplying parameters, Regardless of specific use)    [pa.delegate dosomething:@ "Hello World"];        }    }    return  0;  }

Use an image metaphor to illustrate this entire agent event:

A café business is very good, the Boss (Personone) decided to recruit a barista to help. So I posted an announcement (delegate)

Announcement content: (protocol)

Recruit a barista, have more than one year experience. The bartender is a priority.

From this announcement, you can know two points:

1-can make coffee, and have more than one year experience is a must condition (@required: The method must be implemented )

2-can be adjusted wine is optional, non-mandatory conditions (@optional: Optional implementation of the method (can be all not implemented ))

Therefore, all the candidates must meet the first condition, the second condition is only added to the sub-item, not an indispensable one.

After recruiting staff B, the boss asked B to make a cup of mocha. As for b How to do, the boss will not care, he only cares about the results.

([Pa.delegate dosomething:@ "Hello World"];)-->[ boss. Delegate make coffee: @ " Mocha"];)

4: iOS development knowledge with Cordova

iOS Development using Cordova (Environment configuration and basic usage): HTTP://WWW.JIANSHU.COM/P/D24219C008B6

iOS development with Cordova (use of third-party plugins: Camera plugin): HTTP://WWW.JIANSHU.COM/P/1E3D0C915DBC

iOS Development with Cordova (add Cordova and custom plugins to saved items): Http://www.jianshu.com/p/e982b9a85ae8

Cordova Plug-In Development primer (iOS OC with JS interaction): http://my.oschina.net/crazymus/blog/516388

Brief analysis of Cordova for IOS (the description of OC and JS interaction): http://www.cocoachina.com/industry/20130520/6238.html

Note: In the newer version, if the generated project does not change, the path as long as the input plug-in instructions, will be the OC code and XML configuration has been updated, the second article above a lot of steps can be omitted;

Locating plugins:

Enter the directory after the terminal command input (introducing the locator plugin):

Cordova Plugin Add cordova-plugin-geolocation

To modify the index.html code:

<! DOCTYPE html>

iOS Development Basics-Fragmentation 42

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.