FAQ Database Discussion Community


When does it count from zero?

ios,objective-c,uitableview,nsmutablearray
I have a UITableView with multiple prototype cells. I then have a NSMutableArray that stores the cellID's so I can retrieve them at cellForRow... Here is the code: -(void)viewDidLoad { self.cellID = [[NSMutableArray alloc] initWithObjects:@"typeOfGraph", @"graph", @"time", nil]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *currentCellID = [self.cellID...

How to add Coordinates to CLLocationCoordinate2D from Dynamic NSMutableArray?

ios,objective-c,annotations,nsmutablearray,mkmapview
I have a MapView in which I would like to add annotations and a route from defined coordinates that I add from a Textfield and store in an NSMutableArray. Now I'm able to show the route from multiple coordinates but only when I insert them in my code as follow...

Objective-C if else function, need to iterate from array, but Xcode is throwing undeclared errors

objective-c,xcode,loops,if-statement,nsmutablearray
The code is supposed to be a basic objc program that contains a list of purchased stocks, foreign and domestic. Right now, I have to put them into a portfolio and sum it up. I realized that I could not sum them up because I was getting an error with...

how to check if NSMutableArray element is NSNull or AnyObject

ios,swift,core-data,nsmutablearray,nsnull
I have a PersonsArray: NSMutableArray = [NSNull, NSNull, NSNUll, NSNull, NSNull, NSNUll, NSNull]. I needed seven slots that I then can fill with an Entity CoreData entry as AnyObject. I need to do a for in loop on this NSMutableArray... If the index slot is NSNull I want to pass...

nsmutable array not saving values

objective-c,nsmutablearray
My array is not saving the values I put in it... I am defining my nsmutablearray *arrayClientList in .h file @interface StartupTableViewController : UIViewController<UITableViewDataSource, UITableViewDelegate> @property (strong, nonatomic) IBOutlet UITableView *tableView; @property NSMutableArray *arrayClientList; @property BOOL boolAddToClient; //@property (strong, nonatomic) NSMutableArray *arrayAddClient; @end in .m file I am initializing like...

NSMutableArray out of bounds only when populated with another array

ios,objective-c,arrays,uitableview,nsmutablearray
So I have a UItableView that auto populates cells based upon user input. I have a master array of Colors names called arrColors, and a 'temp' array called arrAutoCorrect, that is populated when the user types. Both arrays are NSMutableArrays. If the user clears out all the text, the temp...

get value of class property (NSMutableArray)

ios,objective-c,iphone,for-loop,nsmutablearray
I'm new to objective-c and have already released the first version of my app in the App Store but I want to improve my app because in the current version, I can only enter 4 player names. In my new iOS app, I have a table view that lists all...

Sort NSmutablearray with two special keys

objective-c,sorting,nsmutablearray
I have a tableview, its header is stored in a mutablearray, the array looks like (2005 fall, 2005 spring, 2007 summer...) When I output the tableview, I want the header in time ascending displayed. 2005 spring 2005 fall 2007 summer I used the code here: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section...

saving facebook mutual friends to array or dictionary

objective-c,facebook-graph-api,nsmutablearray,nsmutabledictionary
This is probably a very novice question and I'm embarrassed to ask, but I've wasted a bunch of time trying to figure this out. I followed facebook's documentation and can now successfully retrieve mututal friends. The problem, I'm having trouble saving them to an array or dictionary. My goal is...

Fast Enumeration over NSMutableArray problems

objective-c,nsmutablearray,enumeration
I am having some issues trying to wrap my head around why we can not mutate a collection during enumeration... Apparently, if you are doing any sort of fast enumeration, the system should throw an exception if you try to mutate. Below I have three examples where I am mutating...

addObject to NSMutableArray is nil even after initialization?

ios,objective-c,nsmutablearray
I have an NSMutableArray declared as property in .h and initialized in viewDidLoad in my SPOCVC .m (UIViewController)... @property (strong, nonatomic) NSMutableArray* SPOCTrackList; in viewDidLoad if ([self SPOCTrackList] == nil) { self.SPOCTrackList = [[NSMutableArray alloc]init]; NSLog(@"SPOTTrackList INITIALIZED"); } In a separate VC, I'm trying to pass/addObject to SPOCTracklist... -(void)tableView:(UITableView *)tableView...

Why can't I access the elements of my NSMutableArray?

objective-c,indexing,nsmutablearray
I declared arrays a,b,c and d as properties in my interface class and initialized them like this: [self setPatternA:[[NSMutableArray init] initWithArray:@[@0,@0,@1,@1,@2,@2]]]; [self setPatternB:[[NSMutableArray init] initWithArray:@[@3,@4,@4,@5,@5,@3]]]; [self setPatternC:[[NSMutableArray init] initWithArray:@[@3,@3,@4,@4,@5,@5]]]; [self setPatternD:[[NSMutableArray init] initWithArray:@[@0,@1,@1,@2,@2,@0]]]; and now I'm trying to access them like this: NSInteger a=[patternA objectAtIndex:3]; NSLog(@"pattern a: %ld", (long)a); but...

Filter array using predicate based on another array that is key for predicate

ios,iphone,arrays,xcode,nsmutablearray
Hello everyone this may be silly question and may be asked before, I want to filter the array using predicate. I have an array which contains dictionary of same type like following. <NSArrayM>( ID:54d3ca82535c12243400c254 Room JID:(null) name:(null) photo:(null) type:3 lastMessage:Gand lastMessageDate:2015-02-05 20:02:47 +0000 occupantIDs:( 2285222, 2285224 ) userID:2285224 unreadMessagesCount:4 lastMessageUserID:2285224...

Objective C delete last NSString in NSMutableArray

ios,objective-c,nsstring,nsmutablearray
I am trying to get the last NSString from a NSMutableArray, and delete it if it's empty. Here is the code I am using: - (void)viewWillAppear:(BOOL)animated { if ([notes.data length]==0){ [storedText removeLastObject]; } [self.tableView reloadData]; } data is the NSString and storedText is the NSMutableArray. This code deletes the NSString...

separate future date in nsmutablearray

ios,objective-c,nsmutablearray,nsarray,nsdate
I am having a mutable array in that array i am having only past date, current date & future date. I have to separate the future date & store into another array. Can you help me. This is my array: uniqueItems( "2015-03-01", "2015-02-28", "2015-02-22", "2015-02-21", "2015-02-20", "2015-02-15", "2015-02-14", "2015-02-13", "2015-02-08",...

Array with array inside

ios,arrays,dictionary,nsmutablearray
I need to create an array with personal name inside,and on this name,another array with personal information.Basically an array with another array inside divided by name. Es:Array[luca [born:x age:y lives:z] marco[born:x age:y lives:z]......} How can i do that?...

get array from dictionary from NSMutableArray iOS

objective-c,iphone,ios8,nsmutablearray,nsdictionary
I have NSMutableArray (self.temporaryArray). How to get "options" key array from dictionary from self.temporaryArray in nsmutablearray. There is console data. self.temporaryArray..( ( { "option_group" = 0; options = ( "<font face=Arial size=2>English</font>\"", "\"<font face=Arial size=2>Both English &amp; German</font>\"", "\"<font face=Arial size=2>Both English and French&nbsp;</font>\"", "\"<font face=Arial size=2>Only German</font>\"", "\"<font face=Arial...

Objective-C - add object to NSMutableArray at specific index

ios,objective-c,asynchronous,nsmutablearray
I'm using Parse as my backend. Saving/fetching objects runs in a separate thread from the main thread, so if you are doing anything with the data you are trying to fetch, you must do it in a background block, like this: [Card fetchInBackgroundWithBlock:^(PFObject *object, NSError *error) { UIButton *button =...

How to Sort object by alphabet order for UITableViewCell?

ios,objective-c,uitableview,nsmutablearray,nsobject
I want to sort objects that i created & stored in NSMutableArray in AppDelegate.m. Stations is NSObject Class I want to show station names in another UIViewController in alphabet order(in UITableViewCell) & when i click on them i want to pass the object that contains station name,latitude,longitude to next UIViewController...

NSDictionary in NSMutableArray ios

ios,objective-c,nsmutablearray,nsdictionary,nsmutabledictionary
I've a NSMutableArray array having NSDictionary keys as: NSMutableArray *[email protected][@{@"A":@{@"user":@"obj1",@"friend":@"obj2"}}]; No I want to add objects to this NSMutableArray. My Code: for (int i = 0; i < 10; i++) { NSString *user = @"A"+i; for(int i=0;i<50;i++) { NSString *friend1 = @"B"+i; NSString *friend2 = @"C"+i; NSString *friend3 = @"D"+i;...

What is the way to add Parse objects into a NSMutableArray?

ios,parse.com,nsmutablearray
I have a mutable array named "eventnameArray". What i want is to add objects. This objects to add come from a Parse query. This is the mutable array: eventArray = [[NSMutableArray alloc]init]; This is the Parse query, which works. PFQuery *query = [PFQuery queryWithClassName:@"Event"]; [query selectKeys:@[@"EventName"]]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError...

Swift class cast fails while casting AnyObject to NSMutableDictionary

class,swift,nsmutablearray,classcastexception
var fetchEachStory = Firebase(url: "\(self.individualStoryUrl)\(eachStory)") // Read data and react to changes fetchEachStory.observeEventType(.Value) { snapshot in let storyDetails = snapshot.value as NSMutableDictionary? let score = storyDetails!["score"] as Int? var thisStory = eachStory if score? > self.minSetScore { self.showStories[thisStory] = storyDetails } } While Assigning Snapshot.value to story details, it fails...

iOS: remove objects or reinitialize arrays in swift?

ios,swift,nsmutablearray,nsarray
I'm new in swift and I want to know if the beast approach to reuse an array is to delete all object inside or reinitialize it. For example if I have: var my_array:NSMutableArray! //global variable and the first method that I use: func firstMethod{ my_array = NSMutableArray() my_array.addObject("one") my_array.addObject("two") my_array.addObject("three")...

change object get from NSUserDefaults

ios,objective-c,nsmutablearray,nsuserdefaults,nsmutabledictionary
I’d like to change object get from NSUserDefaults. But when executing following code, the app crash with error message: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object’ I have this code. NSUserDefaults* pref = [NSUserDefaults standardUserDefaults]; NSMutableArray* data = [[NSMutableArray alloc]init];...

Insert elements in next index of NSMutableArray

ios,objective-c,nsmutablearray
I am adding multiple elements in NSMutableArray but its storing single element at o index. I need to add the elements into next index every time until the end of the loop for (i=1; i<58; i++) { NSString *stringFromInt = [NSString stringWithFormat:@"%d", i]; NSString *strlastName =[[dict objectForKey:stringFromInt]objectAtIndex:7]; [arrLastName insertObject:strlastName atIndex:i];...

how to deal with NSMutableArray containing CoreData Entry after Entry is deleted from CoreData, showing as “

ios,swift,core-data,nsmutablearray,fault
PersonsArray: NSMutableArray = ( "<null>", "<null>", "<null>", "<MyProject.Person: 0x7ffc5257d850> (entity: Person; id: 0xd000000000040000 <x-coredata://8DD0B78C-C624-4808-9231-1CB419EF8B50/Person/p1> ; data: {\n image = nil;\n name = dustin;\n})", "<null>", "<null>", "<null>", "<null>", "<null>") if the user deletes CoreData Entry (entity: Person; name = dustin) PersonsArray: NSMutableArray = ( "<null>", "<null>", "<null>", "<MyProject.Person:...

Shuffle NSMutableArray with 'Shuffle Albums' for up next queue (MediaPlayer)?

ios,algorithm,swift,nsmutablearray,mpmediaitem
I have managed to create an up next queuing system that works (almost) perfectly. I can move, delete and add songs to the list without any issues at all. The only problem i am having is that when the user decides to use a shuffle mode (e.g. MPMusicShuffleMode.Songs), the up...

Most efficient way to create an NSMutableArray from NSArray

objective-c,cocoa,cocoa-touch,nsmutablearray,nsarray
Which of these, if either, is more efficient? NSMutableArray *array = [NSMutableArray arrayWithArray:@[@1, @2]]; or NSMutableArray *array = [@[@1, @2] mutableCopy]; Or are these the same internally?...

Sort NSMutableArray as threaded comments

ios,objective-c,uitableview,nsmutablearray,nsarray
I'm developing an iOS app for website, that uses disqus comment system. So I'm trying to add feature for adding comments from this application. My problem is that I don't know how to keep threaded structure, for example: Comment 1 Child 1.1 Child 1.1.1 Child 1.1.2 Child 1.2 Child 1.2.1...

Data retrieved from a NSMutableArray are different with the one I saved into it

objective-c,nsmutablearray
Why the value of cells retrieved from a NSMutableArray is different with the ones I have originally stored in it? I have a property of type NSMutableArray and I use it to hold an integer matrix with the following code tiles = [[NSMutableArray alloc] initWithObjects: @1, @1, @1, @1, @1,...

How to download images from array to tableviewcontroller in swift?

arrays,xcode,image,swift,nsmutablearray
I have a table view controller with a cell that contains an UIImageView. I also have a NSMutableArray that contains the url's. I want the url's to download the images and place them in the correct order. The NSMutableArray also contains some empty Strings and the cell that it corresponds...

Encoding, decoding, and editing a NSMutableArray with NSCoding

ios,objective-c,nsmutablearray,nscoding
I followed along with Ray Wenderlich's tutorial for saving game data using a singleton and NSCoding (http://www.raywenderlich.com/63235/how-to-save-your-game-data-tutorial-part-1-of-2). Everything they did I've been able to use for NSStrings (changing value, storing, using in my project). I tried to make an NSMutableArray so I could add to and save a list of...

Changing the description of an id object

objective-c,nsmutablearray
I am storing items in an array to be stored in myTableView like so: - (void)insertNewObject:(id)sender { if (!self.objects) { self.objects = [[NSMutableArray alloc] init]; } [nameField becomeFirstResponder]; [self.objects insertObject:@"New Friend" atIndex:0]; //[self.objects insertObject:[NSDate date] atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } Once The object is...

Remove object from NSMutableArray if it exists in another array [duplicate]

objective-c,cocoa,cocoa-touch,collections,nsmutablearray
This question already has an answer here: Remove elements from one NSMutableArray which are contained in another array 1 answer I am trying to build a quiz based game where you can play with your Facebook friends. I have three sections in a table where the first section shows...

NSMutableArray is only storing one value. Using Parse to query for data

ios,objective-c,parse.com,nsmutablearray
My code querys parse and attempts to store the values obtained from parse into arrays. The arrays are then displayed in a table view in a new view controller. When I execute my code it should result in storing two values in each array. This array will then populate a...

Can't return objects from User class in Parse.com iOS

ios,objective-c,parse.com,nsmutablearray,uisearchbar
I am trying to return users from my User class with a UISearchBar and UITableView. For some reason I can't retrieve any objects from the User class in Parse. Do you have any idea why I can't get any objects, even if there are a lot of users in the...

Table View's cellForRowAtIndexPath: not being called

ios,objective-c,uitableview,nsmutablearray
For some reason, my table view's cellForRowAtIndexPath:(NSIndexPath *)indexPath method isn't being called. Here is my code: - (void)viewDidLoad { [super viewDidLoad]; messages = [[NSMutableArray alloc]init]; chatTable = [[UITableView alloc]init]; chatTable.delegate = self; chatTable.dataSource = self; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"Called Count...

Get NSString from NSMutableArray on Swift

swift,nsmutablearray
How can I get NSString from NSMutableArray created with NSStrings in a for loop? I want to store in one NSString, all elements of NSMutableArray. This is my code: class Persona: NSObject { var edad: Int var altura: Double var nombre: NSString var apellido: NSString var cualidades: NSMutableArray init(edad:Int, altura:Double,...

Why is the size of an NSMutableArray that contains three JSON objects returning 1 and not 3?

objective-c,nsmutablearray
Please help me understand this, but I have an NSMutableArray, where an NSLog contains the following contents: ( ( { day = 0; "end_time" = "21:00"; }, { day = 0; "end_time" = "21:00"; }, { day = 0; "end_time" = "21:00"; } ) ) When I perform [array count],...

NSMutableDictionary VS NSMutableArray speed

ios,objective-c,xcode,nsmutablearray,nsmutabledictionary
I am using a cache for images that are downloaded from Parse.com. Images are used as the background images for UIButtons in a UITableView's cells. The images are stored in an NSMutableDictionary. code below: PFUser *user =self.currentUser.friends[(int)indexPath.row*4+i]; label.text=user.username; UIImage *cachedImage = self.images[@(indexPath.row*4+i)]; if (cachedImage) { NSLog(@"Have image"); [button setBackgroundImage:cachedImage forState:UIControlStateNormal];...

KVO. ObserveValueForKeyPAth is not called

objective-c,nsmutablearray,key-value-observing
I am not if this will work properly [[cr1.crossRoad.trafficLights objectForKey: [NSNumber numberWithInt:pedestrianTL]] addObserver:view forKeyPath:@"colorState" options:NSKeyValueObservingOptionNew context:nil]; The project I'm developing doesn't work properly. This way I was trying to add an observer to change the view with after every change happening to the cell of the colorState array. -(void) observeValueForKeyPath:(NSString...

sorting nsmutablearray contaning dictionary in alphnumberic way

ios,sorting,nsmutablearray,nsmutabledictionary
I have array containing dictionary like below:- ( { "act_priority" = B1; } { "act_priority" = ""; } { "act_priority" = A; } { "act_priority" = A3; } { "act_priority" = B; } { "act_priority" = A2; } { "act_priority" = A1; } { "act_priority" = ""; } ) I...

Can't add object to NSMutableArray in singleton

ios,xcode6,singleton,nsmutablearray
I made a singleton and i'm trying to add objects to self.timelineArray but i can't. When i do this i have 9 objects: NSNumber* nmb = [[NSNumber alloc] initWithInt:1]; [self.dataManager.timelineArray addObject:nmb]; After i insert the nmb object, i still have 9 objects. Here's my singleton header (only important bits): @interface...

[__NSCFString name]: unrecognized selector sent to instance

ios,objective-c,uitableview,nsmutablearray,nsindexpath
odd issue, my application has a UITableView with three sections, each populated by a separate array. The end-goal is to have the ability to move cells from section to section, so I wrote the 'logic' in the UITableViewController. Unfortunately, if I try to move a cell into an empty section,...

Error when adding NSString object to my NSMutableArray

ios,objective-c,nsmutablearray
I am getting this error when trying to add the NSString object named object to my array : erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance 0x7fc48ae52ba0' Not sure why this is so. I was originally using NSArray to changed it to NSMutableArray...

How to set the elements of NSMutableArray to UILabel in Objective-C?

ios,objective-c,nsmutablearray
I am new to IOS. I have set the data into NSMutableArray. I want to get the elements of NSMutableArray and set it to the UILabel like the following. self.RedValue.text = [LEDstate objectAtIndex:0]; But it crash for following reason: 2015-03-04 19:01:24.384 BLE_Running[1610:870444] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',...

Editing NSMutableArray of identical objects

ios,objective-c,replace,nsmutablearray
I have an NSMutableArray of custom objects (Subclasses from JSONModel), all the objects are identical. I'm copying a single object as many times I want to add it to the array (If this method is wrong, kindly suggest the proper way). When I edit/modify an object at some index, it...

Why can't I create an NSMutableArray of integers?

objective-c,arrays,integer,nsmutablearray
Is this format not allowed in Objective C? NSMutableArray arrayA=[0,1,2,3,4,5]; is the only way to do this by adding one integer at a time?...

How can I prevent updated Parse objects from moving to the front of my array?

ios,uitableview,swift,parse.com,nsmutablearray
For Context: I have a UITableView which displays UITableViewCells of drawings completed by users. This tableview pulls data stored on my Parse account and is attempting to display the cells in reverse chronological order, the most recently submitted drawing at the top. I have a "like" button on each cell...

iOS NSMutableArray removeObjectAtIndex

ios,objective-c,nsmutablearray
This is my code in ViewController.m file, - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSLog(@"%f",[self usedMemory]); NSMutableArray *array= [[NSMutableArray alloc]init]; for (int i = 0; i < 100; i++) { NSMutableData *data = [NSMutableData dataWithLength:10000]; [array addObject:data]; } NSLog(@"%f",[self usedMemory]); for (int i = 0; i < 100; i++) { [array removeObjectAtIndex:0];...

NSMutableArray add element not working

objective-c,nsmutablearray
I have a NSMutableArray and add a new element to it. But apparently it is not added. What am I doing wrong here? Any hints? However, when I run this program for a second time, it works properly. Code: NSMutableArray *badgesEarned; badgesEarned = [[NSMutableArray alloc]init]; NSArray *loadedBadgesEarned = [defaults valueForKey:@"badgesEarned"];...

How to search something in NSMutableDictionary

ios,objective-c,nsmutablearray,nsmutabledictionary
Hello I have a NSMutableArray like this Contactarray ( { "firstNAme"="name1" "lastName"="name2" "phoneNumber"="12345678902"; } { "firstNAme"="name1" "lastName"="name2" "phoneNumber"="12345678902"; } I want to search the person when I type the person name in my UITextField. Then the filtered UItableView should be loaded. This NSMutableArray contains NSMutableDictionaries. How can I find the...

NSMutableArray and synchronization

ios,objective-c,thread-safety,nsmutablearray
I am using an NSMutableArray like a Queue. Imagine that the app is like Tinder, and when stack of Cards go below a number I fetch new data. When fetching data, they are added at the end of the NSMutableArray. When swiping, I remove fron object. Should I synchronize these...

NSMutableArray addObject using value and key

objective-c,iphone,nsmutablearray,nsmutabledictionary
I found some codes like this: for (int i = 0 ; i < pinyin_array.count; i++) { [pinyins_arr addObject:@{k_PINYIN : pinyin_array[i]}]; } where pinyins_arr is a NSMutableArray and Kk_PINYIN is a NSString. I am not sure if this is correct or not. I think it should be a NSMutableDictionary to...

NSMutableArrays store only 2 objects

ios,iphone,swift,nsmutablearray,nsuserdefaults
I have a weird problem - my mutable array stores only 2 objects - its count is 1,2,2,2 and doesn't change. My only observation is that it always replaces old values f.x. I have: value1 - 2, value2 - 4 and I add next object f.x. 66 and my array...

Remove NSNull values in a KVC generated NSMutableArray

ios,nsmutablearray,key-value-coding,kvc,nsnull
Here's a little test: NSDictionary * test = @ { @"centers" : @[ @{ @"id":@"12345", @"favorite":@NO }, @{ @"id":@"2345", @"favorite":@NO }, @{ @"id":@"345", @"favorite":@YES }, @{ @"favorite":@NO } ]}; NSMutableArray * test2 = [test mutableArrayValueForKeyPath:@"centers.id"]; NSLog(@"%@",test2); The log gives: ( 12345, 2345, 345, "<null>" ) That's great, now, I wish...

NSMutableArray not adding NSDecimalNumber

ios,objective-c,nsmutablearray,nsdecimalnumber
I'm trying to add NSDecimalNumbers to an NSMutableArray. Here is the code: for (int i = 0; i < [dollarArray count]; i++) { NSString *string = [NSString stringWithFormat:@"%@.%@", [[firstArray objectAtIndex:i] firstObject], [[secondArray objectAtIndex:i] firstObject]]; NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithString:string]; [arrData addObject:number]; } NSLog(@"%@ and %@", number, arrData); The results for...

Suggestions need for UI : Listing NSMutableArray elements

objective-c,nsmutablearray,nstableview,nsarraycontroller
I am new to Mac app development. So, I am doing some exercises in Objective-C. I have a nsmutablearray which contains list of names. I want to display a name list using MVC approach and I want perform some action while pressing name in the list view. I came across...

Adding object to NSMutableArray or Converting Float to NSNumber [duplicate]

objective-c,nsmutablearray,nsnumber
This question already has an answer here: NSMutableArray addObject not working 2 answers Having difficulties apparently with either adding elements to a NSMutableArray or to converting float to a NSNumber. Here is a working while loop that uses simple C arrays and not NSMutableArray. It was tested with printf's:...

Rewriting the values in NSMutableArray

ios,objective-c,nsmutablearray
I have an app that allows the user to change the language of some content between English and Welsh. The following is used to populate an NSMutableArray called comments. The first time the code is used it works fine but if the language is subsequently changed the comments array will...

NSMutableArray showing “(” “)” normal brackets instead of “[” “]” square bracket in NSLog

ios,objective-c,nsmutablearray,nsarray
Iam trying to send one json in POST request. I created one NSMutableDictionary and added Key Value pairs, i have one NSMutableArray which contains Binary Stream of UIImage. so When i Add this NSMutableArray into NSMutableDictionary and i did one NSLog So result is { key:value, key:value1, ArrayKey:( iuhdgbdsnb325435435j435bu4h5h45hu34h545ih43h5i43hi5hu3i4h5u3 )...

Trying to add data from parse to an NSMutableArray in IOS

ios,objective-c,parse.com,nsstring,nsmutablearray
So, I am able to successfully perform a query of my parse database. This query matches the logged in user with all objects that have the logged in user in the key user. The object I'm querying has keys "email" "firstName" "lastName" "friendUserName" and "phoneNumber" I would like to be...

Why NSMutableArray doesn't save the data one the view has changed?

ios,cocoa-touch,nsmutablearray
I have a tableviewcontroller (Stops) that shows a list of stops (stopsArray), where the user can mark a specific Stop like his Favourite. After touching an UIImage, the stop is saved on the NSMutableArray (myStopsMArray). And until here everything is ok. But at the moment when I leave that viewcontroller...

__NSArrayI rangeOfCharacterFromSet

ios,objective-c,uitableview,nsmutablearray
I have following NSMutableArray. NSLog(@"vacc_name:%@",vaccScheduleArray_); output is : vacc_name:( ( "Hepatitis B (HepB)" ), ( "Hepatitis B (HepB) 2nd" ), ( "Hepatitis B (HepB) 2nd" ), ( "Rotavirus 1st" ), ( "Rotavirus 2nd" ), ( "Diphtheria, pertussis,and tetanus DTaP" ) and my uitableview code is: - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath...

Adding custom class object to an NSArray updates existing objects

ios,objective-c,class,nsmutablearray
I've got a UIView in a viewController: myView = [[rhythmUIView alloc] initWithFrame:CGRectMake(0,0,100,100)]; [self.view addSubview:myView]; The UIView exposes an NSArray in its .h: @interface rhythmUIView : UIView @property () NSMutableArray* myHits; @end And instantiates and initializes it in the UIView's .m: NSMutableArray* myHits; myHits = [[NSMutableArray alloc] init]; To which I...

Sorting NSMutableArray that contains NSMutableDictionaries [duplicate]

ios,objective-c,sorting,nsmutablearray
This question already has an answer here: How to sort an NSMutableArray with custom objects in it? 19 answers I'm trying to figure out the best/most efficient way to sort an array that contains n-number of dictionaries. One of the key/value pairs in each dictionary is a date field....

Why isn't NSMutableArray working?

ios,objective-c,nsmutablearray
I have a NSMutableArray of a class, and in other class I'd like to initialize it and add various objects. But the problem is that the NSMutableArray isn't retaining the elements. I have the following code: -(void)viewDidLoad { [super viewDidLoad]; MyStops *myStops = [self.storyboard instantiateViewControllerWithIdentifier:@"My Stops"]; myStops.myStopsMArray = [[NSMutableArray alloc]...

how to check all object in NSMutableArray same value

nsmutablearray,nsarray
I have on NSMutableArray like this: NSMutableArray *array = [NSMutableArray arrayWithObjects:@"0",@"0",@"0",@"0",@"0", nil]; now I want check if all object in my array are to same and equal to 0 doing certain work!!!. but I don't know about this. please guide me....

iOS - Adding objects to NSMutableDictionary causing crash

ios,swift,nsmutablearray,nsmutabledictionary
In the app I'm developing I'm reading in a JSON file. This file contains a list of players. Each player has a series of attributes. I have created a Mutable Array and a Mutable Dictionary to store the data. I'm trying to store the dictionary into an array index. I'm...

How to remove first few objects from NSMutableArray

uitableview,nsmutablearray
I have a NSmutableArray like this. [obj1,obj2,obj3,obj5,......]; this has assigned into a UITableView lets say user clicked on the 3rd cell. then I need to create another NSMutableArray like this. [obj3,obj4,obj5,------]; need to remove first few objects from the array upto the current object. How can I do this. please...

Array data from table view to label

ios,sqlite,nsmutablearray,tableview
I've got a tableview setup to display data from an sqlite database, now what I am trying to do is setup a view to display further information from said database when the user clicks on a table cell. From what I've read so far my understanding that this is done...

Save multiple values with same keys in NSMutableDictionary then store the dictionary in NSMutableArray

ios,nsmutablearray,nsmutabledictionary
I know this question has been asked many times but not got the solution or i might not understood that's why posting the question. for (int web=0; web<[web_arr count]; web++) { AdditionalBookmark *web_book=[[AdditionalBookmark alloc]init]; UITextField *txtNam = (UITextField*)[self.view viewWithTag:1100+web]; NSString *txtName = txtNam.text; UITextField *txtLin = (UITextField*)[self.view viewWithTag:1200+web]; NSString *txtLink...

removeobjectAtIndex: causes index to be -1;

xcode,osx,cocoa,nsmutablearray,nstableview
I have a NSTableView that is populated by an array called tableArray. I have a button that is supposed to remove the selected item from the array. In my removeItem: method: [tableArray removeObjectAtIndex:[tableView selectedRow]; [tableView reloadData]; But I get the error: 2015-05-13 18:16:45.283 FileShedb1.0[979:303] *** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond...

Obj-C - how to cast id into GLfloat[]

ios,objective-c,arrays,nsmutablearray
I've got a NSMutableArray of simple arrays of GLfloat. That's how I build it in Swift: var arrays = NSMutableArray() for(i=0; i<arraysCount; i++) { var array:[GLfloat] = [] // fill the array arrays.appand(array) } But how can I get my arrays by index in Objective-C? [arrays objectAtIndex:index] gives me an...

Add different images to UIImageView of cells in UITableView

objective-c,json,uitableview,uiimageview,nsmutablearray
Needless to say, i am a novice. I am trying to add images and text to a UITableView. I have been able to add the text but I am having problems with adding different images to the desired text. I have 2 separate PHP codes for 1 database: The first...

NSMutable array containsObject, does it check the contents of the object or the object type?

ios,nsmutablearray
I am a little confused to how containsObject works. Does it check to see if it contains an instance of an object type or does it compare the inside of the objects variables etc to see if they match?

Passing NSMutable array from one view to another

ios,nsmutablearray,nsuserdefaults
I want to add an element to a NSMutableArray in one view and that array should reflect in another view. I am using NSuserDefaults technique for this purpose.. Here's my code: View for adding element - (IBAction)donebutton:(id)sender { NSUserDefaults *defaults = [NSUserDefaults new]; if ([defaults objectForKey:@"arr"]) { self.arrayy = [defaults...

How not to change the parent NSMutableArray in Swift

swift,nsmutablearray
I have one NSMutableArray and I want just to copy it to another NSMutableArray and change the second one Example code let one: NSMutableArray = NSMutableArray(); one.addObject(9); var two: NSMutableArray = NSMutableArray(); two = one; two.addObject(4); one.addObject(2); println(two); // "(\n 9,\n 4,\n 2\n)" - the 2 should not be here...

Core Data and a UIActivityViewController

objective-c,core-data,nsmutablearray,nsarray,uiactivityviewcontroller
I have my app that is using core data to persist data. I have a UIActivityViewController setup on my main VC. Everything is working as I expect it to. My question is when you go to grab items from a core data model, how do you have it give you...

mutating method sent to immutable object' in nsmutablearray

ios,objective-c,loops,nsmutablearray,nsarray
I want to remove objects from NSmutableArray can one tell me the Best way to remove from NSMutableArray .h @property(nonatomic,retain)NSMutableArray *arr_property; .m _arr_property=[[NSMutableArray alloc]init]; MTPop *lplv = [[MTPop alloc] initWithTitle:SelectProperty(APP_SHARE.language) options:[_arr_property valueForKeyPath:@"property_list.property_type_name"] handler:^(NSInteger anIndex) { txt_Property.text=[[_arr_property valueForKeyPath:@"property_list.property_type_name"] objectAtIndex:anIndex]; NSLog(@"index number...

NSMutableArray of NSDictionaries

ios,objective-c,nsmutablearray
I have multiple NSDictionaries inside an NSMutableArray. A short hand example is below. comparisonChart is the NSMutableArray. NSDictionary *dict1 = @{ @"Tube": @"10/0", @"Dress":@"3" }; [self.comparisonChart setValue:dict1 [email protected]"0"]; // key 0 as i wish to use numeric indexes, comparisonChart is mutable array When i wish to extract the value for...

Can't remove all objects in NSMutableArray

ios,objective-c,nsmutablearray,nsarray
For some reason, I keep getting this error when I run my app: [__NSArrayI removeAllObjects]: unrecognized selector sent to instance I set up the NSMutableArray in .m like this: @implementation ChooseViewController { NSMutableArray *trackName; } And populate it like this: trackName = [JSON valueForKeyPath:@"results.trackName"]; But when I run this code,...

Use a predicate to search a NSMutableArray of Objects

swift,nsmutablearray,nspredicate,uisearchbardelegate,uisearchbardisplaycontrol
I have a collection of contacts I would like to filter: var arraycontacts: NSMutableArray = [] arraycontacts contains a large list of FriendModel Objects: var friend = FriendModel( name: self.contactName(contact), phone: self.contactPhones(contact), email: self.contactEmails(contact), phoneString: self.contactPhonesString(contact) ) self.arraycontacts.addObject(friend) I'd like to be able to use filterContentSearchText, to limit this array...

Incompatible pointer types assigning to 'NSString *' from 'NSMutableArray *'

ios,objective-c,pointers,nsmutablearray,xcode6
I'm presently taking an iOS development course and this line of the code I've encountered in the course generates this warning: Incompatible pointer types assigning to 'NSString *' from 'NSMutableArray *'. media.comments = randomComments; The array is created in this line: NSMutableArray *randomComments = [NSMutableArray array]; I tried adding mutableCopy...

Can't adding objects to MutableArray with iOS Parse SDK

ios,objective-c,object,parse.com,nsmutablearray
I am newbie on Objective C and Parse.com I want to add my string values from parse to my NSMutableArray.But I couldn't add there are my codes. -(void)getObjectsFromParseOnline: (NSString *)objectID { PFQuery *query = [PFQuery queryWithClassName:@"Veterinerler"]; [query getObjectInBackgroundWithId:objectID block:^(PFObject *vet, NSError *error) { if ([vet[@"isMember"]isEqualToString:@"YES"]) { [veterinerAdi addObject:vet[@"adi"]]; [veterinerAdres addObject:vet[@"adres"]];...

Overwriting NSMutableArray loaded from NSUserDefaults

objective-c,arrays,nsmutablearray,nsarray,nsuserdefaults
So I'm having real problems overwriting an array stored in NSUSerDefaults. Basically I have a checklist of 100 items (defined by bools in an array(which are actually strings at the moment)) and I need to save if each item is checked so when the app loads, the checklist remains as...

Collision Detection with an NSMutable array of Objects

sprite-kit,nsmutablearray,collision-detection
I'm attempting to make a game with objects that bounce between the left and right walls of the screen until they reach the bottom. I create my objects inside these methods which stores the objects in an NSMutable array and is called when the game begins. -(void)createContent { self.backgroundColor =...

How to erase duplicates of Child array in Parent array without hardcoring index

ios,objective-c,nsmutablearray
I have two arrays as fallows, NSArray *[email protected][@"a", @"b", @"c",@"d", @"e", @"f",@"g", @"h", @"i", @"j", @"k"]; NSArray *[email protected][@"a",@"d", @"e",@"g",@"i"]; Now In a NSMutableArray *Result=[[NSMutableArray alloc]init]; When i NSLog result array i wnated the output as [ b c f h j k ] Means the result array should delete the...

How to save NSMutableArray to Core Data?

ios,swift,core-data,nsmutablearray
I know it's not recommended to save NSMutableArray to Core Data but I need to access the array on another view controller (using one of the segue methods (such as passing a variable to another view controller) won't do the job). So unless there's another way that I'm not aware...

Objective-C creating and accessing mutable array

objective-c,nsmutablearray
I am trying to create an NSMutableArray to hold some objects but I m having real trouble understanding the proper syntax for creating one that all my methods in main.m can add to and access. I have tried making it an @property in the interface of the object i want...

Getting a particular key value for all object in JSON

ios,objective-c,json,nsmutablearray,nsmutabledictionary
This is my JSON: { "Frames": [ {"Image":"1.png", "Time":"0.04"}, {"Image":"2.png", "Time":"0.04"}, {"Image":"3.png", "Time":"0.04"}, {"Image":"4.png", "Time":"0.04"}, {"Image":"5.png", "Time":"0.04"}, {"Image":"6.png", "Time":"0.04"}, {"Image":"7.png", "Time":"0.04"}, {"Image":"8.png", "Time":"0.04"}, {"Image":"9.png", "Time":"0.04"}, {"Image":"10.png", "Time":"0.04"}, {"Image":"11.png", "Time":"0.04"}, {"Image":"12.png", "Time":"0.04"}, {"Image":"13.png", "Time":"0.04"}, {"Image":"14.png", "Time":"0.04"}, {"Image":"15.png",...

How to load text from UITextField and show it in UITableView every time textfield return text

ios,objective-c,uitableview,uiviewcontroller,nsmutablearray
I am aware this question has been asked before but the answer is not clear The problem is that theUITableview is using data fromviewDidLoad method where theNSMuatableArray has been allocated and initialised but contains void. But in the textfield method oftextFieldDidEndEditing,NSMutableArray do contain text from textField. I have a single...

JSON OBJECTS in Objective C

json,xcode6,nsmutablearray
I need to create a json object in the following format in XCode and I've been using XCode 6. string json = @"{'user': 'Teva', 'password': 'abc123', 'SourceID':1, 'SiteID':1, 'VariableID':1, 'MethodID':1, 'values':[ ['2015-01-29 21:00:00',133.0], ['2015-01-29 22:00:00',134.0] ]}"; I tried NSDictonary approach. However, I'm getting the following output: This is my code....

iOS insertObject with index

ios,objective-c,nsmutablearray
self.messageArray = [NSMutableArray array]; [self.messageArray addObject:[[MessageData alloc] initWithMsgId:[_instantMessageID objectAtIndex:i] text:[_instantMessageData objectAtIndex:i] date:[NSDate date] msgType:JSBubbleMessageTypeOutgoing mediaType:JSBubbleMediaTypeText img:nil]]; [self.messageArray insertObject:[[MessageData alloc] initWithMsgId:[messageID objectAtIndex:i] text:[messages objectAtIndex:i] date:[NSDate date] msgType:JSBubbleMessageTypeOutgoing mediaType:JSBubbleMediaTypeText img:nil] atIndex:0]; First...

Edit contents of NSMutableArray who's name is stored in contents of NSString

ios,arrays,nsstring,nsmutablearray
I have a function that accepts NSString variable in parameters and appends Array at the end which gives it the name of array already defined in class. How can i edit that array ? -(void) editArray:(NSString*)str{ //suppose str value is first NSString* myArrayName = [str stringByAppendingString:@"Array"]; //firstArray myArrayName contains the...