与代表参考的ARC项目编译失败 [英] ARC project with delegate reference fails compiling

查看:153
本文介绍了与代表参考的ARC项目编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我无法在iOS项目中实施Facebook SDK, [facebook authorize:permissions delegate:self]; 

当我尝试在我的ARC项目中运行它时,它不会允许委托:self 。相反,它说有一个ARC错误:没有可见的@interface为'Facebook'声明选择器授权:委托:'



我可以编译: / p>

  [facebook authorize:permissions]; 

但我不认为Facebook和应用程序通过这样做进行正常通信。我可以登录,但一旦重定向到我的应用程序,该应用程序不会注册它登录,不能执行任何共享功能。



我想我需要将该页面保持为ARC,所以设置一个标志为-fno-objc-arc将无法解决这个问题。



任何想法?






FOLLOWUP 4/5/12:



我能够成功实现Facebook ...但只使用弹出式登录方法在应用程序。以下是我发生的事情(只是FB方面的显示):



我的应用程式代码标题:

  #importFBConnect.h

@interface AppDelegate:UIResponder< UIApplicationDelegate> {

Facebook *

}

@property(nonatomic,strong)Facebook * facebook;

@end

应用程序委托方法,包括:

  //// FB元素:导入VC连接FACEBOOK 
#importViewController.h

//// FB ELEMENT
@synthesize Facebook;

/////// FB ELEMENTS
//此方法支持IOS PRE 4.2
- (BOOL)应用程序:(UIApplication *)应用程序handleOpenURL :( NSURL *) url {

NSLog(@handleOpenURL called。);

return [facebook handleOpenURL:url];

}

//这种方法支持IOS 4.2之后
- (BOOL)应用程序:(UIApplication *)应用程序openURL:(NSURL *)url sourceApplication :( NSString *)sourceApplication注释:(id)注释{

NSLog(@openURL called);

return [facebook handleOpenURL:url];
}

然后我想要Facebook的大部分活动都在调用它的页面上。这是标题:

  #importFBConnect.h

@interface ViewController:UIViewController< ; FBSessionDelegate,FBDialogDelegate>

// FB ELEMENTS
Facebook * facebook;
BOOL登录;

//////照片显示层的分享属性
@property(非原子,强)Facebook * facebook;

在视图控制器的方法中:

  @synthesize Facebook; 

////////////////////////////////////// //

- (void)postWall {

NSLog(@postWall called。);

//创建更多可接受的变量
NSString * photoTitle = [photoTitles objectAtIndex:pt];


//建立描述CONTENT
NSDictionary * itemDescriptionPre = [photoDescriptions objectAtIndex:pt];
NSString * itemDescription = [itemDescriptionPre objectForKey:@_ content];

NSMutableDictionary * paramsSet =
[NSMutableDictionary dictionaryWithObjectsAndKeys:

// CLICKABLE LINK COMPONENT(STORY TITLE WORKS WELL HERE)
photoTitle,@name ,

// STORY DESCRIPTION GOES HERE
itemDescription,@description,

// STORY LINK GOES HERE
[flickrURLLink objectAtIndex:pt] ,@link,

// PHOTO to connection with POST
[photoURLsLargeImage objectAtIndex:pt],@picture,
nil];

[[self facebook] dialog:@feedandParams:paramsSet andDelegate:self];

}

- (void)fbDidLogin {

facebook = [[Facebook alloc] initWithAppId:@MY_APP_IDandDelegate:self];

login = YES;

NSLog(@使用Facebook凭据登录);

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@FBAccessTokenKey];
[defaults setObject:[facebook expiredDate] forKey:@FBExpirationKey];
[默认同步];

[self postWall];
}

- (void)fbDidNotLogin:(BOOL)已取消{
/// TO COMPLETE
}

- (void) fbDidExtendToken:(NSString *)accessToken
expiresAt :( NSDate *)expiresAt {
////完成
}


- (void) fbDidLogout {

login = NO;
NSLog(@用Facebook凭据登录);
}

- (void)fbSessionInvalidated {

login = NO;

NSLog(@用Facebook凭据登录);
}

设置完毕后,我确定我将应用ID添加到plist如Facebook教程所述,并且都按预期工作。



我知道BOOL登录值不会影响任何东西。



我现在的这个代码的问题是5.1之前的兼容性问题。



它在我的5.1测试设备和模拟器中工作得很好,但不做登录后的任何事情,如果我去5.0或以下。任何想法为什么会这样的情况?我可以输入我的登录数据,然后返回到应用程序,但不再提供任何选项。



感谢您的反馈。很乐意听到你对这个项目的想法。

解决方案

我能够成功实现Facebook ...但只使用弹出窗口登录方法在应用程序。详细信息已作为我原始帖子的编辑添加。


I'm having trouble implementing the Facebook SDK in an iOS project and I suspect that this line is to blame:

[facebook authorize:permissions delegate:self];

When I try to run it in my ARC project, it will not allow the delegate:self to remain. Instead it says there is an "ARC Error: no visible @interface for 'Facebook' declares the selector 'authorize:delegate:'"

I can compile with this:

[facebook authorize:permissions];

but I don't think Facebook and the app communicate properly by doing so. I am able to login, but once redirected back to my app, the app does not register that it is logged in and can't execute any of its sharing functions.

I think I need to maintain that page as ARC enabled, so setting a flag to -fno-objc-arc won't resolve this.

Any thoughts?


FOLLOWUP 4/5/12:

I was able to successfully implement Facebook… but using just the popup login method in app. Here's how I made it happen (just FB aspects show):

My app delegate header:

#import "FBConnect.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>{

    Facebook *facebook;

}

@property (nonatomic, strong) Facebook *facebook;

@end

App delegate method, included:

////FB ELEMENT: IMPORTING VC TO CONNECT WITH FACEBOOK
#import "ViewController.h"

////FB ELEMENT
@synthesize facebook;

///////FB ELEMENTS
// THIS METHOD SUPPORTS IOS PRE 4.2
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

    NSLog(@"handleOpenURL called.");

    return [facebook handleOpenURL:url];

}

// THIS METHOD SUPPORTS IOS AFTER 4.2
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{

NSLog(@"openURL called.");

return [facebook handleOpenURL:url];
}

Then I wanted the bulk of the Facebook activity to be on the page calling it. Here is the header:

#import "FBConnect.h"

@interface ViewController : UIViewController <FBSessionDelegate, FBDialogDelegate>

//FB ELEMENTS
Facebook *facebook;
BOOL login;

//////SHARE PROPERTIES FOR PHOTO DISPLAY LAYER
@property (nonatomic, strong) Facebook *facebook;

And on the view controller's method:

@synthesize facebook;

////////////////////////////////////////////

-(void)postWall{

    NSLog(@"postWall called.");

    //CREATING MORE ACCESSIBLE VARIABLE
    NSString *photoTitle = [photoTitles objectAtIndex:pt];


    //ESTABLISHES DESCRIPTION CONTENT
    NSDictionary *itemDescriptionPre = [photoDescriptions objectAtIndex:pt];
    NSString *itemDescription = [itemDescriptionPre objectForKey:@"_content"];

    NSMutableDictionary *paramsSet = 
    [NSMutableDictionary dictionaryWithObjectsAndKeys:

     //CLICKABLE LINK COMPONENT (STORY TITLE WORKS WELL HERE)
     photoTitle, @"name",

     //STORY DESCRIPTION GOES HERE
     itemDescription, @"description",

     //STORY LINK GOES HERE
     [flickrURLLink objectAtIndex:pt], @"link",

     //PHOTO TO CONNECT WITH POST
     [photoURLsLargeImage objectAtIndex:pt], @"picture",
     nil];  

    [[self facebook] dialog:@"feed" andParams:paramsSet andDelegate:self];

}

- (void) fbDidLogin {

    facebook = [[Facebook alloc] initWithAppId:@"MY_APP_ID" andDelegate:self];

    login = YES;

    NSLog(@"Logged in with Facebook credentials");

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationKey"];
    [defaults synchronize];

    [self postWall];
}

- (void)fbDidNotLogin:(BOOL)cancelled{
    ///TO COMPLETE
}

- (void)fbDidExtendToken:(NSString*)accessToken
               expiresAt:(NSDate*)expiresAt{
    ////TO COMPLETE
}


- (void)fbDidLogout{

    login = NO;
    NSLog(@"Logged out with Facebook credentials");
}

- (void)fbSessionInvalidated{

    login = NO;

    NSLog(@"Logged out with Facebook credentials");
}

After setting those up, I made sure I added the app ID into the plist as described by the Facebook tutorial and all worked as expected.

I am aware that the BOOL login value doesn't affect anything yet.

My current problem with this code is a compatibility problem before 5.1.

It works great in my 5.1 test device and simulator, but does not do anything after the login step if I go to 5.0 or below. Any idea why that would be the case? I am able to enter my login data, then returned to the app, but not presented any more options.

Thanks for all your feedback so far. Would love to hear your thoughts on this item as well.

解决方案

I was able to successfully implement Facebook… but using just the popup login method in app. Details were added as an edit to my original post.

这篇关于与代表参考的ARC项目编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆