我有一個定義:#define stringFormat中的值?
hashdefine kPingServerToSeeIfInternetIsOn "http://10.0.0.8"
然後在代碼中我使用它:
NSString *theURL = [NSString stringWithFormat:@"%@", kPingServerToSeeIfInternetIsOn];
我得到一個異常。
定義應用程序的常量並在NSString
init中使用它的最佳方法是什麼?
順便說一句,你可以簡化這個特殊的代碼用類似「的NSString * theURL = kPingServerToSeeIfInternetIsOn;」甚至更簡單,但用kPingServerToSeeIfInternetIsOn替換對URL的任何引用。 – Tyler 2009-09-15 02:16:57