ios - Add PFObject from an NSMutableArray to a new NSMutableDictionary -


my problem following:

i run for-loop in nsmutablearray created nsmutabledicitonary , add nsmutabledictionary.

how initialize arrays , dictionaries:

activitespermonth = [[nsmutabledictionary alloc] init]; activitesseperateddate = [[nsmutabledictionary alloc] init];  self.activityobjects = [nsmutablearray array]; self.gatherandholdobjects = [nsmutablearray array]; 

what do:

nsstring *stringdayonly = [dayonly stringfromdate:selecteddate]; nslog(@"%d, %d, %d aaand stringdayonly %@", day, month, year, stringdayonly);  (pfobject *activity in self.gatherandholdobjects){     activitesseperateddate[activity[@"day"]] = activity; }  nsmutablearray *storefromdiction = activitesseperateddate[stringdayonly];  self.activityobjects = [nsmutablearray arraywitharray:storefromdiction]; //self.activityobjects = [nsmutablearray arraywitharray:self.gatherandholdobjects]; [self.activitytableview reloaddata]; 

self.gatherandholdobjects populated this:

pfquery *activitesformonth = [pfquery querywithclassname:@"calendaractivities"];     [activitesformonth wherekey:@"month" equalto:self.displayedmonth];     [activitesformonth findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {         if (!error) {             activitespermonth[self.displayedmonth] = objects;             self.gatherandholdobjects = activitespermonth[self.displayedmonth];         }     }]; 

when try populate self.activitytableview self.gatherandholdobjects works fine! populate self.activitytableview storefromdiction error:

-[pfobject count]: unrecognized selector sent instance 0x14edd940

*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[pfobject count]: unrecognized selector sent instance

what should populate self.activitytableview storefromdiction not error?

thanks in advance!

this line :

activitesseperateddate[activity[@"day"]] = activity;

assigns pfobject entry in activitesseperateddate dictionary

and line

nsmutablearray *storefromdiction = activitesseperateddate[stringdayonly];

retrieves 1 of entries , assigns nsmutablearray instance. objective-c let though makes no sense -it not check object assigned variable of correct type. have nsmutablearray variable contains pfobject. when try treat array (by sending -count it, unrecognized selector error.

using dictionaries store parse objects date key implies ever have 1 pfobject per date- dictionaries can store 1 item per key. either use different form of storage, or make entries in dictionary arrays, mapping dates arrays of pfobject - e.g.

for (pfobject *activity in self.gatherandholdobjects) {     nsstring *daykey = activity[@"day"];     nsmutablearray *objectsfordate = self.activitiesseparatedbydate[daykey];     if(objectsfordate == nil) //instantiate array if doesn't exist     {          objectsfordate = [[nsmutablearray alloc]init];          self.activitiesseparatedbydate[daykey] = objectsfordate;     }      [objectsfordate addobject:activity] } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -