我正在关注FB登录的firebase教程。在'ViewController'类型的对象上找不到属性ref?
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Align the button in the center horizontally
Firebase *ref = [[Firebase alloc] initWithUrl:@"https://MYURL.com"];
// Open a session showing the user the login UI
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"] allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (error) {
NSLog(@"Facebook login failed. Error: %@", error);
} else if (state == FBSessionStateOpen) {
NSString *accessToken = session.accessTokenData.accessToken;
[self.ref authWithOAuthProvider:@"facebook" token:accessToken
withCompletionBlock:^(NSError *error, FAuthData *authData) {
if (error) {
NSLog(@"Login failed. %@", error);
} else {
NSLog(@"Logged in! %@", authData);
}
}];
}
}];
有发生在线路的错误:
[self.ref authWithOAuthProvider:@"facebook" token:accessToken
withCompletionBlock:^(NSError *error, FAuthData *authData)
当我声明它的文件的顶部“属性REF不类型‘的ViewController’的对象中找到”部分。
@interface ViewController()
@property (weak, nonatomic) Firebase* ref;
@end
错误消失,出现在这行代码
Firebase *ref = [[Firebase alloc] initWithUrl:@"https://sizzling-inferno-8395.firebaseio.com"];
它说:“未使用的实体问题,未使用的变量‘裁判’”
为什么报警?如何解决这个问题?
我试图这样做太: 接口的ViewController() 属性(弱,非原子)火力地堡* REF = [[火力地堡的alloc] initWithUrl:@“的https:// .firebaseio.com“]; 结束 它仍然不起作用。如何在类级别声明并使其工作:Firebase * ref = [[Firebase alloc] initWithUrl:@“https:// .firebaseio.com”]; ? –
user3270418
2014-11-04 09:05:58