我不明白我的应用程序出现了什么问题。
我可以解析并输出json文件,这样一个特定的标签就会填充艺术家的名字、专辑的名字以及专辑的id。
我唯一的问题是让url也出现在标签的位置。
我已经仔细检查了lastfm的文档,包括示例输出,但它仍然没有显示给定相册的url。
该特定部分的代码为:
#import "MusicDetailsViewController.h"
#import "FilmSearchService.h"
@implementation MusicDetailsViewController
@synthesize imgAlbum;
@synthesize txtAlbumName;
@synthesize txtArtistName;
@synthesize urlOverview;
@synthesize txtUrl;
@synthesize movie;
-(void)viewWillAppear:(BOOL)animated {
if ([self movie] != nil){
[self setTitle:[[self movie] valueForKey:@"name"]];
;
[txtAlbumName setText:[[self movie] valueForKey:@"name"]];
[txtArtistName setText:[[[self movie] valueForKey:@"artist"] description]];
[txtUrl setText:[[self movie] valueForKey:@"id"]];
NSLog(@"value of url = %@", txtUrl);
[urlOverview setText:[[self movie] valueForKey:@"url"]];
}
}
@end
这是我在执行此操作时收到的错误消息:
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<MusicDetailsViewController 0x71a84f0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key txtUrllink.' ***
由于它是一个标签,因此您需要使用text
属性像下面这样打印,请遵循:-
NSLog(@"value of url = %@", txtUrl.text);
只是您的视图控制器有一个名为"txtUrllink"的IBOutlet,该IBOutlet已不再链接。