CartUtils.m 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. //
  2. // CartUtils.m
  3. // iSales-NPD
  4. //
  5. // Created by Ray on 12/26/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CartUtils.h"
  9. #import "RAUtils.h"
  10. #import "AppDelegate.h"
  11. #import "RANetwork.h"
  12. #import "LoginViewController.h"
  13. #import "MainViewController.h"
  14. #import "OrderListViewController.h"
  15. @implementation CartUtils
  16. +(void) neworder:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart
  17. {
  18. // __block UIAlertController * waitalert = [RAUtils waiting_alert:vc title:@"Create Order" completion:^{
  19. PopWaitAlert* pop = [RAUtils waiting_pop:@"Create Order" completion:nil];
  20. [RANetwork request_create_order:^(NSMutableDictionary *result) {
  21. NSMutableDictionary* return_json = result;
  22. // [waitalert dismissViewControllerAnimated:YES completion:^{
  23. [pop hide];
  24. if([[return_json valueForKey:@"result"] intValue]==2)
  25. {
  26. int resulti=[[return_json valueForKey:@"result"] intValue];
  27. if(resulti==2)
  28. {
  29. //successed.
  30. NSString* order_code = [return_json valueForKey:@"orderCode"];
  31. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  32. appDelegate.order_code = order_code;
  33. appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  34. IMP imp = [holder methodForSelector:addtocart];
  35. void (*func)(id, SEL) = (void *)imp;
  36. func(holder, addtocart);
  37. // [holder performSelector:addtocart];
  38. }
  39. }
  40. else
  41. {
  42. [RAUtils message_box:@"Create Order" message:[return_json valueForKey:@"err_msg"] completion:nil];
  43. }
  44. // }];
  45. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  46. }];
  47. // }];
  48. }
  49. +(void) add_to_cart:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart
  50. {
  51. UIApplication * app = [UIApplication sharedApplication];
  52. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  53. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  54. if(appDelegate.bLogin==false)
  55. {
  56. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  57. loginvc.returnValue = ^(bool blogin){
  58. if(blogin)
  59. {
  60. // if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  61. if(true)
  62. {
  63. [main_vc checklogin:YES];
  64. NSString* msg =@"";
  65. // if(appDelegate.contact_id.length>0)
  66. // {
  67. // msg = [msg stringByAppendingString:@"Customer:"];
  68. // msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  69. //
  70. // }
  71. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  72. //block代码块取代了delegate
  73. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  74. // vc.disable_refresh = true;
  75. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  76. ovc.showNavibar = true;
  77. //ovc.customer_id = appDelegate.contact_id;
  78. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  79. IMP imp = [holder methodForSelector:addtocart];
  80. void (*func)(id, SEL) = (void *)imp;
  81. func(holder, addtocart);
  82. // [holder performSelector:addtocart];
  83. };
  84. ovc.init_style = OL_OPEN;
  85. ovc.onCancel = ^(){
  86. // self.disable_refresh = false;
  87. };
  88. [vc.navigationController pushViewController:ovc animated:true];
  89. }];
  90. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  91. {
  92. //create new;
  93. // self.disable_refresh = true;
  94. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  95. {
  96. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  97. __weak typeof(cvc) weakcvc = cvc;
  98. cvc.showNavibar = true;
  99. cvc.contact_type = @"Sales_Order_Customer";
  100. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  101. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  102. appDelegate.customerInfo = value;
  103. if(appDelegate.order_code==nil)
  104. [self neworder:weakcvc selectorholder:holder selector:addtocart];
  105. // neworder();
  106. // [main_vc checklogin:true];
  107. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  108. //
  109. // if(self.returnValue)
  110. // self.returnValue(value);
  111. };
  112. cvc.onCancel = ^(){
  113. [RAUtils message_box:@"New Order Error" message:@"Cannot create order without customer infomation." completion:nil];
  114. // self.disable_refresh = false;
  115. };
  116. cvc.onReset = ^(){
  117. // [main_vc checklogin:true];
  118. };
  119. [vc.navigationController pushViewController:cvc animated:true];
  120. }
  121. else
  122. {
  123. [self neworder:vc selectorholder:holder selector:addtocart];
  124. }
  125. }
  126. DebugLog(@"No");
  127. }];
  128. [alertControl addAction:actionOne];
  129. [alertControl addAction:alertthree];
  130. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  131. }];
  132. [alertControl addAction:alertcancel];
  133. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  134. [vc presentViewController:alertControl animated:YES completion:nil];
  135. }
  136. // else
  137. // {
  138. //
  139. // //customer login;
  140. // [main_vc checklogin:false];
  141. // //[self addtocart];
  142. // [holder performSelector:addtocart];
  143. // }
  144. }
  145. };
  146. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  147. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  148. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  149. [vc presentViewController:navi animated:YES completion:^{
  150. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  151. DebugLog(@"LoginViewController present.........");
  152. // self.btop = false;
  153. // <#code#>
  154. }];
  155. }
  156. else
  157. {
  158. //if(appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&appDelegate.order_code==nil)
  159. if(appDelegate.order_code==nil)
  160. {
  161. if(appDelegate.contact_id.length==0)
  162. {
  163. NSString* msg =@"";
  164. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  165. //block代码块取代了delegate
  166. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  167. // vc.disable_refresh = true;
  168. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  169. ovc.showNavibar = true;
  170. //ovc.customer_id = appDelegate.contact_id;
  171. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  172. IMP imp = [holder methodForSelector:addtocart];
  173. void (*func)(id, SEL) = (void *)imp;
  174. func(holder, addtocart);
  175. // [holder performSelector:addtocart];
  176. };
  177. ovc.init_style = OL_OPEN;
  178. ovc.onCancel = ^(){
  179. // self.disable_refresh = false;
  180. };
  181. [vc.navigationController pushViewController:ovc animated:true];
  182. }];
  183. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  184. {
  185. //create new;
  186. // self.disable_refresh = true;
  187. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  188. {
  189. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  190. __weak typeof(cvc) weakcvc = cvc;
  191. cvc.showNavibar = true;
  192. cvc.contact_type = @"Sales_Order_Customer";
  193. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  194. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  195. appDelegate.customerInfo = value;
  196. if(appDelegate.order_code==nil)
  197. [self neworder:weakcvc selectorholder:holder selector:addtocart];
  198. // neworder();
  199. // [main_vc checklogin:true];
  200. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  201. //
  202. // if(self.returnValue)
  203. // self.returnValue(value);
  204. };
  205. cvc.onCancel = ^(){
  206. [RAUtils message_box:@"New Order Error" message:@"Cannot create order without customer infomation." completion:nil];
  207. // self.disable_refresh = false;
  208. };
  209. cvc.onReset = ^(){
  210. // [main_vc checklogin:true];
  211. };
  212. [vc.navigationController pushViewController:cvc animated:true];
  213. }
  214. else
  215. {
  216. [self neworder:vc selectorholder:holder selector:addtocart];
  217. }
  218. }
  219. DebugLog(@"No");
  220. }];
  221. [alertControl addAction:actionOne];
  222. [alertControl addAction:alertthree];
  223. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  224. }];
  225. [alertControl addAction:alertcancel];
  226. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  227. [vc presentViewController:alertControl animated:YES completion:nil];
  228. }
  229. else
  230. {
  231. // __block UIAlertController * waitalert = [RAUtils waiting_alert:vc title:@"Checking Pending Order" completion:^{
  232. PopWaitAlert* pop = [RAUtils waiting_pop:@"Checking Pending Order" completion:nil];
  233. [RANetwork request_pendingorder:appDelegate.contact_id completionHandler:^(NSMutableDictionary *result) {
  234. NSMutableDictionary* return_json =result;
  235. // [waitalert dismissViewControllerAnimated:YES completion:^{
  236. [pop hide];
  237. if([[return_json valueForKey:@"result"] intValue]==2)
  238. {
  239. bool openPendingOrder= [[return_json valueForKey:@"hasPending"] boolValue];
  240. bool createNewOrder=appDelegate.can_create_order;
  241. if(openPendingOrder&&createNewOrder)
  242. {
  243. NSString* msg =@"";
  244. if(appDelegate.contact_id.length>0)
  245. {
  246. msg = [msg stringByAppendingString:@"Customer:"];
  247. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  248. }
  249. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  250. //block代码块取代了delegate
  251. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  252. // vc.disable_refresh = true;
  253. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  254. ovc.showNavibar = true;
  255. ovc.customer_id = appDelegate.contact_id;
  256. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  257. IMP imp = [holder methodForSelector:addtocart];
  258. void (*func)(id, SEL) = (void *)imp;
  259. func(holder, addtocart);
  260. // [holder performSelector:addtocart];
  261. };
  262. ovc.init_style = OL_OPEN;
  263. ovc.onCancel = ^(){
  264. // self.disable_refresh = false;
  265. };
  266. [vc.navigationController pushViewController:ovc animated:true];
  267. }];
  268. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  269. {
  270. //create new;
  271. // self.disable_refresh = true;
  272. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  273. {
  274. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  275. __weak typeof(cvc) weakcvc = cvc;
  276. cvc.showNavibar = true;
  277. cvc.contact_type = @"Sales_Order_Customer";
  278. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  279. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  280. appDelegate.customerInfo = value;
  281. if(appDelegate.order_code==nil)
  282. [self neworder:weakcvc selectorholder:holder selector:addtocart];
  283. // neworder();
  284. // [main_vc checklogin:true];
  285. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  286. //
  287. // if(self.returnValue)
  288. // self.returnValue(value);
  289. };
  290. cvc.onCancel = ^(){
  291. [RAUtils message_box:@"New Order Error" message:@"Cannot create order without customer infomation." completion:nil];
  292. // self.disable_refresh = false;
  293. };
  294. cvc.onReset = ^(){
  295. // [main_vc checklogin:true];
  296. };
  297. [vc.navigationController pushViewController:cvc animated:true];
  298. }
  299. else
  300. {
  301. [self neworder:vc selectorholder:holder selector:addtocart];
  302. }
  303. }
  304. DebugLog(@"No");
  305. }];
  306. [alertControl addAction:actionOne];
  307. [alertControl addAction:alertthree];
  308. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  309. }];
  310. [alertControl addAction:alertcancel];
  311. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  312. [vc presentViewController:alertControl animated:YES completion:nil];
  313. }
  314. else
  315. {
  316. if(openPendingOrder)
  317. {
  318. NSString* msg =@"";
  319. if(appDelegate.contact_id.length>0)
  320. {
  321. msg = [msg stringByAppendingString:@"Customer:"];
  322. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  323. }
  324. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  325. //block代码块取代了delegate
  326. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  327. // vc.disable_refresh = true;
  328. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  329. ovc.showNavibar = true;
  330. ovc.customer_id = appDelegate.contact_id;
  331. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  332. IMP imp = [holder methodForSelector:addtocart];
  333. void (*func)(id, SEL) = (void *)imp;
  334. func(holder, addtocart);
  335. // [holder performSelector:addtocart];
  336. };
  337. ovc.init_style = OL_OPEN;
  338. ovc.onCancel = ^(){
  339. // self.disable_refresh = false;
  340. };
  341. [vc.navigationController pushViewController:ovc animated:true];
  342. }];
  343. [alertControl addAction:actionOne];
  344. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  345. }];
  346. [alertControl addAction:alertcancel];
  347. // [alertControl addAction:alertthree];
  348. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  349. [vc presentViewController:alertControl animated:YES completion:nil];
  350. }
  351. else if(createNewOrder)
  352. {
  353. NSString* msg =@"";
  354. if(appDelegate.contact_id.length>0)
  355. {
  356. msg = [msg stringByAppendingString:@"Customer:"];
  357. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  358. }
  359. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  360. //block代码块取代了delegate
  361. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  362. {
  363. //create new;
  364. // self.disable_refresh = true;
  365. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  366. {
  367. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  368. __weak typeof(cvc) weakcvc = cvc;
  369. cvc.showNavibar = true;
  370. cvc.contact_type = @"Sales_Order_Customer";
  371. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  372. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  373. appDelegate.customerInfo = value;
  374. if(appDelegate.order_code==nil)
  375. [self neworder:weakcvc selectorholder:holder selector:addtocart];
  376. // neworder();
  377. // [main_vc checklogin:true];
  378. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  379. //
  380. // if(self.returnValue)
  381. // self.returnValue(value);
  382. };
  383. cvc.onCancel = ^(){
  384. [RAUtils message_box:@"New Order Error" message:@"Cannot create order without customer infomation." completion:nil];
  385. // self.disable_refresh = false;
  386. };
  387. cvc.onReset = ^(){
  388. // [main_vc checklogin:true];
  389. };
  390. [vc.navigationController pushViewController:cvc animated:true];
  391. }
  392. else
  393. {
  394. [self neworder:vc selectorholder:holder selector:addtocart];
  395. }
  396. }
  397. DebugLog(@"No");
  398. }];
  399. // [alertControl addAction:actionOne];
  400. [alertControl addAction:alertthree];
  401. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  402. }];
  403. [alertControl addAction:alertcancel];
  404. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  405. [vc presentViewController:alertControl animated:YES completion:nil];
  406. }
  407. else
  408. {
  409. [RAUtils message_box:@"Add To Cart" message:@"You donot have permission to access order" completion:nil];
  410. }
  411. }
  412. }
  413. else
  414. {
  415. [RAUtils message_box:@"Check Pending Order" message:[return_json valueForKey:@"err_msg"] completion:nil];
  416. }
  417. // }];
  418. }];
  419. // }];
  420. }
  421. }
  422. else
  423. {
  424. // if(appDelegate.order_code==nil)
  425. // [ self neworder];
  426. // else
  427. IMP imp = [holder methodForSelector:addtocart];
  428. void (*func)(id, SEL) = (void *)imp;
  429. func(holder, addtocart);
  430. // [holder performSelector:addtocart];
  431. }
  432. }
  433. }
  434. +(void) add_recent_model:(NSDictionary*) model
  435. {
  436. NSMutableDictionary * newdict = [[NSMutableDictionary alloc]init];
  437. [newdict setObject:model forKey:@"item_0"];
  438. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  439. int count=[appDelegate.recent_model[@"count"] intValue];
  440. for(int i=0;i<count;i++)
  441. {
  442. NSMutableDictionary * mitem= appDelegate.recent_model[[NSString stringWithFormat:@"item_%d",i]];
  443. NSString *mitemProductID = [NSString stringWithFormat:@"%@",mitem[@"product_id"]];
  444. NSString *modelProductID = [NSString stringWithFormat:@"%@",model[@"product_id"]];
  445. if([mitemProductID isEqualToString:modelProductID])
  446. continue;
  447. [newdict setObject:mitem forKey:[NSString stringWithFormat:@"item_%lu",(unsigned long)newdict.allKeys.count]];
  448. }
  449. newdict[@"count"]=[NSString stringWithFormat:@"%lu",(unsigned long)newdict.allKeys.count];
  450. appDelegate.recent_model = newdict;
  451. //
  452. //
  453. // if(!bexist)
  454. // {
  455. // [appDelegate.recent_model setObject:item forKey:[NSString stringWithFormat:@"item_%d",count]];
  456. // appDelegate.recent_model[@"count"]=[NSString stringWithFormat:@"%d",count+1];
  457. // }
  458. }
  459. @end