for(int i=0;i<[promotionArr count];i++)
{
// NSLog(@"ok");
Promotion *prom = [[Promotion alloc]init];
prom.pName=[[promotionArr objectAtIndex:i] objectForKey:@"name"];
prom.pUrl=[[promotionArr objectAtIndex:i] objectForKey:@"url"];
prom.pDescription=[[promotionArr objectAtIndex:i] objectForKey:@"description"];
[promMUAraay addObject:prom];
NSLog(@"number of elements : %d",[promMUAraay count]);
}
但是元素的個數始終爲0。我沒有做對的NSMutableArray @synthetise時,Xcode告訴我,我不能.I只是做這在我的.hSyntheticise an NSMutableArray
NSMutableArray *promMUAraay;
這是什麼問題?
+1當你合成一個屬性時,它並不意味着該屬性將被初始化。 – Max 2011-05-22 21:02:33
基本上它是一個'nil'對象,'count'將返回'0'。 – 2011-05-22 21:03:31
@Deepak根據上下文,發送到'nil'的消息總是會返回0,0.0,0.0f,0,0x00,NO或nil。 – 2011-05-22 21:15:32