Objective C 中的内存管理问题

发布于 2024-12-12 04:24:16 字数 1011 浏览 0 评论 0原文

我正在开发一个简单的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2024-12-19 04:24:16

如果您使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文