IOS network programming-Day5 (enable Apache with MVC)
1. Use xml to retrieve data 1. Write the root node of the tree structure of the xml file (1). <? Xml version = "1.0" encoding = "UTF-8"?> (2 ). set root node (3 ). set the subnode. Copy the subnode directly with the same name (4 ). set the sub-node label and copy (5 ). type the TAG content. 2. use the terminal (Note: In the unixsystem, The a.txt is not equal to a.txt .) (1) Open the terminal: control + space-> ter-> enter (enter the user root directory by default) (2) cmd ++ zoom in cmd +-zoom out (3 ls: view directory documentation ls-a: view all document directories ~: User root directory/: system root directory cd: Enter directory cd, enter the prefix and press the tab key to automatically complete (two tabs will prompt the same file name) cd ..: Enter the upper-level directory pwd: display the absolute path of the current path clear: clear screen 3. enable Apache (1) sudo apachectl startsudo: get the highest permission apachectl: Apache ctl: control abbreviation start: Enable (2) enter the password, do not show anything (3) open your browser and type http: // 127.0.0.1/-> show It works! -> Indicates that Apache (4) has been enabled. Go to computer> Macintosh HD> resource library> WebServer> Documents (5) copy the xml file to Documents> enter the password> open the webpage> copy the browser address (7) at http: // 127.0.0.1) use NSURL encapsulation address (8) GET request (9) Use NSURLConnection to obtain data asynchronously II. Use MVC1. build a framework (1) showInFinder-> Create a folder (Models, Views, Controller, Third, handle)-> add to Files-> select the five created folders-> Groups-> project check-> add (2) copy a Third-party folder-> paste it to the Third folder-> add to Files-select a Third-party folder-> add-> cmd + B compile (3) select project name-> showInFinder-> Create a folder in the same directory as the project file-> name must be Frameworks-> add to Files-select the Frameworks folder-> add (4) add framework support, automatically go to the Frameworks folder 2. create class (1) Controller folder create root Controller that inherits UITableViewController-> cmd + opt + n create group (QQ, phone, Music) music: Create QQ Music Controller phone that inherits UITableViewController: create a mobile phone controller that inherits UIViewController without xib. Use VC to separate QQ: Create a QQ controller that inherits UIViewController, and add the xib (2) Handle folder to create a class that inherits NSObject, used to obtain network data (3) create a class that inherits NSObject from the Models folder, used to create Attribute 3. currently, I have studied Singleton Class 1. [NSNotificationCenter defacenter center] 2. [NSFileManager defaultManager] 3. [UIApplication sharedApplication] 4. [UIDevice currentDivece] 5. [NSURLSession sharedSession] 6. custom Handle Singleton class (1) in. h write a class method and use the shared name .. (2) In. m defines a static Global Object and is left empty (3) in. m implements the class method. Use the dispatch_once sinppet-GCD: Dispatch Once method. In the function body, use the class name to initialize the static Global Object. 4. the global macro name is 0. supporting Files-> cmd + n-> other-> PCH file-> select a project-> Build Settings-> cmd + F-> prefix-> type $ (SRCROOT) /Day5 life service MVC/project. pch1.showInFinder-> new folder-> MyFile-> add to Files-> select the created MyFile folder-> add2.cmd + n-> source-> header file-> macro-defined three notification centers symbol-> In pch # import. h file