我正在關注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