iphone Programming Glossary: bundlepath
Getting a list of files in a directory with a glob http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob I'm currently stuck with something along the lines of NSString bundleRoot NSBundle mainBundle bundlePath NSArray dirContents NSFileManager defaultManager directoryContentsAtPath bundleRoot ..and then stripping.. this pretty easily with the help of NSPredicate like so NSString bundleRoot NSBundle mainBundle bundlePath NSFileManager fm NSFileManager defaultManager NSArray dirContents fm contentsOfDirectoryAtPath bundleRoot..
Using HTML and Local Images Within UIWebView http://stackoverflow.com/questions/747407/using-html-and-local-images-within-uiwebview you have to load the HTML into the view with the correct baseURL NSString path NSBundle mainBundle bundlePath NSURL baseURL NSURL fileURLWithPath path webView loadHTMLString htmlString baseURL baseURL You can then..
How to write data in plist? http://stackoverflow.com/questions/905542/how-to-write-data-in-plist plistPath nil NSFileManager manager NSFileManager defaultManager if plistPath NSBundle mainBundle bundlePath stringByAppendingPathComponent @ Contents Info.plist if manager isWritableFileAtPath plistPath NSMutableDictionary.. dictionaryWithObject NSDate date forKey NSFileModificationDate atPath NSBundle mainBundle bundlePath Update Nate Flink pointed out that some of the NSFileManager methods used above are deprecated. He..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud is valid and a matter of style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @.. style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind.. mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some example code to build your own optimised version. I can't see..
Getting a list of files in a directory with a glob http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob a way to get a list of files with a glob for a given directory. I'm currently stuck with something along the lines of NSString bundleRoot NSBundle mainBundle bundlePath NSArray dirContents NSFileManager defaultManager directoryContentsAtPath bundleRoot ..and then stripping out the stuff I don't want which sucks. But what I'd really.. cocoa touch share improve this question You can achieve this pretty easily with the help of NSPredicate like so NSString bundleRoot NSBundle mainBundle bundlePath NSFileManager fm NSFileManager defaultManager NSArray dirContents fm contentsOfDirectoryAtPath bundleRoot error nil NSPredicate fltr NSPredicate predicateWithFormat..
Using HTML and Local Images Within UIWebView http://stackoverflow.com/questions/747407/using-html-and-local-images-within-uiwebview to refer to images does not work with UIWebView. Instead you have to load the HTML into the view with the correct baseURL NSString path NSBundle mainBundle bundlePath NSURL baseURL NSURL fileURLWithPath path webView loadHTMLString htmlString baseURL baseURL You can then refer to your images like this img src myimage.png from..
How to write data in plist? http://stackoverflow.com/questions/905542/how-to-write-data-in-plist want to modify a bundled .plist here is some code NSString plistPath nil NSFileManager manager NSFileManager defaultManager if plistPath NSBundle mainBundle bundlePath stringByAppendingPathComponent @ Contents Info.plist if manager isWritableFileAtPath plistPath NSMutableDictionary infoDict NSMutableDictionary dictionaryWithContentsOfFile.. plistPath atomically NO manager changeFileAttributes NSDictionary dictionaryWithObject NSDate date forKey NSFileModificationDate atPath NSBundle mainBundle bundlePath Update Nate Flink pointed out that some of the NSFileManager methods used above are deprecated. He posted an answer with the replacement methods below http stackoverflow.com..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud remember that a semi colon at the end of a method definition is valid and a matter of style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some example.. at the end of a method definition is valid and a matter of style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some example code to build your own optimised.. NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some example code to build your own optimised version. I can't see it is worth the maintentace but here it is for completeness...
Add rounded corners to UIImageView http://stackoverflow.com/questions/2171506/add-rounded-corners-to-uiimageview as to how to do this Here is the code void viewDidLoad super viewDidLoad NSString mainpath NSBundle mainBundle bundlePath welcomeImageView.image UIImage imageWithContentsOfFile mainpath stringByAppendingString @ test.png welcomeImageView.layer.cornerRadius..
How do I include CSS resource in programmatically generated HTML for iPhone UIWebView? http://stackoverflow.com/questions/2357878/how-do-i-include-css-resource-in-programmatically-generated-html-for-iphone-uiwe
Problem dealloc'ing memory used by UIImageViews with fairly large image in an UIScrollView http://stackoverflow.com/questions/289360/problem-deallocing-memory-used-by-uiimageviews-with-fairly-large-image-in-an-ui to find the path. However you can get the path to the bundle with the following NSString fullpath NSBundle mainBundle bundlePath Putting that all together here's what that looks like in code NSString fullpath NSBundle mainBundle bundlePath stringByAppendingString.. bundlePath Putting that all together here's what that looks like in code NSString fullpath NSBundle mainBundle bundlePath stringByAppendingString NSString stringWithFormat @ @ d.png self.nibName imageView.tag UIImage loadImage UIImage imageWithContentsOfFile.. frame.size.height maxYLoc maxYLoc frame.origin.y maxYLoc frame.size.height NSString fullpath NSBundle mainBundle bundlePath stringByAppendingString NSString stringWithFormat @ @ d.png self.nibName imageView.tag NSLog fullpath UIImage loadImage..
Singleton shared data source in Objective-C http://stackoverflow.com/questions/355449/singleton-shared-data-source-in-objective-c SearchData @synthesize searchDict @synthesize searchArray id init if self super init NSString path NSBundle mainBundle bundlePath NSString finalPath path stringByAppendingPathComponent @ searches.plist searchDict NSDictionary dictionaryWithContentsOfFile..
UIWebView with just an image that should fit the whole view http://stackoverflow.com/questions/4667614/uiwebview-with-just-an-image-that-should-fit-the-whole-view webView UIWebView alloc initWithFrame CGRectMake 0 0 self.view.frame.size.width 80 NSString path NSBundle mainBundle bundlePath NSURL baseUrl NSURL fileURLWithPath path NSString html NSString stringWithFormat @ html head THE LINE ABOVE IS TO PREVENT..
Getting a list of files in a directory with a glob http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob for a given directory. I'm currently stuck with something along the lines of NSString bundleRoot NSBundle mainBundle bundlePath NSArray dirContents NSFileManager defaultManager directoryContentsAtPath bundleRoot ..and then stripping out the stuff.. You can achieve this pretty easily with the help of NSPredicate like so NSString bundleRoot NSBundle mainBundle bundlePath NSFileManager fm NSFileManager defaultManager NSArray dirContents fm contentsOfDirectoryAtPath bundleRoot error nil NSPredicate..
How can I write an iPhone app entirely in JavaScript without making it just a web app? http://stackoverflow.com/questions/64420/how-can-i-write-an-iphone-app-entirely-in-javascript-without-making-it-just-a-we htmlData NSData dataWithContentsOfFile filePath if htmlData NSBundle bundle NSBundle mainBundle NSString path bundle bundlePath NSString fullPath NSBundle pathForResource @ index ofType @ html inDirectory path webView loadRequest NSURLRequest requestWithURL..
Using HTML and Local Images Within UIWebView http://stackoverflow.com/questions/747407/using-html-and-local-images-within-uiwebview UIWebView. Instead you have to load the HTML into the view with the correct baseURL NSString path NSBundle mainBundle bundlePath NSURL baseURL NSURL fileURLWithPath path webView loadHTMLString htmlString baseURL baseURL You can then refer to your images..
How pass data in seque ios5 storyboard uitableview to detail view http://stackoverflow.com/questions/7937035/how-pass-data-in-seque-ios5-storyboard-uitableview-to-detail-view DetailViewController detailViewController segue destinationViewController NSString path NSBundle mainBundle bundlePath NSString finalPath path stringByAppendingPathComponent @ questList.plist NSArray tempArray finalPath valueForKey @ description..
Get fileSize of info.plist to prevent piracy http://stackoverflow.com/questions/903157/get-filesize-of-info-plist-to-prevent-piracy the answer to your question how you get the size of the Info.plist file NSBundle bundle NSBundle mainBundle NSString bundlePath bundle bundlePath NSFileManager fileManager NSFileManager defaultManager NSString path NSString stringWithFormat @ @ Info.plist.. question how you get the size of the Info.plist file NSBundle bundle NSBundle mainBundle NSString bundlePath bundle bundlePath NSFileManager fileManager NSFileManager defaultManager NSString path NSString stringWithFormat @ @ Info.plist bundlePath.. NSFileManager fileManager NSFileManager defaultManager NSString path NSString stringWithFormat @ @ Info.plist bundlePath NSDictionary fileAttributes fileManager attributesOfItemAtPath path error NULL if fileAttributes nil NSNumber fileSize..
How to write data in plist? http://stackoverflow.com/questions/905542/how-to-write-data-in-plist some code NSString plistPath nil NSFileManager manager NSFileManager defaultManager if plistPath NSBundle mainBundle bundlePath stringByAppendingPathComponent @ Contents Info.plist if manager isWritableFileAtPath plistPath NSMutableDictionary infoDict.. NSDictionary dictionaryWithObject NSDate date forKey NSFileModificationDate atPath NSBundle mainBundle bundlePath Update Nate Flink pointed out that some of the NSFileManager methods used above are deprecated. He posted an answer with..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud end of a method definition is valid and a matter of style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName.. and a matter of style. UIImage imageFromMainBundleFile NSString aFileName NSString bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some.. bundlePath NSBundle mainBundle bundlePath return UIImage imageWithContentsOfFile NSString stringWithFormat @ @ @ bundlePath aFileName Rincewind also included some example code to build your own optimised version. I can't see it is worth the maintentace..
|