Übergabe von Daten aus lokaler Datei mit JSON

Ich versuche, Daten aus meiner JSON-Datei an Labels auf einem einfachen ViewController zu übergeben, weiß jedoch nicht, wo diese Daten tatsächlich übergeben werden sollen. Könnte ich nur meine hinzufügensetDataToJson Methode oder würde ich die Daten in meinem hinzufügenviewDidLoad Methode?

Hier ist mein Code

@interface NSDictionary(JSONCategories)
+(NSDictionary*)dictionaryWithContentsOfJSONString:(NSString*)fileLocation;
@end

@implementation NSDictionary(JSONCategories)

+(NSDictionary*)dictionaryWithContentsOfJSONString:(NSString*)fileLocation{
    NSData* data = [NSData dataWithContentsOfFile:fileLocation];
    __autoreleasing NSError* error = nil;
    id result = [NSJSONSerialization JSONObjectWithData:data 
                                                options:kNilOptions error:&error];
    if (error != nil) return nil;
    return result;
}
@end

@implementation ViewController
@synthesize name;

- (void)viewDidLoad
{
    [super viewDidLoad];

}

-(void)setDataToJson{

    NSDictionary *infomation = [NSDictionary dictionaryWithContentsOfJSONString:@"Test.json"];
    name.text = [infomation objectForKey:@"AnimalName"];//does not pass data
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage