会话与_session之间的差异(facebook整合) [英] difference between session and _session (facebook integration)

查看:121
本文介绍了会话与_session之间的差异(facebook整合)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了Facebook集成的代码...,我的应用程序正常工作。



我只想知道会话 _session



以及 loginDialog _loginDialog

感谢您的帮助...:)

  @interface MyFbViewController:UIViewController< FBSessionDelegate,FBRequestDelegate> 
{


FBSession * _session;

FBLoginDialog * _loginDialog;

}

@property(nonatomic,retain)FBSession * session;

@property(nonatomic,retain)FBLoginDialog * loginDialog;


@end

在MyFbViewController.m文件中.......

  @synthesize session = _session; 

@synthesize loginDialog = _loginDialog;


解决方案

_session _loginDialog 是类的实例变量。因此,您完全负责内存管理(即保留和释放)那些与任何其他变量一样的变量。



属性会话和loginDialog与综合语句生成两个类属性,这反过来只是特殊选择器。



@合成会话= _session; 基本上生成两个方法, - (FBSession *)session; - (void)setSession: (FBSession *)newSession; 当您使用对象属性的点符号(即 object.session )时,它们将被调用。您可以自己编写它们,并省略综合,但很少做,因为您将再次负责内存管理。



由于这些属性是保留属性,自动生成的方法处理必要的保留/释放内容,像这样:

   - (FBSession *)session 
{
return _session;
}

- (void)setSession:(FBSession *)newSession
{
if(newSession!= _session)
{
[ _session release];
[newSession retain];
_session = newSession;
}
}

这样可以让您免受内存管理的负担,当您将属性设置为 nil (完成后将释放任何现有对象)。


i download the code for facebook integration...and my application work fine..

i just wants to know that what is difference between session and _session

and also loginDialog and _loginDialog

thanks for help...:)

@interface MyFbViewController :UIViewController <FBSessionDelegate, FBRequestDelegate>
{


FBSession* _session;

FBLoginDialog *_loginDialog;

}

@property (nonatomic, retain) FBSession *session;

@property (nonatomic, retain) FBLoginDialog *loginDialog;


@end

in MyFbViewController.m file.........

@synthesize session = _session;

@synthesize loginDialog = _loginDialog;

解决方案

_session and _loginDialog are instance variables of the class. As such you are completely responsible for memory management (i.e. retaining and releasing) those variables as you would be with any other variable.

The properties session and loginDialog in combination with the synthesize statement generate two class properties, which in turn are only special selectors.

@synthesize session = _session; basically generates two methods, - (FBSession *)session; and - (void)setSession:(FBSession *)newSession; which are invoked whenever you use the dot-notation for object properties (i.e. object.session). You could write them on your own and leave out the synthesize but that is seldomly done because you again would be responsible for memory management.

As these properties are retain properties, the automatically generated methods handle the necessary retain/release stuff and could look something like this:

- (FBSession *)session
{
    return _session;
}

- (void)setSession:(FBSession *)newSession
{
    if (newSession != _session)
    {
        [_session release];
        [newSession retain];
        _session = newSession;
    }
}

Which frees you from the burden of memory management as long as you set the property to nil when done (as this will release any existing object).

这篇关于会话与_session之间的差异(facebook整合)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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