1. Apple recommended single-use method: If there is a user class, create a class method in the user class
+ (User *) shareinstance
{
static User *user = nil;
Static dispatch_once_t oncetoken;//Ensure that the following block code is called only once
Dispatch_once (&oncetoken, ^{
user = [[user alloc] init];
});
return user;
}
When creating a singleton in the program later: user* user = [user shareinstance];
2. When using Uitextfield to enter a password, it is best to use Textfield.securetextentry = YES to hide the display of the password.
Functions that automatically calculate the height of text after 3.ios7: [String Boundingrectwithsize:cgsizemake (Weigth, heigth) options: Nsstringdrawinguseslinefragmentorigin attributes:attrdict Context:nil];
String is the contents of the text, and the function return value is CGRect type
The first parameter: Set the width and height of the text, in fact, it is only necessary to pay attention to the width of the setting, the height of the value of the text as much as the content of the automatic adjustment, the general initial value set a larger value.
Second parameter: How the text is displayed (above is the way of wrapping)
The third parameter: A dictionary of text size and color properties, such as:
Nsdictionary *attrdict =
@{nsfontattributename:[uifont Systemfontofsize:20.0f],nsforegroundcolorattributename:[uicolor BlueColor]};
Fourth parameter: Context (Nil can be passed)
Knowledge Point (i)