0

私は次のように応答するjsonからのnsdictionaryを持っています:

({
    email = "something@gmail.com";
    name = "User1";
},
    {
    email = "something2@gmail.com";
    name = "user2";
})

これは de .m ファイルの私のコードです:

   - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{



    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;

    int errorCode = httpResponse.statusCode;

    NSString *fileMIMEType = [[httpResponse MIMEType] lowercaseString];

    NSLog(@"response is %d, %@", errorCode, fileMIMEType);

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{

    //NSLog(@"data is %@", data);

    NSString *myString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    //NSLog(@"string is %@", myString);
    NSError *e = nil;

    usersDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&e];

    NSLog(@"dictionary is %@", usersDictionary);
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {



    // inform the user

    NSLog(@"Connection failed! Error - %@ %@",

          [error localizedDescription],

          [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);

}

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

   NombreUsuario = [[NSMutableArray alloc] initWithCapacity:[usersDictionary count]];


}

これを使用して、セクションの行数を返します。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [usersDictionary count];
}

しかし、各セルが名前のメインラベルと電子メールのサブタイトルを表示する必要があるテーブルビューに、データ email,name のペアを配置する方法がわかりません。

前もって感謝します。

4

2 に答える 2