Sorry about the weird title... all will be explained.
Basically I have an array/dictionary structure like this in my app:
NSArray {
NSDictionary {
(NSString *)id;
(NSDictionary *)dictionary;
}
NSDictionary {
(NSString *)id;
(NSDictionary *)dictionary;
}
NSDictionary {
(NSSt...
I have an NSArray of unknown items. I know there will always be more than 10 items.
I would like to assign all but the first 10 items to an NSString.
Something like:
NSString *itemString = (NSString*)[itemArray StartingIndex:10];
Is there a simple efficient way without iteration to accomplish this?
Thanks!
...
Hi friends
how can i remove duplicates in nsarray. for instance my array contains following data. I want to compare with adjacent dates to avoid duplicates but it throughs error.
Can anyone guide me what i am going wrong
calendar first-
(
2010-09-25 17:00:00 GMT,
"AAA",
2010-09-25 17:00:00 GMT,
"AAA",
2010-09-26 17:00:00 GMT,
"BBB"...
Hi folks,
The subject is vague because I'm not sure how to articulate in one sentence what I want.
Here goes:
I have an NSArray of NSDictionaries. Each NSDictionary represents one day of the calendar year. Each NSDictionary has a key "date" with a value of NSDate. There should be 365 NSDictionary items in the array. The dictiona...
Hi friends
Can anybody suggest which is the best way for using NSArray as two-dimensional array to store data for filtering data based on field.
Thanks in advance
Regards,
sathish
...
Possible Duplicate:
removing duplicates in nsarray
Hi friends,
I am storing the value in nsarray and i have to remove the duplicate dates.i mean exactly like this (14/12/2010,paid,15/12/2010,pending,15/12/2010,pending,16/12/2010,paid) should be (14/12/2010,paid,15/12/2010,pending,16/12/2010,paid). can any one suggest me the b...
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 is "Initializer element is not constant." It's very confusing; I'm not even sure what that ...
Hi, I am attempting to de-dupe an NSArray of NSDictionaries based on specific keys in the dictionaries. What I have looks something like this:
NSDictionary *person1 = [NSDictionary dictionaryWithObjectsAndKeys:@"John", @"firstName", @"Smith", "lastName", @"7898", @"employeeID"];
NSDictionary *person2 = [NSDictionary dictionaryWithObject...
If I have an NSArray (or mutable array) with several dictionary objects (each dictionary is a Person) like this:
[
{ forename: chris, surname: smith, age: 22 }
{ forename: paul, surname: smith, age: 24 }
{ forename: dave, surname: jones, age: 21 }
{ forename: alan, surname: jones, age: 26 }
{ forename: cecil, surname: reeves, ...
So, imagine you have a couple of arrays, Colors and Shapes, like this:
Colors: {
Yellow,
Blue,
Red
}
Shapes: {
Square,
Circle,
Diamond
}
Now, if I want to sort Colors into alphabetical order I can do something like this:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(loc...
Hello,
I have been trying to figure out if it is possible to programmatically resize an NSArray, by code similar to this:
NSArray *resize = [NSArray arrayResized:oldarray size:10];
Which would a new NSArray (Not a NSMutableArray if it is possible) that has the elments after the end of oldarray padded with [NSNull null].
...
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 *uniqueVenuesSet = [NSSet setWithArray:[venueArray valueForKey:@"name"]];
NSMutableArray *uniqueVe...
I have an array with custom objects. Each array item has a field named "name". Now I want to remove duplicate entries based on this name value.
How should I go about achieving this.
Thanks in advance.
...
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 sure...
...
(hmm.. long title)
If I start out with an NSArray of custom objects (each object is a Person) like this:
{
surname:Allen forename: Woody,
surname:Baxter forename: Stanley,
surname:Clay forename: Cassius
}
..etc..
You can see that the array is already in surname order. How do I use that array to create a a UITableView wit...
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 NSMutableArray ? Seem like it is complex,shallow copy and deep copy should be considered.
...
Hi, 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 objectAtIndex:i]); is always 0.00000.
NSMutableArray *timeArray = [[NSMutableArray alloc] ...
A couple of questions regarding the following code:
@implementation NSArray (Find)
- (NSArray *)findAllWhereKeyPath:(NSString *)keyPath equals:(id)value {
NSMutableArray *matches = [NSMutableArray array];
for (id object in self) {
id objectValue = [object valueForKeyPath:keyPath];
if ([objectValue isEqual:value] || objec...
Hi !
I'm a bit stuck in a project.
I was writing some code to get a JSON file and store it in an NSString before parsing it into a NSArray.
But I get an error:
2010-10-27 20:59:44.813 GeraldKervyn[21752:207] -JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading chara...
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 set of objects looks like:
NSArray *savedObjects = [NSArray arrayWithObjects:
[NSD...