NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:nil]; for (NSString *dir in dirContents) { if ([dir hasSuffix:@".list"]) { NSRange range = [dir rangeOfString:@"."]; NSString *name = [dir substringToIndex:range.location]; if (![name isEqualToString:@""]) { MyListItem *listItem = [[MyListItem alloc] init]; listItem.name = name; [lists addObject:listItem]; [listItem release]; } } }
Programming blogs containing .NET, C#, LINQ, Objective-C and Delphi experiences
Monday, April 04, 2011
Xcode snippet #1: Reading the contents of a directory
Below you will find a code snippet which reads the contents of a specific directory (in this case the documents directory) from your device. It looks for file with has a suffix .list, stripes the filename from it with the substringToIndex method and adds that name to another array.
Subscribe to:
Post Comments (Atom)
Use an image as your UIBarButtonItem
Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...
-
In ASP.NET it is easy to set the prefered authentication method in the web.config file. For external websites this is set mostly to Forms ...
-
Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...
-
How to get, for example, all the hyperlinks from a webpage, which is loaded in your iPhone app using the UIWebView control? (Xcode's web...
2 comments:
I know already what directory to apply your guidance to! As always, It proved out to be an extreme help!
I cannot thank Mr Benjamin service enough and letting people know how grateful I am for all the assistance that you and your team staff have provided and I look forward to recommending friends and family should they need financial advice or assistance @ 1,9% Rate for Business Loan .Via Contact : . lfdsloans@outlook.com. WhatsApp...+ 19893943740. Keep up the great work.
Thanks, Busarakham.
Post a Comment