IOS study Note 2

Source: Internet
Author: User
Tags gmt time zone julian day

1. nsuserdefaults

I personally think the IOS method is a bit similarProperties. settings. Default in C #, Nsuserdefaults only supports: nsstring, nsnumber, nsdate, nsarray, nsdictionary.

There are multiple methods for creating a user ults, which is the simplest and fastest way to create a user defaults:

Nsuserdefaults * accountdefaults = [nsuserdefaults standarduserdefaults];
Add data to user defaults:
[Accountdefaults setobject: namefield. Text forkey: userdefaultnamekey];
You can also add basic data types such as int, float, and bool.
[Accountdefaults setbool: Yes forkey: userdefaboboolkey];
Get data from user defaults:
[Accountdefaults objectforkey: ncuserdefaultnamekey]
[Accountdefaults boolforkey: userdefaultboolkey];
You can rewrite the object or data corresponding to the same keyword. After rewriting, the keyword corresponds to a new object or data, and the old object or data is automatically cleared.

2. nsdateformatter
Format the date string and copy a common parameter:

A: AM/PM (morning/afternoon)

A: 0 ~ 86399999 (the second microsecond Of a day)

C/CC: 1 ~ 7 (the first day of the week, the day of the week is 1)

CCC: Sun/MON/Tue/wed/Thu/fri/SAT (abbreviated as the day of the week)

CCCC: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday)

D: 1 ~ 31 (the day of the month, with 0)

D: 1 ~ 366 (the day of the year, with 0)

E: 1 ~ 7 (the day of the week, with 0)

E ~ EEE: Sun/MON/Tue/wed/Thu/fri/SAT (abbreviated as the day of the week)

Eeee: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday)

F: 1 ~ 5 (the week of the month, and the first day of the week is Monday)

G: Julian day number (number of days since 4713 BC January 1) unknown

G ~ Ggg: BC/AD (ERA designator abbreviated) unknown

GGGG: Before Christ/Anno Domini unknown

H: 1 ~ 12 (0 padded hour (12hr) in 12-hour format with 0

H: 0 ~ 23 (0 padded hour (24hr) in 24-hour format with 0

K: 1 ~ 24 (0 padded hour (24hr) with 0, in 24-hour format

K: 0 ~ 11 (0 padded hour (12hr) in 12-hour format with 0

L/LL: 1 ~ 12 (0 padded month) months

Lll: Jan/FEB/MAR/APR/May/Jun/JUL/Aug/SEP/OCT/NOV/DEC month abbreviation

Llll: January/February/March/Jun L/May/June/July/August/September/October/November/December full name

M: 0 ~ 59 (0 padded minute) minutes

M/MM: 1 ~ 12 (0 padded month) months

Mmm: Jan/FEB/MAR/APR/May/Jun/JUL/Aug/SEP/OCT/NOV/Dec

Mmmm: January/February/March/April/May/June/July/August/September/October/November/December

Q/QQ: 1 ~ 4 (0 padded quarter) quarter

Qqq: Short for Q1/Q2/Q3/Q4 quarter

Qqqq: 1st quarter/2nd quarter/3rd Quarter/4th quarter

Q/QQ: 1 ~ 4 (0 padded quarter) in the same lower case

Qqq: q1/Q2/Q3/Q4 in the same lower case

Qqqq: 1st quarter/2nd quarter/3rd Quarter/4th quarter in the same lower case

S: 0 ~ 59 (0 padded second) seconds

S: (rounded sub-second) unknown

U: (0 padded year) unknown

V ~ Vvv: (General GMT timezone abbreviation) Compiling of the normal GMT Time Zone

Vvvv: (General GMT timezone name) Name of the general GMT Time Zone

W: 1 ~ 53 (0 padded week of year, 1st day of week = Sunday, NB: 1st week of year starts from the last Sunday of last year) week of the year, the week starts with Sunday, and the first week starts from the last Sunday of last year.

W: 1 ~ 5 (0 padded week of month, 1st day of week = Sunday) week of a month

Y/yyyy: (full year) complete year

YY/yyy: (2 digits year) year of 2 digits

Y/yyyy: (full year, starting from the Sunday of the 1st week of year)

YY/yyy: (2 digits year, starting from the Sunday of the 1st week of year)

Z ~ Zzz: (Specific GMT timezone abbreviation) specifies the GMT time zone.

Zzzz: (Specific GMT timezone name) Z: + 0000 (RFC 822 timezone) specifies the GMT Time Zone name

 

Instance:
Nsdateformatter * formatter = [[nsdateformatter alloc] init];
[Formatter setamsymbol: @ "am"];
[Formatter setpmsymbol: @ "PM"];
[Formatter setdateformat: @ "mm/DD/YYYY hh: mm: A"];
// [Nsstring stringwithformat: @ "last updated: % @", [formatter stringfromdate: [nsdate date];

 

3. backgroundview

Uiview * backgroundview = [[testcellview alloc] initwithframe: cgrectzero];

Backgroundview. opaque = yes;
Backgroundview. backgroundcolor = [uicolor colorwithpatternimage: [uiimage imagenamed: @ "list-gap.png"];
Backgroundview = backgroundview;
[Backgroundview release];

 

4. nsparameterassert

It is a breakpoint with parameters. It is executed when the condition is false and is mainly used for program debugging.

Nsparameterassert (1 = 2 );

 

5. reachability

A probe similar to a network condition.

[[Nsicationicationcenter defacenter center] addobserver: Self selector: @ selector (reachabilitychanged :) name: kreachabilitychangednotification object: Nil];

Hostreach = [[reachability reachabilitywithhostname: @ "hubj.cnblogs.com"] retain];
[Hostreach startnotifier];

Wifireach = [[reachability reachabilityforlocalwifi] retain];
[Wifireach startnotifier];

 

-(Void) reachabilitychanged: (nsnotification *) Note {
Reachability * curreach = [Note object];
Nsparameterassert ([curreach iskindofclass: [reachability class]);

Networkstatus netstatus = [curreach currentreachabilitystatus];

Switch (netstatus)
{
Case notreachable:
{
Nslog (@ "access not available ");
Break;
}

Case reachableviawwan:
{
Nslog (@ "reachable wwan ");
Break;
}
Case reachableviawifi:
{
Nslog (@ "reachable WiFi ");
Break;
}
}

}

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.