原创 算法三 猴子喫桃
+(int)arithmetic21:(int)n { if (n==10) { return 1; } else { return ([self arithmeti
原创 幾種手勢練習
- (void)viewDidLoad { [super viewDidLoad]; //1. UIImageView *i
原创 多個對象的保存與讀取
-(NSString *)personFileName { if(!_personFileName)_personFileName = @"person.dat"; return _personFileName; }
原创 iOS路徑的幾種操作
NSString *path = @"/Users/tarena/Documents/Core iOS"; //1. 加路徑內容,自動加上/ NSString *newPath = [path stringB
原创 NSNotificationCenter消息中心
發射方: - (void)publish { //單例(唯一)的通知中心 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
原创 socket 發送與接收
#import "TRViewController.h" @interface TRViewController () @property (weak, nonatomic) IBOutlet UITextField *hostTF;
原创 鍵盤擡起落下,輸入框相應擡起落下
-(void)myViewLayout { // 旋轉不能用frame 要用bounds, self.inputView.frame = CGRectMake(0, self.view.bounds.size.hei
原创 Core Animation CALayer動畫
-(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset { UIGraphicsBeginImageContext(image.size); CGC
原创 設置動畫,旋轉
CGRect frame = self.imageView.frame; // 創建臨時的圖片,保留原圖。一定要<span style="font-family: Menlo; font-size: 18px; color:
原创 JSON
http://baike.baidu.com/view/136475.htm?fr=aladdin
原创 UIView動畫
-(void)fadein { // CGRect endFrame = self.welcomeLabel.frame; CGRect startFrame = endFrame; startFrame.or
原创 自定義類型歸檔與反歸檔
#import "TRPerson.h" @implementation TRPerson // 遵循nscoding協議,實現以下兩個方法 - (void)encodeWithCoder:(NSCoder *)aCoder{
原创 CoreData1
- (IBAction)foutAction:(UIButton *)sender { switch (sender.tag) { // add case 0: {
原创 bundle是一個目錄,看圖片就知道了
bundle是一個目錄,其中包含了程序會使用到的資源. 這些資源包含了如圖像,聲音,編譯好的代碼,nib文件(用戶也會把bundle稱爲plug-in). 對應bundle,cocoa提供了類NSBundle.我們的程
原创 文件的copy與合併
- (IBAction)copyFile { //source file : source.txt ==> source copy.txt NSString *documentsPath = [NSHomeDirec