What Is Software Design?

程式設計不是 “building software”,而是 “designing software”。

Is Design Dead?

軟體系統的設計是演進來的,不能一步到位,而是要藉由憑繁與使用者互動得到的回饋來修改系統設計。

Programming is Gardening, not Engineering

與其把程式設計比喻成蓋房子,實際上更像是園藝。

Orthogonality and the DRY Principle

所有程式設計活動其實都是維護,因為絕大部分的時間都在改code,寫一點改一點。即使是新專案,也很快需要回頭作修改。

顯示具有 AFNetworking 標籤的文章。 顯示所有文章
顯示具有 AFNetworking 標籤的文章。 顯示所有文章

2014年2月4日 星期二

ios AFNetworking 將token包入 header中 比較安全

setp1.
在api溝通中可以將資料放置 header or body  透過ssl



-(void)modifyWater:(WaterSync*)water uuid:(NSString*)uuid completionHandler:(void (^)(NSDictionary *retDic, NSDictionary *errorDic))handler{

    NSString *path = [NSString stringWithFormat:@"v2/Drinkings"];

    NSDictionary *dic = @{@"uuid": water.uuid, @"cc":water.amount, @"drinked_at":water.time, @"auth_token":[[PassionBeanAccount sharedAccount] authToken]};
    
    [self setDefaultHeader:@"auth_token" value:[[PassionBeanAccount sharedAccount] authToken]]; //將token包入header
    
    [self patchPath:path parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"ok");

        [MyWeb handleJsonResponseWithDataWithCompletionHandler:handler error:nil data:responseObject];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [MyWeb handleJsonResponseWithDataWithCompletionHandler:handler error:error data:nil errorCode:[operation.response statusCode]];
        
    }];


}