nsmutablearray

Objects not being added to NSMutableArray Objective -C

ⅰ亾dé卋堺 提交于 2019-11-30 23:48:40
I'm trying to simply add objects to a mutable array but they WILL NOT insert. I'm not getting errors or anything and I can't figure out whats going on. In my main delegate file I split an array into 4 separate strings like so. NSArray *split=[currentParsedCharacterData componentsSeparatedByString:@"|"]; NSLog([split objectAtIndex:3]); NSString *date=[split objectAtIndex:0]; NSString *venue=[split objectAtIndex:1]; NSString *event=[split objectAtIndex:2]; NSString *city=[split objectAtIndex:3]; I've traced out the string values and they are definitely there. Up next I try to add these string

How to remove elements in NSMutableArray or NSMutableDictionary during enumeration?

筅森魡賤 提交于 2019-11-30 17:50:12
I am using block based enumeration similar to the following code: [[[rows objectForKey:self.company.coaTypeCode] objectForKey:statementType] enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id coaItem, NSUInteger idx, BOOL *stop) { // block code here }] I would like to remove some of the objects during the enumeration process depending on the their object values. How could I do this? I know that manipulating an mutable array or dictionary (NSMutableArray or NSMutableDictionary) during enumeration is usually not possible. What would be the best way to implement this? Thank you!

Writing a new set of data to Plist instead of overwriting it

你。 提交于 2019-11-30 16:33:10
I'm trying to get a plist to store multiple sets of data, but each time I save (using a button from an ActionSheet), it overwrites the previous set. I want to add multiple 'friends' and their data. I'm not too keen on using Core Data, so I'm wondering how you can do it with a Plist. Here is the code for the save button: NSMutableDictionary *friend = [[NSMutableDictionary alloc] init]; NSMutableDictionary *array = [[NSMutableDictionary alloc]init]; [array setObject:friendName.text forKey:@"Name"]; [array setObject:friendPhone.text forKey:@"Phone Number"]; [array setObject:friendEmail.text

Filtering array of dictionaries in Swift

纵饮孤独 提交于 2019-11-30 16:02:21
I have An Array With Dictionaries example : ( { Email = "kate-bell@mac.com"; Name = "Kate Bell"; Number = "(555) 564-8583"; }, { Email = "d-higgins@mac.com"; Name = "Daniel Higgins"; Number = "555-478-7672"; } ) And i want to filter this dictionary according to Key "Name" func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { let predicate = NSPredicate(format:"Name == %@", searchText) let filteredArray = (arrContact as NSMutableArray).filteredArrayUsingPredicate(predicate) print(filteredArray) if(filteredArray.count == 0){ searchActive = false; } else { searchActive = true

Add NSUInteger to NSMutableArray

不羁岁月 提交于 2019-11-30 15:46:21
Hello I am working on a project and I am trying to add an NSUInteger to an NSMutableArray. I am new to Objective-C and C in general. When I run the app NSLog displays null. I'd appreciate any help anyone is able to provide. Here is my code -(NSMutableArray *)flipCardAtIndex:(NSUInteger)index { Card *card = [self cardAtIndex:index]; [self.flipCardIndexes addObject:index]; if(!card.isUnplayable) { if(!card.isFaceUp) { for(Card *otherCard in self.cards) { if(otherCard.isFaceUp && !otherCard.isUnplayable) { int matchScore = [card match:@[otherCard]]; if(matchScore) { otherCard.unplayable = YES;

NSMutableArray is empty after addObject

为君一笑 提交于 2019-11-30 15:17:19
问题 I want to add an object into an NSMutableArray: NSLog(@"Object text: %@", object.text); NSLog(@"Object: %@", object); [appdelegate.objects addObject:object]; NSLog(@"Objects array size: %i", [appdelegate.objects count]); This is the output: Object text: This is the text Object: <Object: 0x6e762c0> Objects array size: 0 How is this possible, I add an object, on the next line, it is still empty. The NSMutableArray is not nil , because that would raise an exception. Anybody a guess? 回答1: It

how to intersect two arrays in objective C?

爷,独闯天下 提交于 2019-11-30 14:38:37
问题 I have two arrays . Array1 contains 15 objects and Array2 contains 4 objects. There are 2 common objects from both array, I just want to get that resulted array of that 2 objects. It should be like intersection of two Set, but how to do in Objective C for array..? Please help. thanks. 回答1: Using NSMutableSet NSMutableSet *set1 = [NSMutableSet setWithArray: array1]; NSSet *set2 = [NSSet setWithArray: array2]; [set1 intersectSet: set2]; NSArray *resultArray = [set1 allObjects]; 来源: https:/

Filtering array of dictionaries in Swift

南楼画角 提交于 2019-11-30 14:20:44
问题 I have An Array With Dictionaries example : ( { Email = "kate-bell@mac.com"; Name = "Kate Bell"; Number = "(555) 564-8583"; }, { Email = "d-higgins@mac.com"; Name = "Daniel Higgins"; Number = "555-478-7672"; } ) And i want to filter this dictionary according to Key "Name" func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { let predicate = NSPredicate(format:"Name == %@", searchText) let filteredArray = (arrContact as NSMutableArray).filteredArrayUsingPredicate(predicate

NSMutableArray is empty after addObject

混江龙づ霸主 提交于 2019-11-30 13:49:21
I want to add an object into an NSMutableArray: NSLog(@"Object text: %@", object.text); NSLog(@"Object: %@", object); [appdelegate.objects addObject:object]; NSLog(@"Objects array size: %i", [appdelegate.objects count]); This is the output: Object text: This is the text Object: <Object: 0x6e762c0> Objects array size: 0 How is this possible, I add an object, on the next line, it is still empty. The NSMutableArray is not nil , because that would raise an exception. Anybody a guess? It would not raise an exception if it was nil . You can still message a nil object if it usually responds to that

how can I Add a ABRecordRef to a NSMutableArray in iPhone?

醉酒当歌 提交于 2019-11-30 12:53:54
I want to create an array of ABRecordRef(s) to store contacts which have a valid birthday field. NSMutableArray* bContacts = [[NSMutableArray alloc] init]; ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); CFIndex nPeople = ABAddressBookGetPersonCount(addressBook); for( int i = 0 ; i < nPeople ; i++ ) { ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i ); NSDate* birthdayDate = (NSDate*) ABRecordCopyValue(ref, kABPersonBirthdayProperty); if (birthdayDate != nil){ [bContacts addObject:ref]; } } The compiler shows