views:

43

answers:

1

Hi friends, my application is crashing when I enter an ' (apostrophe) in the textfield. Can anyone please tell the solution for the problem. Below is the place where it crashes

hotelTextfield.text =  [hotelList objectAtIndex:indexPath.row];

I entered other strings in the textfield but those didn't cause any issue. But whenever I enter some ', it crashes. Please find the stack backtrace for the crash

Program received signal:  “EXC_BAD_ACCESS”.
(gdb) bt
#0  0x31ec3ebc in objc_msgSend ()
#1  0x31ec5b3c in objc_setProperty ()
#2  0x0000e720 in -[AvailabilityVC setHotelList:] (self=0x11fbe0, _cmd=0x1f700, _value=0x31ec3f28) at /Users/amitkumar_gupta/Documents/Projects/5StarHotels/Classes/AvailabilityVC.m:29
#3  0x0000c6c8 in -[AvailabilityVC textFieldDidChange:] (self=0x11fbe0, _cmd=0x1f8e7, aNotification=0x1858a0) at /Users/amitkumar_gupta/Documents/Projects/5StarHotels/Classes/AvailabilityVC.m:248
#4  0x308ff5d8 in _nsnote_callback ()
#5  0x30de3510 in _CFXNotificationPostNotification ()
#6  0x308fd1b2 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7  0x308ff518 in -[NSNotificationCenter postNotificationName:object:] ()
#8  0x336b27f4 in -[UITextField fieldEditorDidChange:] ()
#9  0x335eecb4 in -[UIFieldEditor webViewDidChange:] ()
#10 0x308ff5d8 in _nsnote_callback ()
#11 0x30de3510 in _CFXNotificationPostNotification ()
#12 0x308fd1b2 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#13 0x30da38e4 in __invoking___ ()
#14 0x30df757a in -[NSInvocation invoke] ()
#15 0x311ca134 in SendDelegateMessage ()
#16 0x3069cb30 in WebEditorClient::respondToChangedContents ()
#17 0x3123c01c in WebCore::Editor::respondToChangedContents ()
#18 0x3123a914 in WebCore::Editor::appliedEditing ()
#19 0x3123a740 in WebCore::TypingCommand::typingAddedToOpenCommand ()
#20 0x3122aa10 in WebCore::TypingCommand::insertTextRunWithoutNewlines ()
#21 0x3122a954 in WebCore::TypingCommand::insertText ()
#22 0x3122947c in WebCore::TypingCommand::insertText ()
#23 0x31228bd4 in WebCore::Editor::insertTextWithoutSendingTextEvent ()
#24 0x31228818 in WebCore::EventHandler::defaultTextInputEventHandler ()
#25 0x311f776c in WebCore::EventTargetNode::defaultEventHandler ()
#26 0x311f7358 in WebCore::EventTargetNode::dispatchGenericEvent ()
#27 0x311f6cf8 in WebCore::EventTargetNode::dispatchEvent ()
#28 0x312284fc in WebCore::EventHandler::handleTextInputEvent ()
#29 0x312283e0 in WebCore::Editor::insertText ()
#30 0x3069bab8 in -[WebHTMLView(WebNSTextInputSupport) insertText:] ()
#31 0x30defa14 in -[NSObject performSelector:withObject:] ()
#32 0x31228280 in -[WAKResponder tryToPerform:with:] ()
#33 0x3069b3d0 in -[WebView(WebViewEditingActions) _performResponderOperation:with:] ()
#34 0x3069b350 in -[WebView(WebViewEditingActions) insertText:] ()
#35 0x3368dd2c in -[UIWebDocumentView insertText:] ()
#36 0x3368d7b0 in -[UIKeyboardImpl addInputString:fromVariantKey:] ()
#37 0x3368ca88 in -[UIKeyboardImpl handleStringInput:fromVariantKey:] ()
#38 0x3368c81c in -[UIKeyboardLayoutStar sendStringAction:forKey:] ()
#39 0x3368b8f0 in -[UIKeyboardLayoutStar touchUp:withPathInfo:] ()
#40 0x3368732c in -[UIKeyboardLayout handleHandEvent:] ()
#41 0x3368b414 in -[UIKeyboardLayout touchesEnded:withEvent:] ()
#42 0x33604900 in -[UIWindow _sendTouchesForEvent:] ()
#43 0x33603f94 in -[UIWindow sendEvent:] ()
#44 0x335ff790 in -[UIApplication sendEvent:] ()
#45 0x335ff094 in _UIApplicationHandleEvent ()
#46 0x332e8990 in PurpleEventCallback ()
#47 0x30de952a in CFRunLoopRunSpecific ()
#48 0x30de8c1e in CFRunLoopRunInMode ()
#49 0x332e7374 in GSEventRunModal ()
#50 0x335adc30 in -[UIApplication _run] ()
#51 0x335ac230 in UIApplicationMain ()
#52 0x00002550 in main (argc=1, argv=0x2ffff540) at /Users/amitkumar_gupta/Documents/Projects/5StarHotels/main.m:13
(gdb) 
A: 

OK, the problem is solved. It was due to the SQLite. the Sqlite wasn't able to handle the apostrophe('). Solved it by adding an extra ' before sending it to the SQLite.

Amit Gupta