Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot add another object into an array containing different objects
    primarykey
    data
    text
    <p>Someone please help.</p> <p>I am a noob here who has just created an array to contain all my polyclinics object. Now I need to add in a user object (patientDetail object) into this array. But no matter how i modify the viewDidLoad method, something just seems not quite right.. i cannot populate all the points.. only when i remove all codes that deal with the user object then it works.. Some1 please take a look at the method below and advise? I need to add in the patientDetail object and populate it with the rest of the polyclinics...</p> <p>thanks for reading =(</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; _annotation2 = [[NSMutableArray alloc] init]; CLLocation *userLoc = _mapView.userLocation.location; CLLocationCoordinate2D userCoordinate = userLoc.coordinate; NSLog(@"user latitude = %f",userCoordinate.latitude); NSLog(@"user longitude = %f",userCoordinate.longitude); _annotations=[[NSMutableArray alloc] init]; _listOfPolyClinics = [[NSMutableArray alloc] init]; PatientDetails *patientDetails = [[PatientDatabase database] patientDetails:_nric]; for (PolyClinics *polyclinics in [[PatientDatabase database] polyClinics]){ [_listOfPolyClinics addObject:polyclinics]; } [_listOfPolyClinics addObject:patientDetails]; for (PolyClinics *polyclinics1 in _listOfPolyClinics){ MyAnnotation* myAnnotation=[[MyAnnotation alloc] init]; if ([polyclinics1 isKindOfClass:[PatientDetails class]]){ CLLocationCoordinate2D theCoordinate3; theCoordinate3.longitude = patientDetails.longitude; theCoordinate3.latitude = patientDetails.latitude; myAnnotation.coordinate = theCoordinate3; myAnnotation.title = _nric; myAnnotation.subtitle = [NSString stringWithFormat:@"%i",patientDetails.category]; } else{ CLLocationCoordinate2D theCoordinate; theCoordinate.longitude = polyclinics1.longtitude; NSLog(@"Halo"); theCoordinate.latitude = polyclinics1.latitude; NSLog(@"bye"); //myAnnotation.pinColor = MKPinAnnotationColorPurple; myAnnotation.coordinate = theCoordinate; myAnnotation.title = polyclinics1.name; myAnnotation.subtitle = [NSString stringWithFormat:@"%i",polyclinics1.telephone]; } [_mapView addAnnotation:myAnnotation]; [_annotation2 addObject:myAnnotation]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload