iPhone应用程序崩溃在[NSString stringWithFormat] [英] iPhone app crash at [NSString stringWithFormat]

查看:582
本文介绍了iPhone应用程序崩溃在[NSString stringWithFormat]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了欺骗的错误,任何一个可以帮助他解决这个问题。
当我向服务器发送查询时,应用程序在将查询发送到服务器之前崩溃。

Hi I am getting the fowling error can any one help he in solving the issue. when I am sending the query to server the app is crashing before sending the query to server.

> " (lldb) bt
> * thread #1: tid = 0x2503, 0x38a4f5d0 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x70706118)
>     frame #0: 0x38a4f5d0 libobjc.A.dylib`objc_msgSend + 16
>     frame #1: 0x323169f0 Foundation`_NSDescriptionWithLocaleFunc + 52
>     frame #2: 0x399dc430 CoreFoundation`__CFStringAppendFormatCore + 11160
>     frame #3: 0x399538a2 CoreFoundation`_CFStringCreateWithFormatAndArgumentsAux + 74
>     frame #4: 0x3231650c Foundation`+[NSString stringWithFormat:] + 60
>     frame #5: 0x0012a92c App`-[merchantListViewController getMerchantsData] + 1344 at merchantListViewController.m:754
>     frame #6: 0x00127a3e App`-[merchantListViewController loadMoreButtonClicked:] + 194 at merchantListViewController.m:353
>     frame #7: 0x0012b0e4 App`-[merchantListViewController tableView:willDisplayCell:forRowAtIndexPath:] + 228 at
> merchantListViewController.m:903
>     frame #8: 0x332565aa UIKit`-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 514
>     frame #9: 0x3323b360 UIKit`-[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1316
>     frame #10: 0x332527fe UIKit`-[UITableView layoutSubviews] + 206
>     frame #11: 0x3320e896 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 258
>     frame #12: 0x392cc4ea QuartzCore`-[CALayer layoutSublayers] + 214
>     frame #13: 0x392cc08c QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 460
>     frame #14: 0x392ccfb0 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) +
> 16
>     frame #15: 0x392cc99a QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 238
>     frame #16: 0x392cc7ac QuartzCore`CA::Transaction::commit() + 316
>     frame #17: 0x392cc610 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*,
> unsigned long, void*) + 60
>     frame #18: 0x399d0940 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
> + 20
>     frame #19: 0x399cec38 CoreFoundation`__CFRunLoopDoObservers + 276
>     frame #20: 0x399cef92 CoreFoundation`__CFRunLoopRun + 746
>     frame #21: 0x3994223c CoreFoundation`CFRunLoopRunSpecific + 356
>     frame #22: 0x399420c8 CoreFoundation`CFRunLoopRunInMode + 104
>     frame #23: 0x39a9e33a GraphicsServices`GSEventRunModal + 74
>     frame #24: 0x3325f290 UIKit`UIApplicationMain + 1120
>     frame #25: 0x000dd2d8 App`main + 152 at main.m:15 "

对于json post请求

this is the code for the json post request

sessionId =[[NSUserDefaults standardUserDefaults] objectForKey:@"session_id"];
        shouldReloadData=NO;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getMerchantsListData:) name:@"getMerchantsListData" object:nil];
        NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                latitude,@"latitude",
                                longitude,@"longitude",
                                //[NSString stringWithFormat:@"%d",categoryID],@"category_id",
                                [NSString stringWithFormat:@"%d",sortOrderID],@"sort_order",
                                @"5",@"page_size",
                                [NSString stringWithFormat:@"%@",searchMerchant.text],@"search_keyword",
                                [NSString stringWithFormat:@"%d",pageNumber],@"page_number",
                                sessionId,@"session_id",
                                nil];
        //searchKeyword=@"";
        NSLog(@"params %@",params);

        [[UFNetworking dataSourceInstance] getData:params toAPI:kGetMerchantList cache:NO secure:NO notification:@"getMerchantsListData"];


推荐答案

   NSString *sort_order = [NSString stringWithFormat:@"%d",sortOrderID];
   NSString *search_keyword = [NSString stringWithFormat:@"%@",searchMerchant.text];
   NSString *page_number = [NSString stringWithFormat:@"%d",pageNumber];

   NSLog(@"\n\n Sort Order ==> %@, Search_keyWord ==> %@,Page_Number ==> %@",sort_order,search_keyword,page_number); /// check here what you get from the code..

   NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                latitude,@"latitude",
                                longitude,@"longitude",
                                //[NSString stringWithFormat:@"%d",categoryID],@"category_id",
                                sort_order,@"sort_order",
                                @"5",@"page_size",
                                search_keyword,@"search_keyword",
                                page_number,@"page_number",
                                sessionId,@"session_id",
                                nil];

我希望这个答案对你有帮助..

i hope this answer helpful to you..

这篇关于iPhone应用程序崩溃在[NSString stringWithFormat]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆