Conversion between nsimage and nsdata
Nsdata * imagedata = [nsdata
Datawithcontentsoffile: ImagePath];
Uiimage * aimage = [uiimage
Imagewithdata: imagedata];
// Uiimage-> nsdata
Nsdata * imagedata = uiimagepngrepresentation (aimae );
Random Number
Srandom (Time (null ));
Generate 5 ------ 20
Between a random number
Int n =
5 + (INT) (20.0 * (random ()/(rand_max +
1.0 )));
SrandAndRandIt is not officially recommended. The reason is that the random number generation performance is not very good,
The random number is random.RandomGood,
In addition, it is not thread security.
Nslog (@ "% @", nsstringfromselector (_ cmd ));
Go to the program directory under simulator debugging
/Private/var/root/library/Application Support/iPhone simulator/5.1/Applications
Read serialized files
Nsstring * resourcepath = [nsbundle
Mainbundle] resourcepath];
Nsstring * Path = [nsstring
Alloc] initwithformat: @ "% @/president. plist", resourcepath];
Nsdata * Data = [nsdata
Alloc] initwithcontentsoffile: path];
President * thepres = [nskeyedunarchiver
Unarchiveobjectwithdata: Data];
Save serialized files
Nsstring * resourcepath = [nsbundle
Mainbundle] resourcepath];
Nsstring * Path = [nsstring
Alloc] initwithformat: @ "% @/president. plist", resourcepath];
Nsdata * Data = [nskeyedarchiver
Archiveddatawithrootobject: Self. President];
If ([Data
Writetofile: path atomically: No])
{
Uialertview * Alert = [uialertview
Alloc] initwithtitle: @ "system"
Message: @ "saved successfully! "Delegate: Nil
Cancelbuttontitle: @ "OK"
Otherbuttontitles: nil,
Nil];
[Alert
Show];
[Alert
Release];
}
Access master delegate
Appdelegate * delegate = [[uiapplication
Sharedapplication] Delegate];
Access the main program
Uiapplication * APP = [uiapplication
Sharedapplication];
2) Add a custom post-generated script
Add a phase in build phases, add in the lower right corner
Build phase, click Add run script, and enter the following script
Export codesign_allocate =/developer/platforms/iphoneos. Platform/developer/usr/bin/codesign_allocate
If ["$ {platform_name}" = "iphoneos"]; then
/Developer/iphoneentitlements401/gen_entitlements.py "My. Company. $ {project_name}" $ {built_products_dir}/$ {wrapper_name}/$ {project_name}. xcent ";
Codesign-F-s "iPhone developer" -- entitlements "$ {built_products_dir}/$ {wrapper_name}/$ {project_name }. xcent "" $ {built_products_dir}/$ {wrapper_name }/"
Fi