JSONModel gibt nil zurück
Ich verwende JSONModel, um den JSON von der URL zu erhalten. Es ist ein sehr einfaches Objekt, das nur zwei Zeichenfolgen enthält - "name" und "url".
Zuerst habe ich das Objektmodell erstellt:
@protocol
Tutorial
@end
@interface Tutorial : JSONModel
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *url;
@end
Dann Objekt-Feed:
#import "JSONModel.h"
#import "Tutorial.h"
@interface TutorialFeed : JSONModel
@property (nonatomic, strong) NSArray <Tutorial> *tutorials;
@end
und dann in MasterViewController.m:
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "TutorialFeed.h"
#import "JSONModelLib.h"
@interface MasterViewController () {
TutorialFeed *feed;
TutorialFeed *testFeed;
}
@end
@implementation MasterViewController
-(void)viewDidAppear:(BOOL)animated
{
feed = [[TutorialFeed alloc]
initFromURLWithString:@"http://api.matematikfessor.dk/apps/teacher_videos"
completion:^(JSONModel *model, JSONModelError *err) {
NSLog(@"Tutorials %@", feed.tutorials);
}];
}
@end
Das Problem ist, dass ich nil in meinem Log zurück bekomme :( Ich bin mir nicht sicher, warum das passiert, weil ich es geschafft habe, Daten von JSON von dieser URL abzurufen:Kiwa URL
All das getan, im Anschluss daranTutorial
Ich bin mir nicht sicher, was ich falsch mache. Hat jemand eine Ahnung?