Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have an array storing some attributes (those attributes are: tableID(string), tables coordinate(x,y coordinate in float)). Does anyone know how to store this array into NSMutableDictionary? And I need this NSMutableDictionary transfer into JSON string.
You can Simply set ur MUtable Array in MUtable Dictionary like
NSMutableDictionary *muteDict = [[NSMutableDictionary alloc] init];
[muteDict setObject:mutableArrayObject forKey:#"YourKey"];
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Given an NSSet what is the best way to get an NSMutableSet with those same objects?
To be clear if you have an instance of NSSet what would be the most performant and simple way to get an NSMutable set with those same objects?
There are 2 ways to achieve it.
Use mutableCopy
Objective-C
NSMutableSet* mutableSet2 = [YOUR_SET mutableCopy];
Swift
let mutableSet = YOUR_SET.mutableCopy()
Use setWithSet:
Objective-C
NSMutableSet* mutableSet = [NSMutableSet setWithSet:YOUR_SET];
Swift
let mutableSet = NSMutableSet.init(set: YOUR_SET)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Simple as that, how do I save an Integer for score after the user has restarted the app. I'm trying to use SpriteKit for everything, so keep that in mind. I've tried NSUserDefaults but it doesn't seem to be working.
As msgambel points out below, you can save integers directly into NSUserDefaults via something like:
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:#"one"];
And separately, if you put an integer into a "NSNumber" object (i.e. an Objective C object), you can save these in NSUserDefaults or include these objects in arrays or dictionaries.
Check out [NSNumber numberWithInteger:]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want the name of method of nsmutablearray which return the object at the given index and then remove this object from index and then sort the array accordingly.
Well, you're looking for two different things. To retrieve the object at a specific index in an array, you use -[NSMutableArray objectAtIndex:]. To remove an object at a specific index you use -[NSMutableArray removeObjectAtIndex:].
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have two NSArrays and I would like to change one object in the first NSArray with another object in the second NSArray.
This is what I tried to do, but with no luck:
[[arrrndwords objectsinindex:i] replace object in index:1 with:[arrword indexinobject:rndnum]];
It throws me out of the app when I run it.
The method you are looking for is:
- (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(NSArray *)objects
but it is not available to NSArray because it's immutable, you should use a NSMutableArray.
[array replaceObjectsAtIndex:[NSIndexSet indexSetWithIndex:1] withObjects:[NSArray arrayWithObject:yourObject]]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
If i have a string like /Users/me/Documents/code/maccode/myApp/Icon.png
what should I do to be left only with "Icon.png"?
Using xcode and programming a mac application with objective c.
Thanks in advance.
NSString *filename = #"/Users/me/Documents/code/maccode/myApp/Icon.png";
NSString *path = [filename lastPathComponent];
That will give you Icon.png