以下是尝试加载图像的代码:
- (UIImage*) CPPlistImageToUIImage: (NSString *) CPPlistImage {
/*TODO: Is this a memory leak? Find out*/
UIImage * ret = [UIImage imageNamed: CPPlistImage];
if(ret == nil){
RDLogString(@"Warning: Failed to load image: \"%@\"", CPPlistImage);
}
return ret;
}
- (void) lsOwnDirectory {
NSError * error = [[NSError alloc] init];
NSArray * files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: pathToOwnDirectory error: &error];
for(NSString * file in files){
RDLogString(@"%@", file);
}
}
下面是两个函数在同一次运行中的输出示例:
// CPPlist...Image telling he can't find/load the image
2009-11-29 02:12:51.510 CPPlayer[6452:207] CPConversation.m:113 Warning: Failed to load image: "/Users/nick/Library/Application Support/iPhone Simulator/User/Applications/D3403591-3A56-4F05-B4C1-C21DAAF918A2/CPPlayer.app/CP.Resources/CP.Conversations/Supermarkt/OIGNONS.png"
...
// lsOwnDirectory is called AFTER CPPList...Image
2009-11-29 02:12:51.557 CPPlayer[6452:207] RootViewController.m:81 Contents of /Users/nick/Library/Application Support/iPhone Simulator/User/Applications/D3403591-3A56-4F05-B4C1-C21DAAF918A2/CPPlayer.app/CP.Resources/CP.Conversations/Supermarkt
2009-11-29 02:12:51.566 CPPlayer[6452:207] CPConversation.m:133 audio
2009-11-29 02:12:51.567 CPPlayer[6452:207] CPConversation.m:133 CPConversation.plist
2009-11-29 02:12:51.568 CPPlayer[6452:207] CPConversation.m:133 CPData.sqlite
2009-11-29 02:12:51.569 CPPlayer[6452:207] CPConversation.m:133 images
2009-11-29 02:12:51.570 CPPlayer[6452:207] CPConversation.m:133 OIGNONS.png
非常感谢您的帮助,
刻痕