历尽波折,终于成功登录并拿到了token:

    - (LoginResultDto *)login:(NSString *)userName andPassword:(NSString *)password
{
    LoginRequestDto *requestDto=[LoginRequestDto new];
    requestDto.accountName = userName;
    requestDto.password = password;

    NSString *urlAsString = self.loginUrl;
    NSURL *url = [NSURL URLWithString:urlAsString];
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
    [urlRequest setTimeoutInterval:30.0f];
    [urlRequest setHTTPMethod:@"POST"];
    [urlRequest setHTTPBody:[requestDto toJson]];

    NSURLResponse *response = nil;
    NSError *error = nil;

    NSData *responseData = [NSURLConnection sendSynchronousRequest:urlRequest
                                         returningResponse:&response

                                                             error:&error];

    if (!error) {
        LoginResultDto *result = [LoginResultDto deserialize:responseData];
        return result;
    }
    return  nil;
}

2014-11-09 14:29:49.676 Demo[1517:72075] login succee and get the token: bbd70056c684475ea6bc636263f488a9_353f774969f440b7835a61fc1863e88b

以下是本章基础时间

property getter setter 的实现

@property(nonatomic,strong,readonly) NSString *loginUrl;
- (NSString *) loginUrl
{
    return nil;
}

The compiler willautomatically synthesize an instance variable.If you implement both a getter and a getter for a readwrite property, or a getter for a readonly property, the compiler will assume that you are taking control over the property implementation and won't synthesize an instance variable automatically.

see here: apple

NSString 基础

NSString* str = [NSString stringWithFormat:@"%@",@"Hello World"]

最新文章

  1. Javascript模块化编程(二):AMD规范
  2. html5获取经纬度,百度api获取街区名,并使用JS保存进cookie
  3. ITop
  4. aps.net 图形验证码(转)
  5. phpcms v9无法连接数据库服务器,请检查配置
  6. @ResultMapping注解
  7. Android 颜色渲染(五) LinearGradient线性渲染
  8. python学习-day3
  9. TIKV副本一致性检查机制分析
  10. 裴波那契查找详解 - Python实现
  11. Python中的转义
  12. 浅析mydumper
  13. Yarn架构详解
  14. oracle数据库实例启动与关闭
  15. js this的含义以及讲解
  16. 【黑魔法】Covering Indexes、STRAIGHT_JOIN
  17. Android:android studio快捷键大全
  18. jQuery之end()和pushStack()
  19. 1-hadoop、mr
  20. SQL 查询存储过程

热门文章

  1. 一个完整的Http请求
  2. js手机网页跳转
  3. neutron 网络配置flat模式
  4. 【Networking】容器网络大观 && SDN 资料汇总
  5. js中val()和value的区别
  6. 数据库Error:The ScriptCollection in ScriptName not find
  7. visual studio 2012 插件
  8. 隐藏左侧快速导航除DMS导航树之外的其他区域
  9. Dynamic Invok Webservice
  10. ASIHTTPRequest详解 [经典3]