什么是[NSBundle mainBundle] URLForResource的替代方法:withExtension:在iOS 3 SDK中 [英] What is the alternative of [NSBundle mainBundle] URLForResource:withExtension: in iOS 3 SDK

查看:406
本文介绍了什么是[NSBundle mainBundle] URLForResource的替代方法:withExtension:在iOS 3 SDK中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用iOS 4.2 SDK的iOS应用程序,但我希望该应用程序能够在我的iPhone 2G和iOS 3.1.3之类的旧设备上运行。我不知道这段代码的替代方案是什么:

I am developing an iOS app using iOS 4.2 SDK, but I want the app to run on older devices like my iPhone 2G with iOS 3.1.3. I don't know what is the alternative for this code:

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"CoreDataApp" withExtension:@"momd"];

它在我的设备上崩溃,因为URLForResource:withExtension:方法是iOS 4 +。

It crashes on my device, because the URLForResource:withExtension: method is iOS 4+.

请帮忙。谢谢。

推荐答案

它 -

NSURL *aFileURL = [NSURL fileURLWithPath: [[NSBundle mainBundle]  pathForResource:path ofType:@"aif"]];

这篇关于什么是[NSBundle mainBundle] URLForResource的替代方法:withExtension:在iOS 3 SDK中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆