iOS Development--full project in combat OC & the third day of Miss.

Source: Internet
Author: User

The third day of my sister Morning Error: Keyboard handlingset the cell's split linemethod One:Add a view and topMethod Two:Modify the corresponding frame interception system frame settings, modify the corresponding values according to the requirements no matter what others pass in the original value is unchanged, using our default value optimizationcontroller hangs out cancelAFN Internal ImplementationDirect Termination RequestPause RequestCancellation Request SummaryAFN return Code Debug cannot be all lowercaseThe two were different, and the following band of Iboutlet's interior would be a hermit's strong reference to himSo the way to call is to print the back, that is, after the first line and not destroyed, and so on after the completion of the destruction Afternoon a simple way to set up a circular picture(but this will affect performance, half of us use drawing)Summary of Global constantsCan not be changed in the future (constant)-"macro: temporary data, memory space will also want to modify-" global variables

Global Constants Final Scenario:

    1. static NSString *const name = @ "Icocos"
    2. Const: Can not change, only a piece of memory (constant)
    3. Static: Can only be used here (this class), global variables
    4. extern: Reference a global variable (extern int name: reference a global variable name, the system will be based on his full file), if you do not let outside access, use the static decoration
Const (only the whole following: constants---cannot be changed)
    • Before the * (int const *p): P can change *p cannot be changed
    • After the * (int * const P): p cannot change *p can change
    • Both front and back (int const * Const p): P *p cannot be changed
can use const with const, we should use it to replace the macro, because only a piece of memory (can put some fixed value, cannot put a method or function) The const compile phase to determine the type or value, if we can not determine the corresponding value and type of the need to use the macro local variables scope is unchanged, Life cycle Change global variable scope change, life cycle invariant final optimization scenario: A new class defines a constant in the M implementation file (which defines the value of the constant) so that it can be referred to in the header file (or in the PCH file, but not recommended) (reference constant), or not using extern directly using Uikit _extern Comprehensive:This document is directly contained in this document
    • static NSString *const name = @ "Icocos"
All Files
    1. Create a new const class
    2. Implementation file: NSString *const name = @ "Icocos"
    3. Header file: Uikit_extern nsstring *const name;
    4. Include header files in the PCH
It can be used anywhere at the end, and performance is very good common errors: see if you define two constants, variables, attribute names, or classes, modify or delete one to Night __block and __weak summary__block1. __blockobjects can be modified and re-assigned in the block. 2. __blockObjects are not strongly referenced by block in block, so there is no circular reference problem. Save Manager
    • __unsafe_unretained typeof (self) weakself = self; MRC equates to __weak uiviewcontroller *weakself =self;
    • __weak typeof (self) weakself = self; ARC
 __weakUsed a __weakModifier that is equivalent to the property defined as weak. Nature does not cause circular reference problems, because the Apple documentation has made it clear that when the original object does not have any strong references, the weak reference pointer is also set to nil.
    • __block nsstring *key = nil;
Summarize
    • Therefore, the difference between the__block and __weak modifiers is actually quite obvious:
    • 1.__block can be used in either ARC or MRC mode, can be decorated with objects, and can be decorated with basic data types.
    • 2.__weak can only be used in Arc mode, can only be decorated with objects (nsstring), and cannot be decorated with basic data types (int).
    • 3. The__block object can be re-assigned in the block,__weak not.
    • The ps:__unsafe_unretained modifier can be considered an alternative to iOS SDK version __weak , but will not be automatically empty to nil. So do not use this modifier as much as possible.
Request Failure SummaryFailure in Success
    • The domain name is in, but the following path has errors,
    • Parameter error
Failure in Failsure
    • 1: Network error
    • 2: System error
1     /**2 * Realistic Cue box3      */4 //[Svprogresshud show];5    6     //Request URL7NSString *requesturl =@"http://api.budejie.com/api/api_open.php";8    9     //Request ParametersTenNsmutabledictionary *dict =[Nsmutabledictionary dictionary]; Onedict[@"a"] =@"Tag_recommend"; Adict[@"Action"] =@"Sub"; -dict[@"C"] =@"Topic"; -     the //__unsafe_unretained typeof (self) weakself = self; //MRC equates to __weak uiviewcontroller *weakself =self; - //__weak typeof (self) weakself = self;//ARC -     -     /** + * Send a GET request -      */ +__weaktypeof(self) weakself =Self ; A[Self.manger get:requesturl parameters:dict success:^void(Nsurlsessiondatatask *data,IDResponer) { at         /** - * If the returned data is empty -          */ -         if(Responer = =Nil) { -[Svprogresshud Showerrorwithstatus:@"failed to load data"]; -             return; in         } -         //data that parses the dictionary data is saved to the model . toWeakself.tags =[Icocostagmodel Objectarraywithkeyvaluesarray:responer]; +         -Icocoslog (@"iOS-----Success"); theIcocoslog (@"%@", self.tags); *         $         //Refresh TablePanax Notoginseng [Weakself.tableview Reloaddata]; -         the         //Hide Cue box + [Svprogresshud dismiss]; A         the} failure:^void(Nsurlsessiondatatask *data, Nserror *error) { +         -         /** $ * Status code after request failed $          */ -         -         if(Error.code = = nsurlerrorcancelled)return; the         -         if(Error.code = =nsurlerrortimedout) {Wuyi[Svprogresshud Showerrorwithstatus:@"load timed out, please try again later! "]; the}Else { -[Svprogresshud Showerrorwithstatus:@"failed to load data"]; Wu         } -Icocoslog (@"iOS-----false"); About     }]; $  

iOS Development--full project in combat OC & the third day of Miss.

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.