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

Objective-C arrayWithPlist (that's already in an NSString)

I have an NSString that already contains a pList. How do I turn it into an NSArray? (WITHOUT saving it to disk, only to reload it back with arrayWithContentsOfFile, and then have to delete it.) Where is the make arrayWithPlist or arrayWithString…
Patricia
  • 309
  • 3
  • 11
1
vote
3 answers

merging an nsarray into an nsset and avoiding duplicates in objective-c on iphone

Edit: better example... So I have an NSMutableSet of "existing" objects and I'd like to download JSON data, parse it, and merge these new objects with my existing ones, updating any duplicates with the newly downloaded ones. Here's what the existing…
taber
  • 3,166
  • 4
  • 46
  • 72
1
vote
1 answer

How to define a Swift protocol with a getter and setter for an Objective-C NSArray

I'm doing this for testing purposes. It helps with dependency injection. I have an Objective-C library that I've imported into my Swift 3 project. One of the classes in the Objective-C library is defined this way: @interface Auth :…
pachun
  • 926
  • 2
  • 10
  • 26
1
vote
1 answer

Parsing JSON in Objective-C using NSPredicates on Array

I have the following JSON within an array(array name - banksList) from which I want to get the branch names of "ORIENTAL BANK OF COMMERCE": <__NSArrayM 0x600000a4e820>( { ADDRESS = "PLOT NO.C/3/10-B,GIDCOPP. ASHOPALAV GUEST HOUSE,"; BANK =…
tech_human
  • 6,592
  • 16
  • 65
  • 107
1
vote
2 answers

NSArry of floats issue

Im trying to create an NSArray of floats. However, once the value is added to the arrays it is alway 0.0000000. What am i doing wrong? NSLog(@"percent: %f" , percent); prints the correct value and NSLog(@"timeArray: %f", [timeArray…
user346443
  • 4,672
  • 15
  • 57
  • 80
1
vote
3 answers

How to Add objectAtIndex:i of NSArray to NSMutableDictionary

How to Add objectAtIndex:i of NSArray to NSMutableDictionary i have tried for(int i=0 ;i<=[user count]; i++){ NSMutableDictionary * dict = [NSMutableDictionary :[user objectAtIndex:i]]; }
rva
  • 57
  • 1
  • 9
1
vote
1 answer

How to convert string to NSArray in iOS

I have a JSON object and it has a key value pair like this "AttachedDocument": "[{\"DocumentId\":354,\"DocumentName\":\"Screenshot_2016-04-15-00-35-11.png\",\"DocumentType\":\"image/png\"}]" This value is coming as a string. How can I convert that…
Irrd
  • 325
  • 1
  • 6
  • 18
1
vote
1 answer

What happen when "retain" NSArray or NSMutableArray?

In the source codes @property(retain) NSString* str; @sythesize str; self.str = newStr; I understand actually following will happen if( str != newStr ){ [str release]; str = [newStr retain]; } So how about the case for NSArray or…
Forrest
  • 122,703
  • 20
  • 73
  • 107
1
vote
2 answers

Autorelease object returned from NSArray?

I'm writing an NSArray category to include the -objectAtRandom message that returns an object from a random index (something similar to Python's choice). Should I autorelease this object before returning it? I believe I shouldn't, but I'm not…
cfischer
  • 24,452
  • 37
  • 131
  • 214
1
vote
2 answers

Swift 3 - sending the pointer of an optionally bound variable - iOS

I am currently converting my swift files to swift 3 and there is a runtime exception that involves pointers. Here is the code: var sectionChanges:NSArray? = nil var rowChanges:NSArray? = nil databaseView.getSectionChanges(§ionChanges!,…
Koushik Ravikumar
  • 664
  • 11
  • 26
1
vote
1 answer

unique values of custom object NSString property in nsarray

I have an array which stores custom objects. Objects are of type Venue which have a property defined as name(which contains the names of venue). Now I want to filter out objects with unique names. This is how I was trying to do. NSSet…
Asad Khan
  • 11,469
  • 13
  • 44
  • 59
1
vote
1 answer

Make arrays from excluding strings

I have 2 array of strings, lets say for simplicity it will be Array 1 - @[@"a",@"b",@"c"] and Array 2 will be - @[@"b",@"c", @"d"]. What i want is, to create an array from strings (yes, there will be strings, sometimes long enough, i put characters…
Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
1
vote
1 answer

how can I convert NSArray into specific String?

I'm using facebook-api to fetch user's friends. The code is as follows: let params = ["fields": "id"] let request = FBSDKGraphRequest(graphPath: "me/friends", parameters: params) request.startWithCompletionHandler { (connection :…
user3766930
  • 5,629
  • 10
  • 51
  • 104
1
vote
2 answers

how to Add multiple selected uitableviewcells to an empty uitableview cell in a same uitableviewcontroller

Hi I've 2 UITableviews (tableview1 and tableview2) in a UIViewController. I already loaded some arrays to tableview1 by using MVC method but kept tableview2 as empty. Anyway I need to load selected rows from tableview1 to tableview2 by tapping the…
Fido
  • 218
  • 1
  • 17
1
vote
4 answers

How do I properly create static NSArrays full of NSNumbers in Objective-C (Cocoa)?

Why is it that in the following code, I can not just simply make a static array of NSNumbers? I would just use C arrays and ints, but those cannot be copied and as you can see in init(), I have to copy the array to another one. The error I recieve…
Vexir
  • 11
  • 1
  • 2