【发布时间】:2014-03-11 10:37:49
【问题描述】:
我正在使用 Parse,我想显示从 Parse 获取的电子邮件并显示在 Parse 的列中。 first_name、last_name、id 等所有内容都可以正常工作。但是当我尝试设置 prop.email 时,它没有找到任何属性。如果我在该位置(在代码中标记)执行相同的操作,它会发现我的电子邮件属性没有任何问题。
我的意思是这行代码:
[[PFUser currentUser] setObject:prop.id forKey:@"fbid"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.first_name forKey:@"firstname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.last_name forKey:@"lastname"];
[[PFUser currentUser] saveInBackground];
//This one doesn`t find property email
[[PFUser currentUser] setObject:prop.email forKey:@"email"];
[[PFUser currentUser] saveInBackground];
FB 连接的其余部分代码
{
NSArray *permissionsArray = @[@"email"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
// Was login successful ?
if (!user) {
if (!error) {
NSLog(@"The user cancelled the Facebook login.");
}else {
NSLog(@"An error occurred: %@", error.localizedDescription);
}
// Callback - login failed
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:NO];
}
}else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary<FBGraphUser> *prop = (NSDictionary<FBGraphUser> *)result;
[[PFUser currentUser] setObject:prop.id forKey:@"fbid"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.first_name forKey:@"firstname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.last_name forKey:@"lastname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.email forKey:@"email"];
[[PFUser currentUser] saveInBackground];
}else {
NSLog(@"User logged in through Facebook!");
NSLog(@"Welcome Screen I am %@", [[PFUser currentUser] username]);
}
}];
}
else {
//HERE
NSLog(@"Error getting the FB username %@", [error description]);
}
[[PFUser currentUser] saveInBackground];
// Callback - login successful
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:YES];
}
}];
}
【问题讨论】:
-
你的错误信息是什么?
-
你为什么要为每个属性调用保存?
-
Property 'email' not found on object of type 'NSDictionary<FBGraphUser> *,只想显示名字、姓氏和电子邮件。我认为这是一个好方法,但只是 dont understand, why it doesnt 显示这个属性,而所有其他(用户名,first_name atc.)都显示没有任何问题 -
您是否尝试过调试代码并查看调试器中的 prop 对象,看看它有什么值?
-
That
s that, if I set a breakpoint in the line with Dictionary, it doesnt 即使我点击按钮 facebook 并成功登录也会崩溃
标签: ios facebook parse-platform