顯示包含「NSArray」標籤的文章。顯示所有文章
顯示包含「NSArray」標籤的文章。顯示所有文章

2011年7月7日星期四

Adding nil object to NSDictionary

NSDictionary and NSArray do not allow adding nil object to them.
But [NSNull null] can solve this problem in case you really want to have a "Null Object"


if(anObject!=nil)
{
[self setObject:anObject forKey:aKey];
return YES;
}
else
{
[self setObject:[NSNull null] forKey:aKey];
return NO;
}


reference: https://gist.github.com/307568

2010年11月18日星期四

Strong Type NSArray?

Is there any way to make NSArray become strong typed? The answer is no. (except subclassing it)

From Stackoverflow

Some ppl say it is not necessary, provided having good practice and good testing coverage.
After that I start to think of: why should I need a complier? why should I need VS or Xcode or Eclipse?
Maybe it really takes some time for me to indulge in the embrace of Apple.