AP102 2016/5/13

完成記事本的code


id objectAtIndex:(NSUInteger)

// NSString * message = @"gell";
// NSArray * studens=@[@"123",@"678"];

id message  = @"glee";
id students = @[@"glee",@"mary"];

沒辦法檢查型別
無法判斷

[message objectAtIndex:0];-->當機

不知道回傳什麼

NSArray<NSString*> * students =@[@"glee","mary"];
NSNumber * number = [students objectAtIndex:1];

-(IBAction)clearFields:(id)sender{
UIButton * button = (UIButton*)sender;
[button setBackgroundColo:[UIColor whiteColor]];


}


記憶體管理


pointer

UIImage * image = [UIImage imageNamed:@"fighter.jpg"];

指標只是一種遙控器 可以取用 但不是物件

OBJ-c 1.0
MRC手動

ARC自動

retain
release

以上會自動加

autoRealease

以上這些都不能再用

reference counting


ARC

allo +1
new +1 =>alloc init的縮寫
copy


ARC

weak 就不能再下alloc init 不可被+ / - 1
strong 可以

1.IBoutlet --> weak
2.互相持有 的時候 有一方必須用weak

有一個類別叫做班級
有一個類別叫做學生


@interface class父{
@property (nonatomic,strong) +1 student * s1

}//ARC 1  ViewController >>hold>> class >>ViewController 持有 消失 -->都歸0


@interface students子{
@property (nonatomic,weak) 持有父class *a1.

}//ARC 0  >>不會回去持有

互相持有

retain cycle -->  ARC 彼此釋放不掉

NSData

btyes

資料以16位元的方式表示

NSDate * downloadedData ; // 將下載的圖片資料存在此變數
UIImage * image = [UIImage imageWithData:downloadedData];
NSData * data =UIImageJPEFRepresentation(image, 1.0f);
用bytes在傳輸



不是主執行緒都是背景執行緒

如何取得背景執行緒
主執行緒更新UI用,都是主執行緒的工作

龐大的工作在背景執行緒執行


主執行緒-------
               更新畫面
背景執行緒-------
         下載圖片(下載完成) --> 切回主執行緒












Comments

Popular posts from this blog

MEGA 暫存檔案刪除

IOS GCD多執行緒

利用CMD指令強制刪除