好的 iOS 代码习惯
一,使用别人的框架时,尽量在退出时移除框架创建的对象
1 if (_giftToastView) { 2 [_giftToastView removeFromSuperview]; 3 _giftToastView = nil; 4 }
二,在当前类写网络请求时,勿忘设置当前类是网络请求类的代理.
1 [[[GetAppDelegate taskManager]timeTaskDataMgr]reloadData]; 2 [[GetAppDelegate taskManager]timeTaskDataMgr].delegate = self;
三,接收到的服务器数据不要直接处理,应该先判断一番
1 EnumTaskState state = TaskStateUndefine; 2 NSInteger num = [_state integerValue]; 3 if (num == 1) { 4 state = TaskStateInProgress; 5 } else if (num == 2) { 6 state = TaskStatewillDone; 7 } else if (num == 3) { 8 state = TaskStatedidDone; 9 }
四,