嗨,我得到了错误,任何人都可以帮助他解决问题。 当我将查询发送到服务器时,应用程序在将查询发送到服务器之前崩溃。
> " (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 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"];
答案 0 :(得分:1)
首先在字符串变量中取这个值,然后像bellow一样传递给字典..
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];
我希望这个答案对你有帮助。
答案 1 :(得分:0)
我敢打赌你的格式化程序无效。确保您没有在%@
上使用int
或类似的内容。
答案 2 :(得分:0)
就我而言,我在印度尼西亚语中使用%
,因此我必须在本地化字符串中添加%%
,希望它能有所帮助!