nsbundle

NSBundle mainBundle pathForResource (maybe not the same problem)

本秂侑毒 提交于 2019-12-06 00:43:51
问题 Problem : [NSBundle mainBundle] pathForResource returns null (0x0) I read a lot of posts on this topic, here is what I found: Make sure the file you are trying to get a path to, is in the project. To check, look in the project file list for the file, if it is not there, drag and drop it in. Check that the file your trying to load is being copied to the app. To do this, click on project under project files (blue bar with project name in it->Click on the target->Click on Build Phases->Click to

Frameworks vs. Bundles

為{幸葍}努か 提交于 2019-12-05 08:28:22
I want to be able to add plugins for an application I am developing and as it is a development tool I want other people to be able to write their own plugins. So my questions are what are the real differences between a framework and a loadable bundle? Which are more suited to being a plugin(accessing of headers, ect) ? And if I use loadable bundles how do I load them at runtime and access their functionality during development? The plugins should not have to rely on other plugins. Have you taken a look at NSBundle ? It has all the methods you'll need to load the executable code at runtime. You

NSInternalInconsistencyException Could not load nib ind bundle

試著忘記壹切 提交于 2019-12-05 06:06:44
I am developing an application for the iPad. The application has following details: Base SDK: 4.2 Deployment Target: 3.2 The application is a game application and it has got 10 rounds. In each round I am loading 6 controllers and after the completion of each round again the same cycle starts. The application works fine till 4 rounds but at the end of 4th round it crashes given following error: "NSInternalInconsistencyException Could not load nib ind bundle:" I have checked for everything solution like checking the nib file name, checking the nib file path. Nib file name and nib file path both

iOS - passing data to pushed viewcontroller

百般思念 提交于 2019-12-05 00:04:09
问题 When pushing a viewcontroller, how do I pass data long with it as well (such as "asdf":123)? Are you supposed to addObjects to a NSBundle? 回答1: MyViewController * myVC = [[MyViewController alloc] initWithNibName:nil bundle:nil]; myVC.someProperty = someValue; // Pass your data here [self.navigationController pushViewController:myVC animated:YES]; And in your MyViewController class : .h @interface MyViewController : UIViewController @property (nonatomic, strong) NSString * someProperty; @end

Load view from NIB file from several different UIViewControllers

ⅰ亾dé卋堺 提交于 2019-12-04 21:33:30
I have been loading view from Nib files successfully using the approach found on this site [[NSBundle mainBundle] loadNibNamed:@"YourNibName" owner:self options:nil]; The problem is that, because we have to set the File Owner, this nib file becomes "attached" to this view controller. This view is subclass of UITableViewCell and I wanted to load this nib file from several different vc's. Thanks for your help. I'll present two options: Create a class NibLoader with a single @property (nonatomic, retain) IBOutlet id mainObject; and a method called loadNibNamed:bundle: ). Then, do MyView * v = [

load local image into UIWebView

依然范特西╮ 提交于 2019-12-04 19:12:16
I want to take a screenshot and then send to webview a local path for it, so it will show it. I know that webview could take images from NSBundle but this screenshots are created dynamically - can I add something to it by code? I was trying it like this: UIGraphicsBeginImageContext( webView.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSString *file = @"myfile.png"; NSString *directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)

Swift - Get NSBundle for test target?

南楼画角 提交于 2019-12-04 15:42:55
问题 In Objective C whenever I had to access the test bundle I would call [NSBundle bundleForClass:[ClassInTestTarget class]]; bundleForClass is not available in Swift, so how do I access the test bundle? The reason I need this is that in order to write tests for a framework I'm working on I have to use an in memory core data stack. Initially all resources were included in both main target and test target, but then I moved all these test helpers to test target only, and now the code below is

How to use Core Data's ManagedObjectModel inside a framework?

两盒软妹~` 提交于 2019-12-04 15:15:58
问题 I'm trying to migrate a specific part of one of my apps into a framework so that I can use it in my app itself and in one of those fancy new iOS 8 widgets. This part is the one that handles all my data in Core Data. It's pretty straight forward to move everything over and to access it. I'm just having trouble accessing my momd file in there. When creating the NSManagedObjectModel I still try to load the momd as illustrated in Apple's code templates: NSURL *modelURL = [[NSBundle mainBundle]

Swift - read plist file to an array?

限于喜欢 提交于 2019-12-04 11:31:11
问题 I have created a mini translation from English words to Spanish words. I would like to use the englishArray.plist instead of my englishArray = ["the cat"] How can I create this? I have also used a localizable.strings to retrieve the value "the cat" for "el gato" but I would like to retrieve this from englishArray.plist I started off with this but not sure if I'm on the right path let path = NSBundle.mainBundle().pathForResource("englishArray", ofType: "plist") let plistEnglishArray = NSArray

Get resource URL from project specific path

假装没事ソ 提交于 2019-12-04 10:05:51
问题 I need to retrieve the URL of a resource contained in my Xcode project through a path that begins in the project's directory (aka mainBundle) So if my specified path if ./snd/archer/acknowledge1.wav, I need to create a URL from that. I know I can use NSURL(fileURLWithPath:) for system directories, but I don't know how to do this directly from the bundle. 回答1: You would use one of the bundle resourse URL methods [[NSBundle mainBundle] URLForResource:@"acknowledge1" withExtension:@"wav"