發表文章

目前顯示的是 7月, 2012的文章

好用的NSNumber

java任何變數要轉字串 只要呼叫toString就能完成 在objective c中 要先宣告一個NSString 物件 在用WithFormat傳入値 來完成字串的轉換 有時需要物件的變數 我都會使用NSNumber來做物件化 或是轉型的動作 NSNumber很強大 提供了幾乎所有型別的變數輸入 + (NSNumber *)numberWithChar:(char)value; + (NSNumber *)numberWithUnsignedChar:(unsigned char)value; + (NSNumber *)numberWithShort:(short)value; + (NSNumber *)numberWithUnsignedShort:(unsigned short)value; + (NSNumber *)numberWithInt:(int)value; + (NSNumber *)numberWithUnsignedInt:(unsigned int)value; + (NSNumber *)numberWithLong:(long)value; + (NSNumber *)numberWithUnsignedLong:(unsigned long)value; + (NSNumber *)numberWithLongLong:(long long)value; + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; + (NSNumber *)numberWithFloat:(float)value; + (NSNumber *)numberWithDouble:(double)value; + (NSNumber *)numberWithBool:(BOOL)value; + (NSNumber *)numberWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0); + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0); 也能夠輸出很多種的型別 - (char)charVal...

iPad/iPhone retina display image naming rule

iOS很聰明 ipad跟iphone的影像檔 只要按照官方的naming rule 他就會幫你自動挑選合適的影像 Example: For devices without retina: ImageName.png  - For iPhone/iPod ImageName~ipad.png  -- For iPad For devices with retina display: ImageName@2x.png  - For iPhone/iPod ImageName@2x~ipad.png  -- For iPad 程式只需要寫 [UIImage imageNamed:@"ImageName.png"]; icon Size的部份 57 px, iPhone  – Good ol』 classic. 114 px, Retina iPhone 72 px, iPad 144 px, Retina iPad 29 px, iPhone Settings/Spotlight, iPad Settings   – Used in these table views. Minor, but still important! 58 px, iPhone 4 Settings/Spotlight/Notifications   – That's right, you have to make both 57 and 58 px versions of your icon – d』oh! Good luck aligning this if there's a line running down the middle of the icon. 48 px, iPad Spotlight   – Yup, the iPad uses a different size for Spotlight and Settings. Apple's docs actually say the icon is 50 px, but then there's this not...