Im sorta new to bluetooth programming on the iPhone and i wanted to set up a PeerToPeer bluetooth connectivity between two iOS devices. I followed the steps in this tutorial
http://www.devx.com/wireless/Article/43502/0/page/1
and everything happens as it should until i get the accept or decline option when another device has been detected.
As soon as i choose accept, the app crashes on BOTH devices. And the error message shown is this:-
wait_fences: failed to receive reply: 10004003
2012-03-05 15:40:25.809 Bluetooth[204:707] -[ViewController session:didFailWithError:]: unrecognized selector sent to instance 0x367fe0
2012-03-05 15:40:25.811 Bluetooth[204:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController session:didFailWithError:]: unrecognized selector sent to instance 0x367fe0'
Anybody know whats going on?
Thanks in advance!
Just copy pasting this from coments below in the link you posted:
In case people weren't able to build and run successfully, you need to import the GameKit framework (rightclick frameworks folder > existing frameworks > GameKit.framework)
Add, to the BluetoothViewController.h file:
#import "GameKit/GKSession.h"
#import "GameKit/GKPeerPickerController.h"
Found out the problem. Made a rather silly mistake!
Ive written a method as follows
- (void)peerPickerController:(GKPeerPickerController *)picker
didConnectPeer:(NSString *)peerID
toSession:(GKSession *) session {
and in it i set up the app to receive data via bluetooth using
[session setDataReceiveHandler:self withContext:nil];
I thought i would check if the connection is established first and then think about the data transfer. But turns out you can't do that coz the data handler has been set and i had not implemented it in self. When i did write that though, it worked fine!
Hope, this stope people from committing such obvious mistakes!
Related
I searched SO but didnt find any accurate answer for this.
I am implementing Event Kit in my app.I am programatically implementing creation of events,
But I am not specifying any calendar there.Then I am using the EKEventViewController to Edit my events.I am using the Kal library as well to show the calendar.Every time I edit the second or 3rd so on event, or event delete the event, My app crashes, It is saying that event store is changed.I am not able to solve this issue.
Can anyone help me in this.
Here is the Crash Log..
terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM eventStoreChanged:]: unrecognized selector sent to instance 0x1fc7f040
Thanks
I had found the answer myself...If someone faces the same situation..Then here you go..
You need to set the eventstorechanged delegate to nil. And your problem would be solved.
Cheers
Sanjay
To Implement the Omniture Tracking in an iPhone Application, I have downloaded the AppMeasurement software from SiteCatalyst(AppMeasurement.h,libAppMeasurement.a,libAppMeasurementNoThumb.a).
I am using Omniture's app measurement iphone library, linked the release and dev libraries. I instantiate them using the singleton method (getInstance). Implemented as below
#import "OmnitureTracking.h"
#import "AppMeasurement.h"
AppMeasurement *s = nil;
#implementation OmnitureTracking
+ (void)beginTracking {
s = [[AppMeasurement getInstance] retain];
s.account = #"";
s.debugTracking = YES;
}
Calling this 'beginTracking' in AppDelegate to initiate the tracking, for pagetracking implemented another method as below:
+ (void)trackViewForPage:(NSString *)pageName {
NSLog(#"trackViewForPage::s instance::%#::",s);
if (s == nil)
return;
[s clearVars];
[s track:[NSDictionary dictionaryWithObjectsAndKeys:pageName, #"pageName", nil]];
}
Implementaion working fine and getting below log:
2012-06-21 01:53:20.953 MyApp[857:607] App Measurement Library compile time = Aug 4 2011 16:29:52
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
2012-06-21 01:53:21.795 MyApp[857:607]
Omniture App Measurement Debug: http://MyApp.net/b/ss/MyAppiosappdev/0/OIP-2.1.2/s2253418?AQB=1&ndh=1&t=21/5/2012%205%3A53%3A20%204%20240&vid=01398194867219045&ce=UTF-8&pageName=MyApp%201.2%20%281.2%29%20Launch&ts=2362139876678&events=event7%2Cevent5&c1=D%3Dv2&c2=D%3Dv6&c3=D%3Dv11&v2=MyApp%201.2%20%281.2%29&v4=0&v5=0&v6=20&v7=5&v8=Thursday&v9=4.3.3&v12=D%3Dv3&v13=D%3Dv3&s=320x480&c=24&AQE=1
But when app goes background and enters foreground, app is crashing because of Tracking and getting the log as below:
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::(
""
)::
Jun 21 03:07:41 unknown MyApp[467] <Error>: -[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0
Jun 21 03:07:41 unknown MyApp[467] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0'
"AppMeasurement" instance becoming nil or empty when app goes background and enters foreground, but I am not able to figure out whether its the Site Analyst iPhone Library issue or Coding issue.
To handle the crash,I have done the nil check, but its not falling under nil case.
Please help me in figuring out the "AppMeasurement" instance empty check and why "AppMeasurement" instance becoming empty when app goes background and enters foreground.
Thanks
Finally, i have figured out the things. Sorry for all the mishap.
All I am doing is using a 3rd party library to implement the Omniture Tracking for iPhone Application which is provided by Site Catalyst itself.
Please refer the below URL for library :
Site Catalyst Omniture library is intended for apps developed for all iOS devices, including iPhone, iPad and iPod Touch
There is problem with the library itself, its having lot of memory management issues.
They have provided new library with the memory leakage fixes.
Uploaded the new libraries to fix the issue.
Got the issue at the supporting class - OmnitureTracking.m, while setting the AppMeasurement.h Property :
//Use best practices plugin
s.useBestPractices = YES;
Because of this property, omniture tracking got called whenever app comes to active state i.e. launches. As the libaries having memory management issue, app getting crashed when ever app goes background and comes foreground.
Thanks for the replies.
But still one thing haunting me is how to check the empty instance of a class
If instance is there, its getting on NSLog as
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
But in error case getting the instance on NSLog as
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::("")::
By seeing that , i am thinking it as EMPTY INSTANCE case. How to check this case? Its not checking under nil check.
That code is a mess; hard to say what is wrong for the reasons mentioned in the comments on your question.
no method should be prefixed with get unless it is of a very special type
beginTracking leaks whatever is assigned to s
So... s is being assigned to an NSArray instance either because the poorly named getInstance is returning an NSArray or you are over-releasing that object.
I'm programming a metronome app that establishes a Bluetooth connection through GameKit and the PeerPickerController and then allows one device to send the controls through to the other, so if start is pressed on one device, the metronome starts on both.
The App loads fine and searches for other devices and says that its connected in the debugger window of Xcode, but then crashes immediately with this error:
wait_fences: failed to receive reply: 10004003
2012-05-27 20:51:50.820 MetroConnect[5689:707] -[MetroConnectViewController session:didFailWithError:]: unrecognized selector sent to instance 0x1793f0
2012-05-27 20:51:50.824 MetroConnect[5689:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MetroConnectViewController session:didFailWithError:]: unrecognized selector sent to instance 0x1793f0'
* First throw call stack:
(0x3126388f 0x375a1259 0x31266a9b 0x31265a83 0x311c0650 0x34141b5f 0x311c21fb 0x31b7f747 0x31237ad3 0x3123729f 0x31236045 0x311b94a5 0x311b936d 0x33233439 0x3091ccd5 0x5023 0x4fc8)
terminate called throwing an exception(lldb)
I was wondering if anyone could tell me where I'm going wrong? I have made a different App in a similar way that sends chat messages between two devices and that works fine and I can't see any differences between this implementation and the Metronome implementation.
It seems as though you are the GKSession delegate, yet don't implement the required delegate methods. They are required for a reason, after all. Implement the session:didFailWithError: method with something like this and check that you have the rest of them implemented properly:
- (void)session:(GKSession *)session didFailWithError:(NSError *)error {
NSLog(#"Session connection failed with error %#",[error localizedDescription]);
}
I'm wanting to have a bunch of people beta test my app on their phones soon. In the event that the app crashes, what's the best way for them to send me a bug report?
A good approach is to use a 3rd party service like Instabug which is a bug & crash reporting service that allows for two things:
Automatically receive crash reports in the event of a crash
Allow users to report bugs through a shake gesture in-app.
All reports arrive to your Instabug dashboard containing various details such as:
Network and console logs
Complete Device details
Visual reproduction steps
3D inspection of the current view hierarchy
Crash stack trace (In case of a crash report)
It only takes a line of code to integrate.
For full disclosure, I work at Instabug. Let me know if I can help.
My own experience: I used Flurry as the analytics tool in my project. I followed Flurry's recommendation and set up an uncaught exception listener inside my code.
void uncaughtExceptionHandler(NSException *exception) {
[FlurryAPI logError:#"Uncaught" message:#"Crash!" exception:exception];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAPI startSession:#"my_API_here"];
....
}
And then I tested my app, and after several hours' delay, I was able to see a few crashes reported to Flurry. Things like this:
NSInvalidArgumentException:
-[NSCFString objectAtIndex:]: unrecognized selector sent to instance
0x2e1b30 Msg: Crash!
It's neither complete nor thorough, but it was a convenient way to have a basic sense of what's going on out there in the wild.
Setup a database for it. Have a submit form that places their report into the database. This way any of the info they submit can be searched and managed easilly.
I'm writing an MKMapKit app that allows the user to drag around an annotation. Everything seems to work for the most part, but it crashes every now and then with the following message:
2009-09-27 12:34:18.903 iParkNow![7181:207] *** -[LBSGAddressComponent _mapkit_cache_heapTime]: unrecognized selector sent to instance 0x195320
2009-09-27 12:34:18.907 iParkNow![7181:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[LBSGAddressComponent _mapkit_cache_heapTime]: unrecognized selector sent to instance 0x195320'
I've had no luck googling for useful information and the iphone forums have nothing useful either. I haven't attached any code since its a bit long. Just wondering if anyone how any idea what would cause this error. Thanks in advance!
Do you try to reverse geocode more than one location at a time? This will cause the crash as of 3.1...So if the user is dragging and you start making calls to reverse geo code and keep them open as so many of them would be processing at one time then thats probably your problem.