__NSSingleObjectArrayI in Coredata - objective-c

I am working with Coredata. i have an relation with the entity when i fetch my relation it gives the NSSet and i Convert this to NSMutableArray with AllObjects. The issue it gives me __NSSingleObjectArrayI instead of NSMutableArray. Can any one please help me on this. Thanks
Tired Code :-
NSSet *arrPayment = [[[dictPaymentData allValues] valueForKey:#"paymentToInvoice"] valueForKey:#"invoiceToPeople"];
NSMutableArray *arrData = [NSMutableArray arrayWithArray:[arrPayment allObjects]];
This is my __NSSingleObjectArrayI Code :-
<__NSArrayM 0x6000018464f0>(
<__NSSingleObjectArrayI 0x600000a8bdd0>(
{(
<People: 0x600002b44370> (entity: People; id: 0x91782a4d7073f8e8 <x-coredata://0785667E-51C4-4C34-B696-C4374F6315D4/People/p630> ; data: {
archiveStatus = 0;
defaultTerms = 30;
email = nil;
extra1 = nil;
extra2 = nil;
extra3 = nil;
faxNo = nil;
firstName = nil;
from = nil;
fromid = 0;
homeNo = nil;
internalNotes = nil;
lastName = nil;
mobileNO = nil;
modificationDate = "2019-01-17 11:58:50 +0000";
organization = Yogesh;
peopleId = 0;
"sa_City" = nil;
"sa_Country" = nil;
"sa_State" = nil;
"sa_Street1" = nil;
"sa_Street2" = nil;
"sa_Zip" = nil;
selectedCurrency = "en_US";
signature = nil;
sortingString = nil;
status = Cactive;
syncID = nil;
uniqueIdentifier = "6A819F69-DCB0-4B6C-BE60-03151B23541D-3341-0000043F5397E622";
userId = nil;
vatNo = nil;
})
)}
)
)
,

valueForKey: has a special behavior. Applied to an array it returns always an array of all values for the given key.
You are better off using objectForKey:

Related

How to obtain Home City from Contacts Framework in iOS +9?

I am replacing my obsolete ABAdressBook code with the current CNContact framework in Objective C. I could sort out most of it, except for the Home City part, so lets focus on that.
Currently I have this code:
-(NSArray *)getLandAddressesForContactIOS6:(ABRecordRef)recordRef {
ABMultiValueRef addresses = ABRecordCopyValue(recordRef, kABPersonAddressProperty);
NSMutableArray *formattedAddressesResponse = [NSMutableArray array];
for(CFIndex i = 0; i < ABMultiValueGetCount(addresses); i++) {
NSString *label = (__bridge NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(addresses, i));
NSDictionary *addressComponents = (__bridge NSDictionary*)ABMultiValueCopyValueAtIndex(addresses, i);
NSString *street = [addressComponents objectForKey:(NSString *)kABPersonAddressStreetKey];
NSString *city = [addressComponents objectForKey:(NSString *)kABPersonAddressCityKey];
NSString *formattedAddress = ABCreateStringWithAddressDictionary(addressComponents, YES);
NSMutableDictionary *currentAddressResponse = [NSMutableDictionary dictionaryWithObjectsAndKeys:
label, #"type",
label, #"label",
nil];
if (street != nil) {
[currentAddressResponse setObject:street forKey:#"street"];
}
if (city != nil) {
[currentAddressResponse setObject:city forKey:#"city"];
}
if (formattedAddress != nil) {
[currentAddressResponse setObject:formattedAddress forKey:#"formattedAddress"];
}
[formattedAddressesResponse addObject:currentAddressResponse];
}
return formattedAddressesResponse;
}
That code is deprecated for iOS 9+ so the closest I have got to get the home city with the new Contacts framework is:
-(NSArray *)getLandAddressesForContactIOS10:(CNContact*)recordRef {
NSArray <CNLabeledValue<CNPostalAddress *> *> *addresses = recordRef.postalAddresses;
NSMutableArray *formattedAdressResponse = [NSMutableArray array];
for(CFIndex i = 0; i < addresses.count; i++) {
CNLabeledValue *addressi = [addresses objectAtIndex:i];
//NSString *city = addressi.??????; //Stuck here, don't know what else to do
How can I extract the City name from a CNContact??
-(void )getLandAddressesForContactIOS10:(CNContact*)contact
{
for (CNLabeledValue<CNPostalAddress*>* labeledValue in contact.postalAddresses)
{
NSLog(#"%#",labeledValue.value.city);
NSLog(#"%#",labeledValue.value.street);
NSLog(#"%#",labeledValue.value.state);
NSLog(#"%#",labeledValue.value.postalCode);
NSLog(#"%#",labeledValue.value.ISOCountryCode);
}
}
NSArray *addresses = (NSArray*)[contact.postalAddresses valueForKey:#"value"];
if (!(addresses == nil) && addresses.count > 0)
{
for (CNLabeledValue<CNPostalAddress*>* labeledValue in contact.postalAddresses)
{
NSString *city = labeledValue.value.city;
NSLog(#"City = %#",city);
NSString *street = labeledValue.value.street;
NSLog(#"Street = %#",street);
NSString *state = labeledValue.value.state;
NSLog(#"State = %#",state);
NSString *postalCode = labeledValue.value.postalCode;
NSLog(#"PostalCode = %#",postalCode);
NSString *ISOCountryCode = labeledValue.value.ISOCountryCode;
NSLog(#"ISOCountryCode = %#",ISOCountryCode);
}
}
else
{
NSLog(#"No addresses for name = %#",strname);
}

breaking up a single array object into many objects

Apologies if this is a novice question, but I've been struggling to figure this out with no luck. I'm trying to pull a users' twitter timeline using the AFOAuth2Manager framework. Everything makes sense except the returned JSON object is an array and the entire object is one giant object. I obviously want to break it up into different elements and store them in a dictionary, but have not been able to figure it out so far.
This is a VERY partial example of what the array object looks like. The complete object is this with about 20 or so more tweets with this format attached. I will post the entire json object if requested, but it seems pretty pointless to post the entire thing.
Heres my code:
[manager GET:#"/1.1/statuses/user_timeline.json?screen_name=jack"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject ) {
self.object = responseObject;
NSLog(#"Success: %#", responseObject);
if ([responseObject isKindOfClass:[NSArray class]]) {
NSLog(#"object is a nsarray class");
} else if ([responseObject isKindOfClass:[NSDictionary class]]){
NSLog(#"object is a nsdictionary class");
} else {
NSLog(#"object is a different class");
}
NSArray *response = [NSArray arrayWithObject:responseObject];
NSLog(#"count %ld", [response count]);
NSData *dataFromTwitter = [NSKeyedArchiver archivedDataWithRootObject:self.object];
NSError *parseError = nil;
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:dataFromTwitter
options:NSJSONReadingMutableLeaves | NSJSONReadingMutableContainers|NSJSONReadingAllowFragments
error:&parseError];
NSLog(#"response Dict: %#", responseDict);
NSError *e = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:dataFromTwitter
options:NSJSONReadingAllowFragments
error:&e];
NSLog(#"jsonArray: %#", jsonArray);
NSError *jsonError2 = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:dataFromTwitter
options:NSJSONReadingAllowFragments
error:&jsonError2];
if ([jsonObject isKindOfClass:[NSArray class]]) {
NSLog(#"its an array!");
NSArray *jsonArray = (NSArray *)jsonObject;
NSLog(#"jsonArray2 - %#",jsonArray);
}
else {
NSLog(#"its probably a dictionary");
NSDictionary *jsonDictionary = (NSDictionary *)jsonObject;
NSLog(#"jsonDictionary - %#",jsonDictionary);
NSLog(#"error %#", jsonError2);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Failure: %#", error);
}];
{
contributors = "<null>";
coordinates = "<null>";
"created_at" = "Mon Feb 29 01:18:05 +0000 2016";
entities = {
hashtags = (
);
symbols = (
);
urls = (
);
"user_mentions" = (
{
id = 14616957;
"id_str" = 14616957;
indices = (
0,
7
);
name = "Jason Del Rey";
"screen_name" = DelRey;
},
{
id = 19040598;
"id_str" = 19040598;
indices = (
8,
18
);
name = "\U0ca0_\U0ca0";
"screen_name" = MikeIsaac;
},
{
id = 46063;
"id_str" = 46063;
indices = (
19,
30
);
name = "Hunter Walk";
"screen_name" = hunterwalk;
}
);
};
"favorite_count" = 12;
favorited = 0;
geo = "<null>";
id = 704113377920978944;
"id_str" = 704113377920978944;
"in_reply_to_screen_name" = DelRey;
"in_reply_to_status_id" = 704112911116013568;
"in_reply_to_status_id_str" = 704112911116013568;
"in_reply_to_user_id" = 14616957;
"in_reply_to_user_id_str" = 14616957;
"is_quote_status" = 0;
lang = en;
place = "<null>";
"retweet_count" = 0;
retweeted = 0;
source = "Twitter for iPhone";
text = "#DelRey #MikeIsaac #hunterwalk this changes everything";
truncated = 0;
user = {
"contributors_enabled" = 0;
"created_at" = "Tue Mar 21 20:50:14 +0000 2006";
"default_profile" = 0;
"default_profile_image" = 0;
description = "#withMalala!";
entities = {
description = {
urls = (
);
};
};
"favourites_count" = 11433;
"follow_request_sent" = "<null>";
"followers_count" = 3458722;
following = "<null>";
"friends_count" = 1859;
"geo_enabled" = 1;
"has_extended_profile" = 1;
id = 12;
"id_str" = 12;
"is_translation_enabled" = 0;
"is_translator" = 0;
lang = en;
"listed_count" = 25944;
location = "California, USA";
name = Jack;
notifications = "<null>";
"profile_background_color" = EBEBEB;
"profile_background_image_url" = "http://abs.twimg.com/images/themes/theme7/bg.gif";
"profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme7/bg.gif";
"profile_background_tile" = 0;
"profile_image_url" = "http://pbs.twimg.com/profile_images/668328458519384064/FSAIjKRl_normal.jpg";
"profile_image_url_https" = "https://pbs.twimg.com/profile_images/668328458519384064/FSAIjKRl_normal.jpg";
"profile_link_color" = 990000;
"profile_sidebar_border_color" = DFDFDF;
"profile_sidebar_fill_color" = F3F3F3;
"profile_text_color" = 333333;
"profile_use_background_image" = 1;
protected = 0;
"screen_name" = jack;
"statuses_count" = 19066;
"time_zone" = "Pacific Time (US & Canada)";
url = "<null>";
"utc_offset" = "-28800";
verified = 1;
};
},
You show no code in your question, in a comment you state you have a responseObject but not how you came by it.
The JSON you are getting from somewhere will be text, you may have it as an NSString, NSData, an NSArray whose elements are these, etc.
You need to obtain that text and then parse it as JSON, the NSJSONSerialization class will handle the parsing for you, the first line of its description states:
You use the NSJSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON.
Once you have those Foundation objects - arrays, dictionaries, strings, numbers, etc. you can extract the fields you are interested in.
Once you've written some code to do this if it doesn't work and you are stuck ask a new question showing your code and someone will probably be able to help you further.
HTH

Get all keys of a multidimensional dictionary

I have a dictionary like:
{
dataTypes = (
{
dataType = "datatype1";
editable = 1;
maxValue = 300;
minValue = 0;
order = 1;
title = "Title 1";
type = numeric;
units = kg;
},
{
dataType = "datatype 2";
editable = 1;
maxValue = 300;
minValue = 0;
order = 2;
title = "title2";
type = numeric;
units = gm;
},
{
dataType = "datatype3";
editable = 1;
maxValue = 300;
minValue = 20;
order = 3;
title = "title3";
type = numeric;
units = kg;
}
);
name = "Name";
order = 1
title = "Title";
}
I want to get all keys within this dictionary.
I tried [myDict allKeys], however this is returning only four keys: DataTypes, name, order, title.
I want to retrieve all keys: dataType, editable, maxvalue, etc.
Try this.
NSArray *tempArray = [myDict objectForKey:#"dataTypes"];
NSDictionary *tempDictionary = (NSDictionary *)tempArray[0];
[tempDictionary allKeys] will have what you want.
Write this method.
- (NSDictionary *)dictionaryFromArrayWithinDictionary:(NSDictionary *)dictionary withKey:(NSString *)key{
NSArray *tempArray = [dictionary objectForKey:key];
return (NSDictionary *)tempArray[0];
}
This will return the inner dictionary and simply calling `allKeys' on this dictionary, you will get all the keys you want.
You need to recursively walk through your dictionary, and through any arrays the dictionary might contain, and so on. This can be nicely done via a recursiveKeys method added to all objects, which returns an empty array for objects that are not containers, and walks though the container for objects that are containers:
#interface NSObject(MyCategory)
- (NSArray)recursiveKeys;
#end
#implementation NSObject(MyCategory)
- (NSArray)recursiveKeys {
return #[];
}
#end
#implementation NSArrray(MyCategory)
- (NSArray)recursiveKeys {
NSMutableArray *result = [NSMutableArray array];
for (id item in self) {
[result addObjectsFromArray:[item recursiveKeys]];
}
return [result copy]; //return an immutable array
}
#end
#implementation NSSet(MyCategory)
- (NSArray)recursiveKeys {
NSMutableArray *result = [NSMutableArray array];
for (id item in self) {
[result addObjectsFromArray:[item recursiveKeys]];
}
return [result copy]; //return an immutable array
}
#end
#implementation NSDictionary(MyCategory)
- (NSArray)recursiveKeys {
NSMutableArray *result = [self.allKeys mutableCopy];
for (id key in self) {
[result addObjectsFromArray:[self[key] recursiveKeys];
}
return [result copy]; //return an immutable array
}
#end
You can use it like this:
NSArray *keys = myDictionary.recursiveKeys;
Please pardon any syntax errors, I don't have at this time an Xcode in front of me, I simply typed the code here on SO.

How to mapping array in YAPdatabase object?

i have test array with objects structure - Group with (NSMutableArray)items, and i save group in YapDatabase
-(void)parseAndSaveJson:(id) json withCompleteBlock:(void(^)())completeBlock{
NSMutableArray *groupsArray = (NSMutableArray *)json;
if (groupsArray != nil) {
YapDatabaseConnection *connectnion = [[DatabaseManager sharedYapDatabase] newConnection];
[connectnion asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
for (int groupIndex = 0; groupIndex < [groupsArray count]; groupIndex ++) {
LocalGroupsExercise *localGroup = [[LocalGroupsExercise alloc] init];
localGroup.name = groupsArray[groupIndex][LOCAL_GROUPS_NAME];
localGroup.tagColor = groupsArray[groupIndex][LOCAL_GROUPS_TAG_COLOR];
localGroup.idGroup = [groupsArray[groupIndex][LOCAL_GROUPS_ID_GROUP] intValue];
if (groupsArray[groupIndex][LOCAL_GROUPS_EXERCISES] != nil) {
NSMutableArray *exerciseArray = (NSMutableArray *)groupsArray[groupIndex][LOCAL_GROUPS_EXERCISES];
for (int exerciseIndex = 0; exerciseIndex < [exerciseArray count]; exerciseIndex ++) {
LocalExercise *localExercise = [[LocalExercise alloc] init];
localExercise.name = exerciseArray[exerciseIndex][EXERCISE_NAME];
localExercise.exerciseId = [exerciseArray[exerciseIndex][LOCAL_EXERCISE_ID_EXERCISE] intValue];
localExercise.groupId = localGroup.idGroup;
localExercise.type = [exerciseArray[exerciseIndex][EXERCISE_TYPE] intValue];
localExercise.minWeight = [exerciseArray[exerciseIndex][EXERCISE_MIN_WEIGHT] floatValue];
localExercise.maxWeight = [exerciseArray[exerciseIndex][EXERCISE_MAX_WEIGHT] floatValue];
localExercise.minReps = [exerciseArray[exerciseIndex][EXERCISE_MIN_REPS] intValue];
localExercise.maxReps = [exerciseArray[exerciseIndex][EXERCISE_MAX_REPS] intValue];
localExercise.minTimer = [exerciseArray[exerciseIndex][EXERCISE_MIN_TIMER] intValue];
localExercise.maxTimer = [exerciseArray[exerciseIndex][EXERCISE_MAX_TIMER] intValue];
localExercise.timeRelax = [exerciseArray[exerciseIndex][EXERCISE_RELAX_TIME] intValue];
[localGroup.exercises addObject:localExercise];
}
}
[transaction setObject:localGroup forKey:[NSString stringWithFormat:#"%d", localGroup.idGroup] inCollection:LOCAL_GROUPS_CLASS_NAME];
}
YapDatabaseConnection *connectnion = [[DatabaseManager sharedYapDatabase] newConnection];
[connectnion readWithBlock:^(YapDatabaseReadTransaction *transaction) {
LocalGroupsExercise *group = [transaction objectForKey:#"2" inCollection:LOCAL_GROUPS_CLASS_NAME];
NSLog(#"%#", group.name);
NSLog(#"%#", group.tagColor);
NSLog(#"%#", group.exercises);
}];
} completionBlock:^{
completeBlock();
}];
}
}
+ (YapDatabaseView *)setupDatabaseViewForShowGroupsGyms{
YapDatabaseViewGrouping *grouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *(YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) {
if ([object isKindOfClass:[LocalGroupsExercise class]]) {
LocalGroupsExercise *groupExercise = (LocalGroupsExercise *)object;
return [NSString stringWithFormat:#"%#", groupExercise.name];
}
return nil;
}];
YapDatabaseViewSorting *sorting = [YapDatabaseViewSorting withObjectBlock:^NSComparisonResult(YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection1, NSString *key1, LocalGroupsExercise *obj1, NSString *collection2, NSString *key2, LocalGroupsExercise *obj2) {
return [obj1.name compare:obj2.name options:NSNumericSearch range:NSMakeRange(0, obj1.name.length)];
}];
YapDatabaseView *databaseView = [[YapDatabaseView alloc] initWithGrouping:grouping sorting:sorting versionTag:#"0"];
return databaseView;
}
[[DatabaseManager sharedYapDatabase] registerExtension:self.databaseGroupView withName:LOCAL_GROUPS_CLASS_NAME];
[_connection beginLongLivedReadTransaction];
self.mappingsGroup = [[YapDatabaseViewMappings alloc] initWithGroupFilterBlock:^BOOL(NSString *group, YapDatabaseReadTransaction *transaction) {
return true;
} sortBlock:^NSComparisonResult(NSString *group1, NSString *group2, YapDatabaseReadTransaction *transaction) {
return [group1 compare:group2];
} view:LOCAL_GROUPS_CLASS_NAME];
[_connection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[self.mappingsGroup updateWithTransaction:transaction];
}];
The problem is that the group be NSMutabblArray and I want to see the objects in the table of the array, but [self.mappingsGroup numberOfItemsInSection:section] return only one items in group
You need to configure YapDatabase to use Mantle. By default, it will use NSCoding. (Which is why you're seeing an error about "encodeWithCoder:", as that method is part of NSCoding.)
Take a look at YapDatabase's wiki article entitled "Storing Objects", which talks about how it uses the serializer/deserializer blocks: https://github.com/yaptv/YapDatabase/wiki/Storing-Objects
Basically, when you alloc/init your YapDatabase instance, you'll want to pass a serializer & deserializer block that uses Mantle to perform the serialization/deserialization.
Also, see the various init methods that are available for YapDatabase: https://github.com/yaptv/YapDatabase/blob/master/YapDatabase/YapDatabase.h

Searching array kept in NSDictionary

I am having a requirement in which I have 5 keys stored in a NSDictionary corresponding to which I have stored 5 values from different arrays. My data structure looks like:
Dictionary is {
1 = (
{
SubRegionName = "abc";
WalkId = 123;
WalkName = xyz;
},
{
},....
2 = (
{
SubRegionName = "abc";
WalkId = 123;
WalkName = xyz;
},
{
},....
3 = (
{
SubRegionName = "abc;
WalkId = 123;
WalkName = xyz;
},
{
},....
4 = (
{
SubRegionName = "abc";
WalkId = 123;
WalkName = xyz;
},
{
},....
5 = (
{
SubRegionName = "abc";
WalkId = 123;
WalkName = xyz;
},
{
},
)
The above data I am getting from sqlite according to some Id say tempId(1,2,3,4,5) and I want to use them separately. As I have to display the walkName as cell.textlabel.text and SubregionName as cell.detailtext.text in tableview.
I am not getting how to access this data from the dictionary. Can anyone please suggest me right way to do it.
My code is:
// For Database queries (To get data from database) ***********
-(void)getMainRegions
{
sqlite3 *walkNameDB;
if (sqlite3_open([[self databasePath] UTF8String], &walkNameDB) != SQLITE_OK) {
sqlite3_close(walkNameDB);
NSAssert(0, #"Failed to open Walk name database");
}
NSString *regionQuery = #"SELECT Rid,RName from MainRegions";
sqlite3_stmt *teststatement = nil;
// NSLog(#"%d",sqlite3_prepare_v2(walkNameDB,[regionQuery UTF8String], -1, &teststatement, nil));
if (sqlite3_prepare_v2(walkNameDB,[regionQuery UTF8String], -1, &teststatement, nil) == SQLITE_OK)
{
RNameArray = [[NSMutableArray alloc] init];
RIdArray = [[NSMutableArray alloc] init];
while( sqlite3_step(teststatement) == SQLITE_ROW )
{
NSNumber *RId;
int temp1 = (int)sqlite3_column_int(teststatement, 0);
RId = [[NSNumber alloc] initWithInt:temp1];
char *RNameCharacter;
RNameCharacter = (char *) sqlite3_column_text(teststatement, 1);
NSString *RNameString = [[NSString alloc] initWithUTF8String:RNameCharacter];
[RNameArray addObject:RNameString];
[RIdArray addObject:RId];
}
}
[self getWalks];
}
-(void)getWalks
{
sqlite3 *walkNameDB;
if (sqlite3_open([[self databasePath] UTF8String], &walkNameDB) != SQLITE_OK) {
sqlite3_close(walkNameDB);
NSAssert(0, #"Failed to open Walk name database");
}
RegionWalksDictionary = [[NSMutableDictionary alloc] init];
for(regionId in RIdArray)
{
regionWalkArray = [[NSMutableArray alloc] init];
NSString *walkQuery = [[NSString alloc] initWithFormat:#"SELECT Wid,WName,SName from Walks,SubRegions WHERE Walks.Sid=SubRegions.Sid AND Rid = %d",[regionId integerValue] ];
sqlite3_stmt *walkstatement = nil;
// NSLog(#"%d",sqlite3_prepare_v2(walkNameDB,[walkQuery UTF8String], -1, &walkstatement, nil));
if (sqlite3_prepare_v2(walkNameDB,[walkQuery UTF8String], -1, &walkstatement, nil) == SQLITE_OK)
{
while( sqlite3_step(walkstatement) == SQLITE_ROW )
{
NSNumber *WId;
int temp1 = (int)sqlite3_column_int(walkstatement, 0);
WId = [[NSNumber alloc] initWithInt:temp1];
char *WNameCharacter;
WNameCharacter = (char *) sqlite3_column_text(walkstatement, 1);
NSString *WNameString = [[NSString alloc] initWithUTF8String:WNameCharacter];
char *SNameCharacter;
SNameCharacter = (char *) sqlite3_column_text(walkstatement, 2);
NSString *SNameString = [[NSString alloc] initWithUTF8String:SNameCharacter];
NSMutableDictionary *tempWalk = [[NSMutableDictionary alloc] init];
[tempWalk setObject:WId forKey:#"WalkId"];
[tempWalk setObject:WNameString forKey:#"WalkName"];
[tempWalk setObject:SNameString forKey:#"SubRegionName"];
[regionWalkArray addObject:tempWalk];
}
}
[RegionWalksDictionary setObject:regionWalkArray forKey:regionId];
// NSLog(#"arr%#",RegionWalksDictionary);
}
}
//*** Methods to get data from database ends here **************
Try this way...
for(id dict in RegionWalksDictionary){
NSLog(#"WalkId: %#",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:#"WalkId"] );
NSLog(#"WalkName: %#",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:#"WalkName"] );
NSLog(#"SubRegionName: %#",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:#"SubRegionName"] );
NSLog(#"----");
}
I have used as following (comment if this is not the structure or your data)
NSMutableDictionary *RegionWalksDictionary=[NSMutableDictionary new];
NSMutableArray *regionWalkArray=[NSMutableArray new];
NSMutableDictionary *tempWalk=[NSMutableDictionary new];
[tempWalk setObject:#"wk1" forKey:#"WalkId"];
[tempWalk setObject:#"wkName1" forKey:#"WalkName"];
[tempWalk setObject:#"srName1" forKey:#"SubRegionName"];
[regionWalkArray addObject:tempWalk];
[RegionWalksDictionary setObject:regionWalkArray forKey:#"1"];
[RegionWalksDictionary setObject:regionWalkArray forKey:#"2"];
[RegionWalksDictionary setObject:regionWalkArray forKey:#"3"];
NSLog(#"tempWalkd dict is %#",RegionWalksDictionary);
try this
NSString * walkName = [[parentDic objectForKey:[NSString stringWithFormat:#"%d",indexPath.row]] objectForKey:#"WalkName"];
NSString * SubregionName = [[parentDic objectForKey:[NSString stringWithFormat:#"%d",indexPath.row]] objectForKey:#"SubRegionName"];
It seems you have an NSDictionary with your 5 keys, and inside that you have an NSArray with a single element that is a NSDictionary. Although I might be wrong, try this:
NSDictionary *dictionaryForKey1 = [[myDictionary objectForKey:#"1"] objectAtIndex:0];
You can then use this:
NSString *walkName = [dictionaryForKey1 objectForKey:#"WalkName"];
AH! now I see it -- there are 5 arrays of length 1
NSArray *array1 = dict[#"1];
NSDictionary *details = array1[0];
//print each var
id WalkName = details[#"WalkName"];