2013-08-20 40 views
-1

尝试使用像(/Users/sai/Desktop/images/aaa.jpg)这样的路径从MAC桌面上存在的文件夹中加载图像,该图像在名为Data的plist文件中创建项目0处的.plist。 作为使用一个NSBundle它diaplying图像路径而不是从。我已经做了很多的研究还是没能找到解决.Plz帮我。这里是代码使用NSBundle和plist从文件夹中加载图像

NSString *path=[[NSBundle mainBundle]pathForResource:@"Data" ofType:@"plist"]; 
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:path]; 
NSString *errorDesc = nil; 
NSPropertyListFormat format; 
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc]; 
NSArray *array=[NSArray arrayWithArray:[temp objectForKey:@"images"]]; 
NSString *object=[array objectAtIndex:0]; 
NSLog(@"object at index i %@",[object lastPathComponent]); 
NSString *image=[object lastPathComponent]; 
mImageView.image=[UIImage imageNamed:image]; 
[self.view addSubview:mImageView]; 

桌面加载图像IM这里是Data.plist

的屏幕截图

Here is the screen shot of Data.plist

回答

1

简单,简短的回答:这是不可能从MAC台式机获得的图像,所以请它更好地停止与它战斗:)

它是d ifferent for mobile(iPhone应用程序)和桌面(mac应用程序),但为什么你想这样做?你知道你的iOS应用程序安装在苹果iPhone?如果你的应用程序与iOS相关?那么你如何将它连接到MAC OS?

最好和简单的方法是把这个图像放在应用程序包或您的应用程序的文档目录中并得到它。

+0

现在即时通讯工作在模拟器即时通讯试图从系统中获取图像。我有一个疑问,是否有可能与您的答案是清除它不是。 – lreddy

+0

你可以从任何包或文档目录:) – iPatel

+0

实际上我试图从其他文件夹中选择使用该图像路径的iphone设备中的特定图像。你会为此提出答案吗? – lreddy