登录成功,拿到token
2024-08-25 17:06:17
历尽波折,终于成功登录并拿到了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"]
最新文章
- Javascript模块化编程(二):AMD规范
- html5获取经纬度,百度api获取街区名,并使用JS保存进cookie
- ITop
- aps.net 图形验证码(转)
- phpcms v9无法连接数据库服务器,请检查配置
- @ResultMapping注解
- Android 颜色渲染(五) LinearGradient线性渲染
- python学习-day3
- TIKV副本一致性检查机制分析
- 裴波那契查找详解 - Python实现
- Python中的转义
- 浅析mydumper
- Yarn架构详解
- oracle数据库实例启动与关闭
- js this的含义以及讲解
- 【黑魔法】Covering Indexes、STRAIGHT_JOIN
- Android:android studio快捷键大全
- jQuery之end()和pushStack()
- 1-hadoop、mr
- SQL 查询存储过程