數組在IOS開發中使用是非常廣泛的:
我在使用過程中,我們知道的是:數組中添加的元素是object對象 比如一個string 對象:@"" 但是有時候想要將一個座標放進數組裏面,比如說CGRectMake(0,0,0,0)。這個東西是不能直接放進去數組裏面的 ,拿怎麼才能把他放進去呢:我們一般使用這中方式:
itemPoint=[[NSArray alloc]initWithObjects:
[NSValue valueWithCGRect:CGRectMake(182/2, 714/2, 700/2, 246/2)],
[NSValue valueWithCGRect:CGRectMake(750/2, 378/2, 460/2, 246/2)],
[NSValue valueWithCGRect:CGRectMake(1158/2, 684/2, 784/2, 284/2)],
[NSValue valueWithCGRect:CGRectMake(784/2, 1032/2, 460/2, 284/2)], nil];
寫進去之後在取出來使用:
dashView.frame =[[mutableArray objectAtIndex:0] CGRectValue];