我試圖編輯rawURL
,以便它在我的應用程序包中正確的文件夾中查找。我看着Apple's documentation,但是當我打開了我的應用程序的.xcdatamodeld
,其字符串值,我希望編輯的屬性,似乎沒有設置任何東西:定義實體的屬性值
我看着在整個代碼庫,並且我無法以編程方式找到它。但是,我在我想要更改的代碼中添加一條打印語句,並且它實際上打印了一個字符串。我想要更改此字符串的值,以便它在FindSpecies/[species name]/[img file]
中看起來不是FindSpecies/species/[species name]/images/[img file]
。
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString* cachePath = [paths objectAtIndex:0];
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
NSLog(@"self.rawurl: %@", self.rawURL);
NSString* stringURL = [self.rawURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"stringURL: %@", stringURL);
NSURL* url = [NSURL URLWithString:stringURL];
NSString* path = [url path];
NSString* query = [url query];
//...
returnString = [NSString stringWithFormat:@"%@/%@%@", resourcePath, kThumbnailDirectoryName, path];
我可以編輯rawURL
如果我甚至不知道在第一個地方/怎麼它的設定?
編輯:這個程序是由我的教授的前畢業生在2011年建成的。我正在對其進行現代化改造。
你爲什麼要這樣做?爲什麼不使用'NSBundle pathForResource:ofType:'也可以改變資源的完整路徑。 –
@JonRose,我應該提到,對於我的教授,我正在修復他的前研究生在2011年建立的應用程序。 – Matt