Questions tagged [nsarray]

An immutable, integer-indexed array of objects from the Apple Foundation framework.

An NSArray object manages an immutable array; once you have created the array, you cannot add, remove, or replace the objects in the array. You can, however, modify the individual elements themselves (if they support modification). The mutability of the collection does not affect the mutability of the objects inside the collection. You should use an immutable array if your data rarely changes, or changes all at once. Consider using a mutable array () if your data changes frequently.

Resources:

5346 questions
1
vote
1 answer

Create dictionary with dictionaries of arrays (sorted by a specific custom object property)?

The title may be confusing, apologies. Maybe someone can advise me on a more appropriate title. I have a .json file structured as below. "sections": [{ "title": "Locations", "key": "location" }], "contacts":…
rosshump
  • 370
  • 1
  • 4
  • 21
1
vote
1 answer

adding objects to unknown sized array, not orderly

I am trying to find a structure or way to adding objects from an array to another array. To clarify; actualArray[] // size not specified smthArray[1,9,8,4,9] i want to add objects from smthArray to actualArray from 5th index. Like…
Binus
  • 99
  • 1
  • 12
1
vote
2 answers

How to find sum of all objects for some key in array of custom objects in swift

I have array of objects in which I need to find sum of the particular key. I have the following properties in object class Due: NSObject { var dueIndex: Int? var dueAmount: Double? } I have the following logic to add the objects to array var…
Arasuvel
  • 2,971
  • 1
  • 25
  • 40
1
vote
1 answer

Compare dictionary object with an Array in Parse.com - iOS

I have a class that has a object type column, e.g. COLUMN 1 Row 1 : {"gender":"male","name":"A"} Row 2 : {"gender":"female","name":"B"} Row 3 : {"gender":"male","name":"C"} I need to get the rows whose objects for key name, in…
Hyder
  • 1,163
  • 2
  • 13
  • 37
1
vote
3 answers

Sort multi dimensional array based on sum of internal arrays in objective c

Let's say I have a multi-dimensional array like this: ( (2, 2, 1), (0, 1, 2), (0, 1, 1), (0, 0, 1), (0, 0, 2), (0, 1, 3), (0, 1, 0), (0, 0, 1), (0, 0, 1), (1, 3, 3) ) Now I need to sort this array in…
Rajesh S
  • 133
  • 1
  • 9
1
vote
1 answer

Turning Dictionary passed into two Arrays

I pass a dictionary of data from the iPhone to WatchKitExtension. What is the best way to turn the received Dictionary into two different item arrays? iPhone Data: let applicationDict = [“Item1” : data.item1, “Item2” : data.item2] let transfer =…
victorpulak
  • 131
  • 2
  • 8
1
vote
1 answer

Duplicating items already in array

Every time I run the app, and then re-run it, it saves the same items into the NSUserDefaults even if it is already there. I tried to fix that with contains code, but it hasn't worked. What am I missing? for days in results! { let nD =…
victorpulak
  • 131
  • 2
  • 8
1
vote
1 answer

Find adjacent boxes to a box in a 4x4 grid

I've an array with 1 to 16 numbers self.gridArray = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16", nil]; I am using this function to randomize or shuffle the array…
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116
1
vote
1 answer

Grab key/value pair from Array of NSDictionaries

My situation: I have an NSArray of NSDictionaries. The NSDictionary has 2 key/value pairs and I want to just want one of the key/value pairs. I want grab the key/value pair at index 0: What is the best method to accomplish this?
klmitchell2
  • 171
  • 2
  • 13
1
vote
1 answer

Filter NSArray with NSObject inside

I would like to use searchbar in my tableView. I have an NSArray with Person (NSObject). In cellForRow I'm using this code : Person *person = [[self.sectionedPersonName objectAtIndex:indexPath.section]…
Vjardel
  • 1,065
  • 1
  • 13
  • 28
1
vote
7 answers

How to create NSDictionary inside NSArray and How to access them in ios

I am new to iOS and want to create an NSArray like this which contains an NSDictionary. [ { Image: 1, 2,3 Title: 1,2,3 Subtitle:1,2,3 } ] I have tried this. NSArray *obj-image=@[@"Test.png",@"Test.png",@"Test.png"]; NSArray…
Khyati Vaishnav
  • 43
  • 1
  • 11
1
vote
1 answer

How to convert native Swift sets to NSArrays?

I have built a form(https://github.com/xmartlabs/Eureka) in my app and one of the input will obtain an Optional Set type. However,I need to push this set as an array to Parse for every user.But the array field in Parse only accepts NSArray as a…
Syed Ariff
  • 722
  • 2
  • 8
  • 26
1
vote
2 answers

Is possible to add some padding into an Array?

I was wandering..... Is possible to add some padding into an array? For example: if i have something like var array:[NSDate] = [] What kind of data can i put inside the array as padding to obtain an array of 5 elements like array[NSDate, padding,…
Swalsz
  • 33
  • 3
1
vote
2 answers

how to store old value and new value in same Nsmutablearray in ios

hi i am new in iOS developer. i have UITableView and UITextField. I set some different value in textfield and each textfield's value store in NSmutablearray than i display this array in next screen. Displayed array value is perfect. But my problem…
Jigar
  • 1,801
  • 1
  • 14
  • 29
1
vote
0 answers

Is this a memory leak in ARC when returning NSArray?

I have tried to find answers online and I did find a few relevant answers on SO, but I really want to confirm I understand it correctly (which maybe I don't) I have this code: - (NSArray*)arrayMethod { MPMediaQuery *albumArtistsQuery = [MPMediaQuery…
Lukas1
  • 582
  • 1
  • 5
  • 28
1 2 3
99
100