2

Added Sharekit group to my project and getting so many compiled warnings.

In this it is a static instance and passing self parameter in a static method is not right as there is no particular instance of this object in static methods. How i can fix this.

 + (void)logout
{
FBSession *fbSession; 

if(!SHKFacebookUseSessionProxy){
    fbSession = [FBSession sessionForApplication:SHKFacebookKey
                                             secret:SHKFacebookSecret
                                           delegate:self];

}else {
    fbSession = [FBSession sessionForApplication:SHKFacebookKey
                                    getSessionProxy:SHKFacebookSessionProxyURL
                                          delegate:self];
                  //delegate:[self sharedSomeProtocolDelegate]];
}

[fbSession logout];
}

Anyone please.

Thanks

user1452248
  • 767
  • 2
  • 11
  • 28
  • Ignore warnings. (in this case) –  Sep 19 '12 at 19:28
  • You say you have a static instance - do you mean there is a `static` variable that has a pointer to an instance of your class? If so, can you pass that variable instead of `self`? – Carl Veazey Sep 22 '12 at 22:15

2 Answers2

1

Do a SocialManager object which conforms to FBSessionDelegate protocol. Instantiate it and give instead of self parameter in your code. Eg:

SocialManager.h:

 @interface SocialManager : NSObject <FBSessionDelegate>
- (id) init;
/**
 * Called when the user successfully logged in.
 */
- (void)fbDidLogin;

/**
 * Called when the user dismissed the dialog without logging in.
 */
- (void)fbDidNotLogin:(BOOL)cancelled;

/**
 * Called when the user logged out.
 */
- (void)fbDidLogout;
@end

SocialManager.m:

-(id) init
{
  self = [super init];
  return self;
}
- (void)fbDidLogin;
{
}
- (void)fbDidNotLogin:(BOOL)cancelled;
{
}
- (void)fbDidLogout
{
}

and in your code:

 + (void)logout
{
FBSession *fbSession;
SocialManager* socialManager = [[SocialManager alloc] init];

if(!SHKFacebookUseSessionProxy){
    fbSession = [FBSession sessionForApplication:SHKFacebookKey
                                             secret:SHKFacebookSecret
                                           delegate:socialManager];

}else {
    fbSession = [FBSession sessionForApplication:SHKFacebookKey
                                    getSessionProxy:SHKFacebookSessionProxyURL
                                          delegate:socialManager];
                  //delegate:[self sharedSomeProtocolDelegate]];
}

[fbSession logout];
}

This is a simple example, but you have to implement your own delegate somewhee in your code. Just add to your object (viewController probably) methonds which are in protocol and set this object as delegate of FBsession.

pro_metedor
  • 1,176
  • 10
  • 17
1

When working with static Class, you can just manually get ride of the warning in that case:

...
delegate:(id<FBSessionDelegate>)self];
Cœur
  • 37,241
  • 25
  • 195
  • 267