Since the well-known 31-day case tutorial abroad is older, the official API is 2.X in 2008, so there are more or less compile warnings and error messages after the current xcode3-4. You must do some code changes to fit the iOS version to successfully compile the pass.
Day1:minutes to Midnight
nsdate* now = [NSDate Date];
-[Now Datewithcalendarformat:nil Timezone:nil] hourofday];
-[Now Datewithcalendarformat:nil Timezone:nil] minuteofhour];
-[Now Datewithcalendarformat:nil Timezone:nil] secondofminute];
Here Datewithcalendarformat: After the official API 2.2.1, there will be a warning error. In xcode3.x and later versions, the following modifications are required to compile the pass:
Nscalendar *calendar = [[Nscalendar alloc] Initwithcalendaridentifier: Nsgregoriancalendar]; Nsinteger unitflags = Nsyearcalendarunit | Nsmonthcalendarunit | Nsdaycalendarunit | Nshourcalendarunit | Nsminutecalendarunit | Nssecondcalendarunit; NSDate *date = [NSDate Date]; Nsdatecomponents *comps = [calendar components:unitflags fromdate:date]; int hour = 23 - [comps hour]; int min = 59 - [comps minute]; int sec = 59 -[comps second];
Day3:openurl
Statement: NSLog (Urltext); Generate warning Error: format string is not a string literal (potentially insecure)
Modified to: NSLog (@ "%@", Urltext);
Of course this sentence does not change, nsstring *urltext = [NSString stringwithformat:@ "http://maps.google.com.hk/maps?q=%@", AddressText];
Day4:what is My IP
For Get iphone native IP address, on iphone ios2. X can be obtained using the method call in the sample code:
Nshost *myhost = [Nshost currenthost];
NSString *ad = [myhost address];
However, after iOS 3.0, these methods become the Apple private API, at compile time will not find the error of this method declaration, the use of the private API submitted by the app will be reject. For this reason, it is recommended to use a custom IP address class file on the network. Relevant files are: IPAddress.h (http://iphonesdksnippets.com/post/2009/09/07/Get-IP-address-of-iPhone.aspx)
Reprint: http://www.cnblogs.com/lovecode/archive/2011/12/11/2283914.html
Some questions about the SDK version in the 31-day App Tutorial sample (GO)