Unable to Show onComingCall ViewController for my iOS VoIP Application - ios

I want my App to show IncomingCall ViewController, when App Receives Some Incoming Call.
This is my Code that I uses to show Incoming Call.. From my ContactsViewController, which is Active View when Incoming Call take places.
- (void)showIncomigCallVC{
[self performSegueWithIdentifier:#"segueToIncomingCallVC" sender:nil];
}
This is my Code, that is called by Library.
/* Callback called by the library upon receiving incoming call */
static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
pjsip_rx_data *rdata)
{
pjsua_call_info ci;
PJ_UNUSED_ARG(acc_id);
PJ_UNUSED_ARG(rdata);
pjsua_call_get_info(call_id, &ci);
PJ_LOG(3,(THIS_FILE, "....\n\n\n Incoming call from %.*s!! \n\n\n",
(int)ci.remote_info.slen,
ci.remote_info.ptr));
ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init];
[incomingCallVC showIncomigCallVC];
/* Automatically answer incoming calls with 200/OK */
pjsua_call_answer(call_id, 200, NULL, NULL);
}
And This is my Console Output:
20:39:37.482 XCPjsua.c ......
Incoming call from <sip:eeshaMiss12#ekiga.net>!!
2017-01-16 20:39:37.494 simpleVoIP[922:19652] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ContactsViewController: 0x7bea3d00>) has no segue with identifier 'segueToIncomingCallVC''
*** First throw call stack:
(
0 CoreFoundation 0x03a14212 __exceptionPreprocess + 194
1 libobjc.A.dylib 0x034d3e66 objc_exception_throw + 52
2 UIKit 0x01a69893 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 simpleVoIP 0x00089ba6 -[ContactsViewController showIncomigCallVC] + 70
4 simpleVoIP 0x00086caf on_incoming_call + 255
5 simpleVoIP 0x000fc273 pjsua_call_on_incoming + 3811
6 simpleVoIP 0x00103294 mod_pjsua_on_rx_request + 84
7 simpleVoIP 0x0012938f pjsip_endpt_process_rx_data + 351
8 simpleVoIP 0x00128bf2 endpt_on_rx_msg + 546
9 simpleVoIP 0x0012fba1 pjsip_tpmgr_receive_packet + 849
10 simpleVoIP 0x001315ec udp_on_read_complete + 316
11 simpleVoIP 0x0014b8e0 ioqueue_dispatch_read_event + 704
12 simpleVoIP 0x0014d5b2 pj_ioqueue_poll + 946
13 simpleVoIP 0x001290c3 pjsip_endpt_handle_events2 + 163
14 simpleVoIP 0x00102023 worker_thread + 99
15 simpleVoIP 0x0014eb96 thread_main + 86
16 libsystem_pthread.dylib 0x04c8a11b _pthread_body + 184
17 libsystem_pthread.dylib 0x04c8a063 _pthread_body + 0
18 libsystem_pthread.dylib 0x04c8993e thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am Beginner, any Recommendation will be appreciated.. Thanks in Advance

You are experiencing the crash, because you are programatically allocating your ContactsViewController, instead of using from the storyboard.
When you do this:
ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init];
[incomingCallVC showIncomigCallVC];
You are creating an instance of ContactsViewController, what has nothing to do with the one created in our storyboard.
It would be possible to overcome on this, however, you are trying to make a segue call on a viewController, what has only been loaded to the memory, but is not visible at all. That will never work, it will always crash.
I would recommend to show your viewController, whatever is behind the segue, straight away, instead of creating a viewController and show it with a segue.
EDIT:
Using the code below, you should be able to present your desired UIViewController subclass from the end of your callback function.
// Lets get keywindow
UIWindow* keyWindow = [[[UIApplication sharedApplication] delegate] window];
keyWindow.frame = [UIScreen mainScreen].bounds;
// Lets get `IncomingCallViewController` from storyboard
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"TheNameOfYourStoryboard" bundle:nil];
// do not forget to set the identifier of your viewController on the storyboard as "IncomingCallViewController"
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"IncomingCallViewController"];
// Lets present the keyWindow from the main thread
dispatch_async(dispatch_get_main_queue(), ^{
keyWindow.rootViewController = vc;
[keyWindow makeKeyAndVisible];
});

Related

Crash after receiving a Voip Push

While testing Voip Pushes i came across this error
2016-10-19 14:03:26.809 linphone[332:33741] Can't endBackgroundTask: no background task exists with identifier c6, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Oct 19 14:03:26 linphone[332] <Notice>: ios/(honeAppDelegate.m:492 ) PushKit received with payload : <PKPushPayload: 0x14ee5b30>
Oct 19 14:03:26 linphone[332] <Notice>: ios/(honeAppDelegate.m:494 ) incoming voip notfication: {
aps = {
alert = Testando;
};
}
2016-10-19 14:03:26.818 linphone[332:33741] -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x18e5c760
2016-10-19 14:03:26.821 linphone[332:33741] Crash: -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x18e5c760
2016-10-19 14:03:26.902 linphone[332:33741] Stack Trace: (
0 CoreFoundation 0x24bff933 <redacted> + 150
1 libobjc.A.dylib 0x2439ae17 objc_exception_throw + 38
2 CoreFoundation 0x24c052b5 <redacted> + 0
3 CoreFoundation 0x24c02ee1 <redacted> + 700
4 CoreFoundation 0x24b2e238 _CF_forwarding_prep_0 + 24
5 linphone 0x0002ee2f -[LinphoneAppDelegate processRemoteNotification:] + 214
6 linphone 0x00030f15 __78-[LinphoneAppDelegate pushRegistry:didReceiveIncomingPushWithPayload:forType:]_block_invoke_2 + 96
7 libdispatch.dylib 0x012ddb7f _dispatch_call_block_and_release + 10
8 libdispatch.dylib 0x012ddb6b _dispatch_client_callout + 22
9 libdispatch.dylib 0x012e2655 _dispatch_main_queue_callback_4CF + 1680
10 CoreFoundation 0x24bc1b6d <redacted> + 8
11 CoreFoundation 0x24bc0067 <redacted> + 1574
12 CoreFoundation 0x24b0f229 CFRunLoopRunSpecific + 520
13 CoreFoundation 0x24b0f015 CFRunLoopRunInMode + 108
14 GraphicsServices 0x260ffac9 GSEventRunModal + 160
15 UIKit 0x291e3189 UIApplicationMain + 144
16 linphone 0x0002b949 main + 124
17 libdyld.dylib 0x247b7873 <redacted> + 2
)
2016-10-19 14:03:26.907 linphone[332:33741] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x18e5c760'
*** First throw call stack:
(0x24bff91b 0x2439ae17 0x24c052b5 0x24c02ee1 0x24b2e238 0x2ee2f 0x30f15 0x12ddb7f 0x12ddb6b 0x12e2655 0x24bc1b6d 0x24bc0067 0x24b0f229 0x24b0f015 0x260ffac9 0x291e3189 0x2b949 0x247b7873)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is the code XCode points me to when the app crashes.
- (void)processRemoteNotification:(NSDictionary *)userInfo {
NSDictionary *aps = [userInfo objectForKey:#"aps"];
if (aps != nil) {
NSDictionary *alert = [aps objectForKey:#"alert"];
if (alert != nil) {
NSString *loc_key = [alert objectForKey:#"loc-key"];
/* if we receive a remote notification, it is probably because our TCP background socket was no more working.
As a result, break it and refresh registers in order to make sure to receive incoming INVITE or MESSAGE*/
if (linphone_core_get_calls(LC) == NULL) { // if there are calls, obviously our TCP socket shall be working
//linphone_core_set_network_reachable(LC, FALSE);
if (!linphone_core_is_network_reachable(LC)) {
LinphoneManager.instance.connectivity = none; //Force connectivity to be discovered again
[LinphoneManager.instance setupNetworkReachabilityCallback];
}
if (loc_key != nil) {
NSString *callId = [userInfo objectForKey:#"call-id"];
if (callId != nil) {
[LinphoneManager.instance addPushCallId:callId];
} else {
LOGE(#"PushNotification: does not have call-id yet, fix it !");
}
if ([loc_key isEqualToString:#"IC_MSG"]) {
[self fixRing];
}
}
}
}
}
LOGI(#"Notification %# processed", userInfo.description);
}
As you can see, I do receive the push notification but only on the log, it wont pop on my phone and the app crashes.
You are accessing the value for key "loc-key" in "alert" dictionary and in the payload "alert" dictionary doesn't have the value for this key, therefore it is crashing at NSString *loc_key = [alert objectForKey:#"loc-key"];
I ran into the same issue. The server side was pushing notifications containing only the "Incoming Notification" string. Thus, the objectForKey:#"loc-key" would crash - The push notification did not contain strings in the expected format. To work around this, I checked the contents of the push notifications from the server. For legacy push servers, a comparison of alert to "Incoming Notification" would yield true. In this case, I would then set alert to nil to bypass the crash.
NSDictionary *alert = [aps objectForKey:#"alert"];
BOOL result = [alert isEqual:#"Incoming Notification"];
if (result == true)
{
if (linphone_core_get_calls(LC) == NULL) { // if there are calls, obviously our TCP socket shall be working
if (!linphone_core_is_network_reachable(LC)) {
LinphoneManager.instance.connectivity = none; //Force connectivity to be discovered again
[LinphoneManager.instance setupNetworkReachabilityCallback];
}
}
alert = nil;
}
if (alert != nil) {
...
}

GMSPolygon array iOS crash

I Have an extremely strange issue with the GMSPolygon object.
Just out of nowhere my code crashes with the error "Unrecognized selector send to instance 0x...."
(Yes it worked all day, and suddenly it starts crashing)
I am using an array of Polygons (to keep track of them and update them dynamically) and I initialize them as follows in my -viewDidLoad:
GMSPolygon *myPoly[50];
--
GMSMutablePath *path = [[GMSMutablePath alloc] init];
// set some fake coordinates, initializing a Polygon with an empty path seems to crash as well...
[path addCoordinate:CLLocationCoordinate2DMake(1,0)];
[path addCoordinate:CLLocationCoordinate2DMake(-1,0)];
[path addCoordinate:CLLocationCoordinate2DMake(0,1)];
for (int i=0;i<50;i++) {
myPoly[i] = [GMSPolygon polygonWithPath:path];
myPoly[i].map = nil;
}
Later on in my program I try to acces the object again in the same way, first set it to nil so it will be removed from the map, and then update and if necessary display it again
for (int i=0;i<50;i++) {
myPoly[i] = [GMSPolygon polygonWithPath:path];
myPoly[i].map = nil; <--------- CRASH
// Do other stuf here, update the Polygon data and if needed
// display again as follows:
myPoly[i].map = mapView_;
}
But it seems to crash..
Same thing happens if I put the GMSPolygon in an NSMutable array. Initializing the array is fine, but getting the GMSPolygon out of the array and setting the .map property gives the same crash..
UPDATE:
It seems be caused by the object Memory locations.. If it works fine, memory locations are as follows:
[0] GMSPolygon * 0x1558ed750 0x00000001558ed750 <--- viewDidLoad for-loop
[0] GMSPolygon * 0x1558ed750 0x00000001558ed750 <--- other function for-loop
When it crashes
[0] GMSPolygon * 0x12e7cbf30 0x000000012e7cbf30 <--- viewDidLoad for-loop
[0] GMSPolygon * 0x129d36630 0x0000000129d36630 <--- other function for-loop
The object is only initialized once in the viewDidLoad, nowhere else!
It obviously explains the crash if the objects memory location are different.. but what's happening here?
Any one an idea why?
UPDATE 2, Got Crash log now:
2016-04-14 15:16:49.618 myApp[1130:240689] -[GMSMutablePath setMap:]: unrecognized selector sent to instance 0x1540bb560
2016-04-14 15:16:49.627 myApp[1130:240689] void uncaughtExceptionHandler(NSException *__strong) [Line 354] CRASH: -[GMSMutablePath setMap:]: unrecognized selector sent to instance 0x1540bb560
2016-04-14 15:16:49.688 myApp[1130:240689] void uncaughtExceptionHandler(NSException *__strong) [Line 355] Stack Trace: (
0 CoreFoundation 0x0000000182ebee50 <redacted> + 148
1 libobjc.A.dylib 0x0000000182523f80 objc_exception_throw + 56
2 CoreFoundation 0x0000000182ec5ccc <redacted> + 0
3 CoreFoundation 0x0000000182ec2c74 <redacted> + 872
4 CoreFoundation 0x0000000182dc0d1c _CF_forwarding_prep_0 + 92
5 myApp 0x00000001001115a0 -[mapViewController plotPoly] + 2028
6 myApp 0x000000010012c944 -[mapViewController mapView:didChangeCameraPosition:] + 556
7 CoreFoundation 0x0000000182ec4ae0 <redacted> + 144
8 CoreFoundation 0x0000000182dbc548 <redacted> + 284
9 CoreFoundation 0x0000000182dc0e70 <redacted> + 60
10 myApp 0x0000000100203370 -[GMSDelegateForward forwardInvocation:] + 108
11 CoreFoundation 0x0000000182ec2aa4 <redacted> + 408
12 CoreFoundation 0x0000000182dc0d1c _CF_forwarding_prep_0 + 92
13 myApp 0x0000000100188fec -[GMSMapView updateWithCamera:] + 176
14 Foundation 0x0000000183893ffc <redacted> + 340
15 CoreFoundation 0x0000000182e75124 <redacted> + 24
16 CoreFoundation 0x0000000182e74bb8 <redacted> + 540
17 CoreFoundation 0x0000000182e728b8 <redacted> + 724
18 CoreFoundation 0x0000000182d9cd10 CFRunLoopRunSpecific + 384
19 GraphicsServices 0x0000000184684088 GSEventRunModal + 180
20 UIKit 0x0000000188069f70 UIApplicationMain + 204
21 myApp 0x000000010013dd3c main + 124
22 libdyld.dylib 0x000000018293a8b8 <redacted> + 4)
2016-04-14 15:16:49.700 myApp[1130:240689] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GMSMutablePath setMap:]: unrecognized selector sent to instance 0x1540bb560'
*** First throw call stack:
(0x182ebee38 0x182523f80 0x182ec5ccc 0x182ec2c74 0x182dc0d1c 0x1001115a0
0x10012c944 0x182ec4ae0 0x182dbc548 0x182dc0e70 0x100203370 0x182ec2aa4
0x182dc0d1c 0x100188fec 0x183893ffc 0x182e75124 0x182e74bb8 0x182e728b8
0x182d9cd10 0x184684088 0x188069f70 0x10013dd3c 0x18293a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am stunned now.
The initial initialization works fine, the Polygons are drawn as the should, but as soon as I call the function to redraw the polygons, the crash happens.. and strange enough now I see why it crashes, but I don't understand.. It changes the first 5 array entry's to GMSMutablePath and GMSPolyLine , instead of GMSPolygon ?!, see link to picture below.. And have no idea why, because I am 100% sure the array of GMSPolygon is not touched anywhere else in the mean time..
Picture of of change in Array type
I can't post a comment yet due to my reputation. Just like what Dan said, use NSArray or NSMutableArray to store your objects. Then do your stuff.
UPDATE:
Here are my suggestions:
Add All Exceptions to your breakpoint navigator.
Try testing your code without loop.
Try adding float values as your coordinates.
See example code below:
GMSMutablePath *prettyPoly = [GMSMutablePath path];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(52.506191, 1.83197)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(52.05249, 1.650696)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(51.92225, 1.321106)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(51.996719, 1.219482)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(52.049112, 1.244202)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(52.197507, 1.334839)];
[prettyPoly addCoordinate:CLLocationCoordinate2DMake(52.519564, 1.801758)];
GMSPolygon *polygon = [GMSPolygon polygonWithPath: prettyPoly];
polygon.fillColor = [UIColor colorWithRed:0 green:0.25 blue:0 alpha:0.3];
polygon.strokeColor = [UIColor greenColor];
polygon.strokeWidth = 5;
polygon.map = self.googleMap;
If everything failed:
- Refer to this doc: https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_polygon#properties
How about you try Polyline class and see this example: https://developers.google.com/maps/documentation/ios-sdk/shapes#add_a_polyline
Last, try seeking help from Google Forum, or from the repo of that library you are using.

tableView crashes on end up with more than 16 items

This is very confusing.
I have a UITableView, which updates and works fine until it gets more than 16 items then it crashes when trying to endUpdates after calling insertRowsAtIndexPaths.
The NSIndexPaths being added are all valid. -numberOfRowsInSection returns the correct number. It is not throwing an error related to the data set, rather it crashes with
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
when endUpdates is called on the tableView.
The data source is all there, the NSIndexPaths are fine. the code works fine between 0 and 16 rows, but when I add a 17th it crashes. Additionally if I start it with 22 items it works fine, when I add the 23rd it crashes... if I call reload data instead of doing the update and insert process it works fine, so it's nothing to do with the data itself, and it shouldn't be anything to do with how I'm inserting the rows since it works through 16...
I'm completely perplexed. Here is my update method. It is being called on the main thread at all times.
- (void)updateConversation:(NSNotification*)notification
{
NSDictionary *updateInfo = [notification userInfo];
//NSLog(#"Got update %#", updateInfo);
if ([[updateInfo objectForKey:#"success"] integerValue] == YES) {
[self updateConversationUI];
int addedStatementCount = [[updateInfo objectForKey:#"addedStatementCount"] intValue];
if (addedStatementCount > 0) {
//[self.tableView reloadData];
[self.tableView beginUpdates];
int previousStatmentCount = [[updateInfo objectForKey:#"previousStatmentCount"] intValue];
NSLog(#"owner %i, Was %i, now %i, change of %i", self.owner, previousStatmentCount, (int)self.conversation.statements.count, addedStatementCount);
NSMutableArray *rowPaths = [[NSMutableArray alloc] init];
for (int i = previousStatmentCount; i < previousStatmentCount + addedStatementCount; i++) {
NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:0];
[rowPaths addObject:path];
}
[self.tableView insertRowsAtIndexPaths:rowPaths withRowAnimation:UITableViewRowAnimationBottom];
[self.tableView endUpdates];
[self.tableView scrollToRowAtIndexPath:[rowPaths lastObject] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
}
}
The rest of the crash past [self.tableView endUpdates] is UITableView
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x000000010189b795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001015fe991 objc_exception_throw + 43
2 CoreFoundation 0x0000000101852564 -[__NSArrayM insertObject:atIndex:] + 820
3 UIKit 0x0000000100317900 __46-[UITableView _updateWithItems:updateSupport:]_block_invoke691 + 173
4 UIKit 0x00000001002b5daf +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 460
5 UIKit 0x00000001002b6004 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 57
6 UIKit 0x00000001003174cb -[UITableView _updateWithItems:updateSupport:] + 2632
7 UIKit 0x0000000100312b18 -[UITableView _endCellAnimationsWithContext:] + 11615
8 Dev App 0x0000000100006036 -[ConversationViewController updateConversation:] + 998
9 CoreFoundation 0x00000001018f121c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
10 CoreFoundation 0x000000010185370d _CFXNotificationPost + 2381
11 Dev App 0x00000001000055ac -[ConversationManager postNotification:] + 92
12 Foundation 0x0000000101204557 __NSThreadPerformPerform + 227
13 CoreFoundation 0x000000010182aec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x000000010182a792 __CFRunLoopDoSources0 + 242
15 CoreFoundation 0x000000010184661f __CFRunLoopRun + 767
16 CoreFoundation 0x0000000101845f33 CFRunLoopRunSpecific + 467
17 GraphicsServices 0x00000001039a23a0 GSEventRunModal + 161
18 UIKit 0x0000000100261043 UIApplicationMain + 1010
19 Dev App 0x0000000100003613 main + 115
20 libdyld.dylib 0x0000000101f2a5fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This seems like a bug in the OS, the stack would indicate that it's something to do with the animation block but it happens no matter what I set the animation to, including none.
And to re-state. This works through 16 items, then inserting items past that causes a crash. It is also called at initial setup to load data, and it will load any number of items there, including well over 16. But when called again, purely as an update from 16 or more to something higher it will crash.
Most bizarre issue I've yet to encounter with table views...
under iOS 7 on device and simulator, latest Xcode for reference.
It seems that the problem is caused by my call of scrollToRowAtIndexPath (even though it crashes before it gets there...) combined with implementing tableView:estimatedHeightForRowAtIndexPath: by removing the row height estimate the crash went away... still seems like a bug in the animation system for tables to me. Thankfully I don't need the estimated row height, I had forgotten I had implemented it (trying to play nice by iOS 7 bites me again).
Place strategic breakpoints when you are incrementing the statement count, go through the loop of adding the rows as many times as you need to, and locate the statement that it's causing the crash, at that moment take a look at your objects and look for nil values as the error you are having it's trying to insert a nil object(or un-existent) from an Array.
I would personally recommend you to go through this loop entirely while keeping an exe for the path and previous statement count .
NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:0];
in my case the tableView:heightForHeaderInSection: method has been missing,
hadn't implemented the tableView:estimatedHeightForRowAtIndexPath method so this also could be solving the problem if you aren't using tableView:estimatedHeightForRowAtIndexPath:
Your problem is that you don't update the dataSource the tableView is using.
if you insert a row, you need to insert the appropriate object to the array the tableView is using.
Goodluck!

Why my [UIScrollView removeFromSuperview] is crashing?

The crash log is below.
Do you know any particular reason why might [UIScrollView removeFromSuperview] can crash? The scrollview contains view hierarchy with different types of UIViews. I also finds that the ad hoc version crash often not the debug version. I could not find any reason for that.
Same viewcontroller is loaded in a different flow in iPhone that works fine. But in iPad it crashes.
In iPad, in a container view controller, only viewcontroler.view is loaded.
Incident Identifier: EE102239-34D1-4BE7-8B52-41F74AB26203
CrashReporter Key: 2b11ea2a01ac5618e199ffc5a1e1f321600bb6a9
Hardware Model: iPad3,4
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-06-18 15:19:16.132 +0200
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3bab7070 prepareForMethodLookup + 20
1 libobjc.A.dylib 0x3bab6fb2 lookUpMethod + 42
2 libobjc.A.dylib 0x3bab6f7e _class_lookupMethodAndLoadCache3 + 14
3 libobjc.A.dylib 0x3bab6638 objc_msgSend_uncached + 24
4 QuartzCore 0x357f2a72 CA::Layer::contents_visibility_changed(CA::Transaction*, bool) + 50
5 QuartzCore 0x357f29de CA::Layer::mark_visible(CA::Transaction*, bool) + 190
6 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
7 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
8 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
9 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
10 QuartzCore 0x357f28d2 CA::Layer::update_removed_sublayer(CA::Transaction*, unsigned int) + 18
11 QuartzCore 0x357f255a CA::Layer::remove_sublayer(CA::Transaction*, CALayer*) + 130
12 QuartzCore 0x357f246a CA::Layer::remove_from_superlayer() + 34
13 UIKit 0x35a6e92c -[UIView(Hierarchy) removeFromSuperview] + 144
14 UIKit 0x35b857bc -[UIScrollView removeFromSuperview] + 60
15 MyApp 0x000bde8a -[iPadNavigationController vcAnimationDone] (iPadNavigationController.m:400)
16 UIKit 0x35a55ab6 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 154
17 UIKit 0x35aca8f8 -[UIViewAnimationState animationDidStop:finished:] + 44
18 QuartzCore 0x35801304 CA::Layer::run_animation_callbacks(void*) + 204
19 libdispatch.dylib 0x3bed55d8 _dispatch_client_callout + 20
20 libdispatch.dylib 0x3bed8e40 _dispatch_main_queue_callback_4CF + 224
21 CoreFoundation 0x33c051ac __CFRunLoopRun + 1284
22 CoreFoundation 0x33b78238 CFRunLoopRunSpecific + 352
23 CoreFoundation 0x33b780c4 CFRunLoopRunInMode + 100
24 GraphicsServices 0x37733336 GSEventRunModal + 70
25 UIKit 0x35a942b4 UIApplicationMain + 1116
A few line from the code (as asked),
previous = showing;
showing = [ vc retain ];
showing.view.frame = startFrameIn;
[ container addSubview:showing.view ];
CGContextRef context = UIGraphicsGetCurrentContext();
[ UIView beginAnimations:nil context:context ];
[ UIView setAnimationDelegate:self ];
[ UIView setAnimationDidStopSelector:#selector(vcAnimationDone) ];
[ UIView setAnimationCurve:UIViewAnimationCurveEaseOut ];
[ UIView setAnimationDuration:0.4 ];
previous.view.frame = endFrameOut;
showing.view.frame = detailFrame;
[ UIView commitAnimations ];
}
- (void) vcAnimationDone {
if ( previous != nil ) {
if (previous.view.superview != nil) {
[previous.view removeFromSuperview];
}
[ previous release ];
previous = nil;
}
A very probable reason is that you are overreleasing your scrollview or one of the views inside it.
Calling removeFromSuperview then deallocates the view instead of simply decreasing the retain count.
Actually, if you are still stuck with non-ARC project, Static Code Analysis is very useful for this kind of bug. Retain/release balancing issues are hard to pin down, and nearly impossible with incomplete method so I suggest you post the full method body if possible.
Thanks everyone for your answers, tips and tricks. However one thing I want share with you is the cause of the crash. I found that the crash was at different thread in different times. I had several views loaded with button pressing/menu in my iPad app. Some of the button pressing fetch data from web service. So I was bit confused to get the cuase of crash, animation, or url connection etc... I tried with enabled NSZombie objects, but it did not show any information.
Then I tried with Guard Malloc. This only runs in Simulator. And magically I found the code point of crash. I have function to convert a hex string into data. There I have line of code to make a C string null terminated. where I assigned 0 at the last index. and that makes the crash!
tmpCh[count] = 0;
I do not why, but probably it takes some time in the memory management procedure in iOS so it crash at different thread at different times. But with Guard malloc in Simulator, it always point out here and when I rewrite the code, the crash is gone.
/* Converts a hex string to bytes.
Precondition:
. The hex string can be separated by space or not.
. the string length without space or 0x, must be even. 2 symbols for one byte/char
. sample input: 23 3A F1 OR 233AF1
*/
+ (NSData *) dataFromHexString:(NSString*)hexString
{
if (hexString.length < 1) {
return nil;
}
char * tmpCh = (char *) malloc([hexString length] * sizeof(char));
int count = 0;
for (int k=0; k<hexString.length;k++) {
char c = [hexString characterAtIndex:k];
if (c == (char)0x20) { //skip space
continue;
}
if (c == '0') { // skip 0x
if(k+1 < hexString.length){
if ([hexString characterAtIndex:k+1] == 'x'
|| [hexString characterAtIndex:k+1] == 'X' )
{
k = k + 1;
continue;
}
}
}
tmpCh[count] = c;
count++;
}
tmpCh[count] = 0; // make null terminated string
if (count % 2) {
return nil;
}
NSString *temp = [[NSString alloc] initWithUTF8String:tmpCh];
free(tmpCh);
if ([temp length] % 2 != 0) {
return nil;
}
NSMutableData *result = [[NSMutableData alloc] init];
unsigned char byte;
char hexChars[3] = {0};
for (int i=0; i < (temp.length/2); i++) {
hexChars[0] = [temp characterAtIndex:i*2];
hexChars[1] = [temp characterAtIndex:i*2+1];
if (![Util isValidChar:hexChars[0]] || ![Util isValidChar:hexChars[1]]) {
return nil;
}
byte = strtol(hexChars, NULL, 16);
[result appendBytes:&byte length:1];
}
NSData * data = [NSData dataWithData:result];
[result release];
return data;
}

Xcode 4 and "SIGABRT" error? (only for iphone though)

I'm new to ios development and to stackoverflow. I did try searching both stackoverflow and google before posting.
I built a simple little app, originally just left it an iphone only app, but decided to make it universal in the end. I, stupidly, was messing around when i was getting to know xcode 4 and switched it to universal and then back again so i had to recopy the project and do it again. This time i started it with a universal app. (Not when i created it but after i went to project and selected it there) It created the ipad folder and mainwindow-ipad.xib file but was empty of course since i didn't do anything yet. I had it set up as a tabbed based app so my iphone version had firstview and secondview nib files also, but the ipad version didn't. I set it all up in iphone version first and it worked fine. I then went and laid down the ipad version (i did eliminate the second tab from mainwindow-ipad because i didn't need it)
i then went and created a new nib file and placed it in the ipad folder along with "main-ipad.h" and "main-ipad.m". I copied my code and connected everything and it runs fine on ipad simulator but now when i try and run iphone simulator i get "SIGABRT error. I took a screen shot of it. I don't fully understand objective-c so i was hoping someone can help me? I can post any code or whatever you might need to help me with this error so just ask.
Appreciate any help and suggestions you may have!
Thanks!
[Okay i would have posted image but I can't since I'm a new user, instead i posted the line highlighted and the output from xcode]
Code for file with error:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //ERROR IS ON THIS LINE <-----
[pool release];
return retVal;
}
[OUTPUT]
2011-06-18 17:32:43.980 Price Assist[445:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e09cc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key finallabel.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc35a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f17313 objc_exception_throw + 44
2 CoreFoundation 0x00dc34e1 -[NSException raise] + 17
3 Foundation 0x00795677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x000c7628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x000c5134 -[UIViewController loadView] + 120
11 UIKit 0x000c500e -[UIViewController view] + 56
12 UIKit 0x00038d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
13 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
14 UIKit 0x00048ff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
15 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
16 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
17 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
18 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
19 UIKit 0x0001717a -[UIApplication _loadMainNibFile] + 172
20 UIKit 0x00017cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
21 UIKit 0x00022617 -[UIApplication handleEvent:withNewEvent:] + 1533
22 UIKit 0x0001aabf -[UIApplication sendEvent:] + 71
23 UIKit 0x0001ff2e _UIApplicationHandleEvent + 7576
24 GraphicsServices 0x00ffc992 PurpleEventCallback + 1550
25 CoreFoundation 0x00da4944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
26 CoreFoundation 0x00d04cf7 __CFRunLoopDoSource1 + 215
27 CoreFoundation 0x00d01f83 __CFRunLoopRun + 979
28 CoreFoundation 0x00d01840 CFRunLoopRunSpecific + 208
29 CoreFoundation 0x00d01761 CFRunLoopRunInMode + 97
30 UIKit 0x000177d2 -[UIApplication _run] + 623
31 UIKit 0x00023c93 UIApplicationMain + 1160
32 Price Assist 0x000029a9 main + 121
33 Price Assist 0x00002925 start + 53
)
terminate called after throwing an instance of 'NSException'
iPhone FirstView nib file .h code:
#interface FirstViewController : UIViewController {
IBOutlet UITextField *dollarinput;
IBOutlet UITextField *centsinput;
IBOutlet UIButton *combinevalue;
IBOutlet UITextField *percentoffinput;
IBOutlet UILabel *discountlabel;
IBOutlet UILabel *finallabel;
}
- (IBAction)calculate:(id)sender;
- (IBAction)backgroundTouched:(id)sender;
- (IBAction)autonext:(id)sender;
iPhone FirstView nib file .m code:
//
// FirstViewController.m
// Price Assist
//
// Created by Dustin Schreiber on 6/15/11.
// Copyright 2011 TheTechSphere.com. All rights reserved.
//
#import "FirstViewController.h"
#implementation FirstViewController
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
*/
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload
{
[percentoffinput release];
percentoffinput = nil;
[discountlabel release];
discountlabel = nil;
[finallabel release];
finallabel = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc
{
[percentoffinput release];
[discountlabel release];
[finallabel release];
[super dealloc];
}
- (IBAction)calculate:(id)sender {
if ([centsinput.text length] == 0){
centsinput.text = #"00";
}
if ([dollarinput.text length] == 0){
dollarinput.text = #"00";
}
if ([percentoffinput.text length] == 0){
percentoffinput.text = #"00";
}
double cDollars = [dollarinput.text doubleValue];
double cCents = [centsinput.text doubleValue];
double percentoff = [percentoffinput.text doubleValue] / 100;
NSString *ccDollars = [[NSNumber numberWithFloat:cDollars] stringValue];
NSString *ccCents = [[NSNumber numberWithFloat:cCents] stringValue];
NSString *placeholder = [NSString stringWithFormat:#"%#.%#", ccDollars, ccCents];
double combined = [placeholder doubleValue];
double discount = combined * percentoff;
NSString *discountholder2 =[NSString stringWithFormat:#"%.2f", discount];
discountlabel.text = discountholder2;
double newprice = (combined - discount);
NSString *str = [NSString stringWithFormat:#"%.2f", newprice];
finallabel.text = str;
dollarinput.text = ccDollars;
centsinput.text = ccCents;
percentoffinput.text = [[NSNumber numberWithFloat:percentoff] stringValue];
}
-(IBAction)backgroundTouched:(id)sender
{
[dollarinput resignFirstResponder];
[centsinput resignFirstResponder];
[percentoffinput resignFirstResponder];
}
- (IBAction)autonext:(id)sender {
if ([centsinput.text length ] >= 2) {
if ([centsinput.text length] > 2) {
centsinput.text = #"";
} else {
//next field
}
}
}
#end
Thanks again! If anyone has any suggestions for my code i'd love to here them! Like I said, I'm new to it and thats the only way i know to do this.
------------> If anyone wants, I'll upload the entire project folder. Just ask. Thank you guys for all the help. i'm a n00b with xcode so i haven't got it all down yet.
Project Zipped
Post some code where you use finallabel and try to debug your app so you can tell me the line just before the app crashes.
Option 2:
Try to set a BreakPoint in malloc_error_break so we can have more info about the error.
In XCode go to Run -> Show -> BreakPoints (or just cmd + option + B). Then double click to add a new symbol (symbolic breakpoint) and type in malloc_error_break then press enter.
Now run your app and paste your console text.
UPDATE If you need help http://developer.apple.com/library/mac/#recipes/xcode_help-breakpoint_navigator/articles/adding_a_symbolic_breakpoint.html
Check your connections inside your InterfaceBuilder, you may have it wrong with fianllabel.
Also check your Custom Class -> Class in your iphone XIB in your InterfaseBuilder
UPDATE
Go to Product -> Clean. Then Run.
The line UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); just means that an exception was thrown during the running of your program. This could range from a memory problem, to a simple runtime error. Look in the target debugger console; it will tell you where the error occurred.
Open "iOS Simulator" Menu in the upper left->Reset Content and Settings. Then quit the iOS simulator and Xcode, and then restart your computer. This will get rid of the other instance of the process.
This May work it's work for me...........
The problem is with your XIB file. This error generally occurs when your finalLabel is incorrectly hooked up or doesn't exist anymore. Check your connections in the Interface Builder once.
I also had this error. After spending so much time, I found how to fix it. First of all go the console and see where is the error (mine was related to storyboards and its code) The way I fixed my error was by going in story board. Below the iPhone screen, there will be small yellow button. Right click on it and you will see that is causing error. Delete(x) it if there is yellow error sign.
If this does not fix your error then try to make new project and then replace its blank files with old files of your old project. I had same error in very beginning and by doing this program run without any error.
Other people suggests by restarting your laptop and running it again, reseting the iOS simulator, or changing iOS debugger (however this does not work in latest x code since there is only one debugger)
Hope this helps

Resources