Objective C 中的内存管理问题
我正在开发一个简单的 UITableView 应用程序,我需要在单元格中显示图像。我遇到内存管理问题,但无法解决。
我遇到的问题是:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
SoftwareBugsDetails *bug1 = [[[SoftwareBugsDetails alloc]initWithTitle:@"BohrBug" rating:4 thumbImage:[UIImage imageNamed:@"images.jpeg"]]autorelease];
NSMutableArray *bugs = [NSMutableArray arrayWithObjects:bug1, nil];
RootViewController *rootController = (RootViewController*)[_navigationController.viewControllers objectAtIndex:0];
rootController.bugs = bugs;
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
错误消息是: Thread1 程序收到信号:SIGABRT
由于我使用 Xcode 4,我创建了一个新组作为 Resources
并将我的图像放入其中。
任何帮助表示赞赏
I am developing a simple UITableView
application whereby I need to display images in the cell. I am getting a memory management issue but is unable to resolve it.
I am getting the issue in:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
SoftwareBugsDetails *bug1 = [[[SoftwareBugsDetails alloc]initWithTitle:@"BohrBug" rating:4 thumbImage:[UIImage imageNamed:@"images.jpeg"]]autorelease];
NSMutableArray *bugs = [NSMutableArray arrayWithObjects:bug1, nil];
RootViewController *rootController = (RootViewController*)[_navigationController.viewControllers objectAtIndex:0];
rootController.bugs = bugs;
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
The error message is: Thread1 Program received signal:SIGABRT
As I am using Xcode 4, I have created a new group as Resources
and placed my image in it.
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 xCode 4,则必须检查新的 ARC 框架,它已添加到 Xcode 4.2 和 iOS 5 中,但它对以前的 iOS 具有向后支持。
它将让您摆脱释放/自动释放问题,因此您需要再次担心内存管理(几乎)。
您可以在这里找到更多数据:
TransitioningToARC
或者在此处观看有关 ARC 的 WWDC 电影:
WWDC
If you are using xCode 4 you must check the new ARC framework, It was added in Xcode 4.2 and iOS 5 but it has backwards support for previous iOS.
It will free your mind from releasing/autoreleasing issues so you want have to worry again for memory management (almost).
you can find more data here:
TransitioningToARC
Or watch the WWDC movie about ARC here:
WWDC