nsmutablearray

iPhone SDK Xcode - How to get all the filenames in the documents dir

£可爱£侵袭症+ 提交于 2019-12-04 11:28:58
问题 I want to get all the filenames in my application's documents folder, and place them in an NSMutableArray . Nothing more, nothing less. 回答1: There is a convenient method in NSFileManager : NSFileManager *fileManager = [[NSFileManager alloc] init]; NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil]; ... [fileManager release]; As of ARC you can of course drop the release statement. 来源: https://stackoverflow.com/questions/7064190/iphone-sdk-xcode-how-to-get-all

Copy NSMutablearray to another

流过昼夜 提交于 2019-12-04 08:58:38
I am trying to copy NSMutableArray to another but it does not show me anything at the UITableView : NSMutableArray *objectsToAdd= [[NSMutableArray alloc] initWithObjects:@"one",@"two"]; NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:objectsToAdd,nil]; NSMutableArray *list = [[NSMutableArray alloc] init]; [self.list addObjectsFromArray:myArray]; Nothing show up! What is wrong? It crashes my app because I do not have nil at my NSMutableArray how can I add nil to it? addobject:nil does not work it crashes the app: static NSString * DisclosureButtonCellIdentifier = @

Sorting Array alphabetically [duplicate]

元气小坏坏 提交于 2019-12-04 08:40:45
This question already has answers here : Closed 8 years ago . Possible Duplicate: How to sort a NSArray alphabetically? Hi all, I have an array which consist of companies name. I want to sort array alphabetically so that companies name come in alphabetic order. Please suggest me how to do this. Thanks in advance [myArray sortUsingSelector:@selector(caseInsensitiveCompare:)]; Rams NSArray *sortedStrings = [strings sortedArrayUsingSelector:@selector(compare:)]; Simon Lee See this.... Alphabetical Sort If the array consists of NSStrings : [companies sortUsingSelector:@selector(compare:)]; 来源:

NSPredicate - case insensitive filtering for multiple conditions

不羁的心 提交于 2019-12-04 08:29:41
I'm using following NSPredicate for filtering, NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(firstName CONTAINS %@ ) OR (lastName CONTAINS %@ )OR (UserName CONTAINS %@ ) ", myText,myText,myText]; NSArray *filtered = [responseArray filteredArrayUsingPredicate:predicate]; It works fine, but it's case-sensitive. I need the filtering should be case insensitive. I've tried, NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(ANY firstName CONTAINS %@ ) OR (ANY lastName CONTAINS %@ )OR (ANY UserName CONTAINS %@ ) ", myText,myText,myText]; But it throws the error ***

UITableView, how do I know what Section during cellForRowAtIndexPath?

Deadly 提交于 2019-12-04 08:12:44
问题 I have a UITableView displaying a list of Cities. I want to separate them by State. I can't seem to figure out how to get it to pick the right items out of my Array. If Section 1 (Arizona) has 2 Cities and Section 2 (California) has 2 Cities, during cellForRowAtIndexPath, Section 2, City 1 has an index of 0, even though it's the 3rd item in my array. I thought about just turning my City Array into a State Array, where each item holds an Array of Cities, but I still don't know what section I'm

How to make a Global Array?

旧街凉风 提交于 2019-12-04 07:10:57
So, I read this post , and it's pretty much exactly what I was looking for. However... it doesn't work. I guess I'm not going to go with the singleton object, but rather making the array in either a Global.h file, or insert it into the _Prefix file. Both times I do that though, I get the error: Expected specifier-qualifier-list before 'static' and it doesn't work. So... I'm not sure how to get it to work, I can remove extern and it works, but I feel like I need that to make it a constant. The end goal is to have this Mutable Array be accessible from any object or any file in my project. Help

addObject: to array not working (array still nil)

痴心易碎 提交于 2019-12-04 06:46:53
问题 This app is a table view with a tab bar controller. I am logging the count of the array: arrayOfFavourites and even though i add an object is continues to have a nil value, my relating code, all objects shown are allocated and initialized in the code (previous or present) some are instances and some are properties: ListViewController.m: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"TOUCHED CELL!"); // Push the web view controller onto the

how to remove NULL values from NSMutableArray? ios

风流意气都作罢 提交于 2019-12-04 06:42:24
i have array of birthdates as array is getting filled from facebook so there are some friends whos birthdates are private so it contain NULL how to convert that array like empty string wherever there is null value the array is like below "<null>", "10/29/1988", "11/13", "03/24/1987", "04/25/1990", "03/13", "01/01", "<null>", "12/15/1905", "07/10", "11/02/1990", "12/30/1990", "<null>", "07/22/1990", "01/01", "07/17/1989", "08/28/1990", "01/10/1990", "06/12/1990", The null values appear to be string literals @"<null>" rather than the NSNull objects typically used to represent nil s in Cocoa

Storing NSMutableArray filled with custom objects in NSUserDefaults - crash

爷,独闯天下 提交于 2019-12-04 05:47:54
问题 EDIT: Here is a working version. I was able to retrieve my object within the NSMUtableArray after I saved and loaded it from the NSUserDefaults via NSCoding. I think it's important to mention, that you not only need to de-archive the array, but also all its content. As you can see, I had to not only store the NSData of my freeze object, but also the NSData of my array: // My class "Freeze" @interface Freeze : NSObject <NSCoding> // The NSCoding-protocoll is important!! { NSMutableString *name