0

を使用して、他の plist ファイルから plist ファイルを読み込もうとしていますinitWithContentsOfURL:

私は説明します、私はホストでplistファイルを使用して1つのテーブルビューを持っています。

NSMutableArray *genres = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.myurl.com/file.plist"]];
    self.loadGenres = genres;

<string>他の UITableView をロードするセルを選択する場合、最初の plist 内で使用する URL から他の plist を取得するように 2 番目のテーブル ビューにどのように指示できますか?

のような:

NSMutableArray *genres = [[NSMutableArray alloc] initWithContentsOfURL:[self.loadGenres objectForKey:@"PLIST URL"]];
self.loadGenres = genres;

ご支援ありがとうございます。

4

2 に答える 2

1

YourClass.hで次のことを試してください

NSURLConnection* linksConnection;
NSMutableData* linksData;

YourClass.m で

-(void) loadURL
{

NSMutableURLRequest* the_request = [NSMutableURLRequest requestWithURL:[NSURL        URLWithString:YOUR_URL]];
linksConnection = [[NSURLConnection alloc] initWithRequest:the_request delegate:self startImmediately:YES];

if(linksConnection != nil)
{
    linksData = [[NSMutableData data] retain];

}
}

-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
 [linksData setLength:0];
}

-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[linksData appendData:data];
}

-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{

NSString *errorStr = nil;
NSPropertyListFormat format;
NSDictionary *propertyList = [NSPropertyListSerialization propertyListFromData:linksData
                                                              mutabilityOption:NSPropertyListImmutable
                                                                        format:&format
                                                              errorDescription:&errorStr];
NSMutableArray*  myArray = [[propertyList objectForKey:@"sample"] retain];
}

私はこれがあなたを大いに助けると確信しています

于 2013-03-27T13:28:10.257 に答える
1

配列では Key-Value コーディングを使用できません。

代わりに、このようにしてみてください。

NSMutableDictionary * genres = [[NSMutableDictionary alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.myurl.com/file.plist"]];
self.loadGenres = genres; // your self.loadGenres must be Dictionary type

NSMutableDictionary * genres = [[NSMutableDictionary alloc] initWithContentsOfURL:[NSURL URLWithString:[[self.loadGenres objectForKey:@"PLIST URL"]stringValue]]];
self.loadGenres = genres;
于 2013-03-27T13:08:42.783 に答える