0

I have a NSArray having below data and want to convert it to NSDictionary in the format that follows. The array has only [0] and the data belongs to that index only. The reason why the dictionary should have this format is a web service that accepts only this format. The array fetches data from Core DB and then i have to send it to the web service.

<MatchDayChecklist: 0xa6a04c0> (entity: MatchDayChecklist; id: 0xa69eee0 <x-coredata://2A66067E-8B0D-4BAC-857D-E6C71906270C/MatchDayChecklist/p2> ; data: {
    acceptDeclaration = 1;
    actions = Df;
    authorisedRep = 1;
    awayAssociationId = 18;
    awayClubId = 7;
    awayTeamName = Sdf;
    awayTeamRepName = Df;
    awayTeamRepPosition = df;
    createDate = "2014-03-19 09:09:13 +0000";
    firstAidFacilityAccessible = 1;
    groundMarkingsAcceptable = 0;
    homeAssociationId = 18;
    homeClubId = 7;
    homeTeamName = E;
    homeTeamRepName = Df;
    homeTeamRepPosition = Df;
    inspectionDate = "2014-03-19 09:08:00 +0000";
    matchDayChecklistid = 1;
    matchVenue = Sdf;
    perimeterFencesFreeOfHazard = 1;
    photo = "<relationship fault: 0xa7ae630 'photo'>";
    photoThumbs = "<relationship fault: 0xa7ae880 'photoThumbs'>";
    playSurfaceAcceptable = 0;
    playerAreaFreeOfHazard = 0;
    publicAreaFreeOfHazard = 0;
    sprinkleCoverLevelled = 0;
    stateAwayTeam = NSW;
    stateHomeTeam = NSW;
    submited = 2;
    updateDate = "2014-03-19 09:09:13 +0000";
    visibleDebrisRemoved = 0;
    weatherSafeToPlay = 1;
})

Format of Dictionary:

  @"homeAssociationID":           22,
                                  @"homeClubID":                  7,
                                  @"homeTeamName":                df,
                                  @"awayAssociationID":           4,
                                  @"awayClubID":                  4,
                                  @"awayTeamName":                sfd,
                                  @"matchVenue":                  sdf,
                                  @"inspectionDateTime":          2014-03-19 09:08:00 +0000,
                                  @"weatherSafeToPlay":           0,
                                  @"playSurfaceAcceptable":       0,
                                  @"visibleDebrisRemoved":        0,
                                  @"groundMarkingsAcceptable":    0,
                                  @"sprinklerCoverLevelled":      0,
                                  @"perimeterFencesFreeOfHazard": 1,
                                  @"publicAreaFreeOfHazard":      1,
                                  @"playerAreaFreeOfHazard":      1,
                                  @"firstAidFacilityAccessible":  0,
                                  @"actions":                     (includeActionsAndPhotos ? actions : @""),
                                  @"authorisedRep":               0,
                                  @"acceptDeclaration":           1,
                                  @"homeTeamRepName":             sdf,
                                  @"homeTeamRepPosition":         sdf,
                                  @"awayTeamRepName":             df,
                                  @"awayTeamRepPosition":         sdf,
                                  @"photos":     

             encodedImageArray,

please help.

LUI
  • 85
  • 1
  • 9
  • What is `MatchDayChecklist`? A custom `NSObject`-derived object? – trojanfoe Mar 19 '14 at 10:14
  • its the class generated for the entity matchdaychecklist that contains all these fields. – LUI Mar 19 '14 at 10:15
  • So it sounds like you need to add a method to the class to create the dictionary and populate it with each property. Doesn't sound too difficult. – trojanfoe Mar 19 '14 at 10:21
  • See http://stackoverflow.com/questions/10427340/extending-core-data-generated-nsmanagedobject-classes – trojanfoe Mar 19 '14 at 10:22
  • 1
    Your question's title is inexact, you are not talking about converting a NSArray to a NSDictionary but a NSManagedObject to a NSDictionary, that's not the same thing at all. – Jerome Diaz Mar 19 '14 at 10:35

0 Answers0