2. What is the memory management mechanism?
Cocoa provides a mechanism to implement the logic model mentioned above. It is called "referring counting" or "retain counting ):
3. What are the meanings and usage of minus signs and plus signs in objc?
① Subtraction indicates the start of a function, method, or message (called and implemented on an instance of a class) (it can be considered as a private method)
② The plus sign indicates that other functions can directly call methods in this class, instead of creating instances of this class (commonly known as static methods)
4. project arrangement
Button:
Btnwinwin = [uibutton buttonwithtype: uicontrolstatenormal];
Btnwinwin. Frame = cgrectmake (768,679,256, 42 );
[Btnwinwin setbackgroundimage: [uiimage imagenamed: @ "btnwinwin.jpg"] forstate: uicontrolstatenormal];
[Btnwinwin addtarget: Self action: @ selector (winwin) forcontrolevents: uicontroleventtouchupinside];
[Self. View addsubview: btnwinwin];
PLAYER:
Nsstring * soundpath = [[nsbundle mainbundle] pathforresource: musictop oftype: @ "MP3"];
Nsurl * soundurl = [[nsurl alloc] initfileurlwithpath: soundpath];
Player = [[avaudioplayer alloc] initwithcontentsofurl: soundurl error: Nil];
[PLAYER setdelegate: Self];
[Player play];
Animation conversion between two controllers:
Mainframe = [[test_book1_2_classes_viewcontrolleralloc] init];
Havemainfram = true;
Catransition * transition = [catransitionanimation];
Transition. Duration = 1.0f;/* interval */
Transition. timingfunction = [camediatimingfunctionfunctionwithname: kcamediatimingfunctioneaseineaseout];/* speed of animation start and end */
Transition. type = @ "pagecurl ";
Transition. Subtype = kcatransitionfromtop;/* animation direction */
Transition. Delegate = self;
[Self. navigationcontroller. View. layeraddanimation: Transition forkey: Nil];
[Self. navigationcontrollerpushviewcontroller: mainframeanimated: Yes];
SDK related:
1, the merger of two. A static library, static library has points suitable for the simulator and the real machine, how to merge please see: My another article http://www.cnblogs.com/visen-0/archive/2011/08/02/2125067.html
2. Create a root permission application: http://www.cnblogs.com/visen-0/archive/2011/08/22/2149014.html
3. Get the list of installed: http://www.cnblogs.com/visen-0/archive/2011/08/22/2148847.html
4. download and install the self-made. IPA file.
5. To determine whether to jailbreak, go to [nsfilemanager defamanager manager] to find out if there is a corresponding cydia. app program.
Submit information to the server:
// Device information
Uidevice * Device = [uidevice currentdevice];
Nsstring * identifier = [[nsstringstringwithstring: [device uniqueidentifier] lowercasestring];
Nslog (@ "% @", identifier );
Nsstring * requeststring = [nsstringstringwithformat: @ "http://www.yrwang.net/post.aspx? Client = IOS & DeviceID =%@ & reportmessage =%@ ", identifier, opinion. Text];
Nsstring * requeststringutf8 = [requeststring stringbyaddingpercentescapesusingencoding: nsutf8stringencoding];
Nsurl * myurl = [[nsurl alloc] initwithstring: requeststringutf8];
Nsmutableurlrequest * myrequest = [nsmutableurlrequestrequestwithurl: myurl
Cachepolicy: nsurlrequestreloadignoringlocalandremotecachedata
Timeoutinterval: 30];
[Myurl release];
Connection _ = [[nsurlconnectionalloc] initwithrequest: myrequest delegate: Self];
Parse XML:
Nsxmlparser * xmlread = [[nsxmlparser alloc] initwithdata: Data]; // initialize the nsxmlparser object
[Data release];
[Xmlread setdelegate: Self];
[Xmlread parse];
Listener mode:
[[Nsnotificationcenterdefacenter] addobserver: Self
Selector: @ selector (getupdatedpoints :)
Name: 111
Object: Nil];
[[Nsnotifcencenterdefacenter] postnotificationname: 111 object: Nil];
Singleton mode:
Static adpublisherconnect * sharedinstance _ = nil;
+ (Adpublisherconnect *) sharedadpublisherconnect
{
If (! Sharedinstance _)
{
Sharedinstance _ = [[superalloc] init];
}
Returnsharedinstance _;
}
File Read and Write, create:
This is an example of creation:
// Create a file manager
Nsfilemanager * filemanager = [nsfilemanagerdefaultmanager];
// Obtain the path
// Obtain the path of the nsdocumentdirectory Parameter
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes );
Nsstring * documentsdirectory = [paths objectatindex: 0]; // The path required for the path.
// Change to the directory to be operated
[Filemanager changecurrentdirectorypath: [documentsdirectory stringbyexpandingtildeinpath];
// Create the file filename file name and the content of the contents file. If there is no content at the beginning, you can set it to nil, the attribute of the attributes file, initially Nil
// Obtain the file path
Nsstring * Path = [documentsdirectory stringbyappendingpathcomponent: Filename];
// Create a data buffer
Nsmutabledata * Writer = [[nsmutabledataalloc] init];
// Add the string to the buffer
[Writer appenddata: [contents datausingencoding: nsutf8stringencoding];
// Add other data to the buffer
// Write the buffered data to the file
[Writer writetofile: path atomically: Yes];
[Writer release];
To obtain a string: nsange
E = [tempstring rangeofstring: @ ","];
Key = [tempstring substringtoindex: E. Location];
E = [tempstring rangeofstring: @ "\ r \ n"];
Tempstring = [tempstring substringfromindex: E. Location + 1];
Recording:
Avaudiosession
Paging:
Uitable Paging
Find the file directory;
+ (Nsmutablearray *) findfile {
Nsfilemanager * filemanager = [[nsfilemanager defaultmanager] init];
Nsmutablearray * everytitle = [[nsmutablearray alloc] init];
Nsarray * filepaths = nssearchpathfordirectoriesindomains (nslibrarydirectory, nsuserdomainmask, yes );
Nsstring * filepath = [filepaths objectatindex: 0];
Nslog (@ "% @", filepath );
Nsdirectoryenumerator * direnum = [filemanager enumeratoratpath: filepath];
Nsstring * filename;
While (filename = [direnum nextobject]) {
[Everytitle addobject: Filename];
}
Return everytitle;
}
Form:
Uiactionsheet
Long press button:
Uilongpressgesturerecognizer
Scroll View:
Uiscrollview
Web page:
Uiwebview
Hide the navigation bar and apply full screen.