TWTweetComposeViewController crash ios5 - ios5

On iOS the "protocol" is that
id foo = [[SomeClass alloc] init]
[foo release]
should create an object "foo" with retainCount of 1 so that a release will free it.
The code below on iOS5 will yield a retainCount of 3.
TWTweetComposeViewController *twController = [[TWTweetComposeViewController alloc] init];
log_trace(#"twController (after construction) retain count %d", [twController retainCount]);
The problem is during a memory warning issued to the app will crash with
*** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <TWTweetComposeViewController 0x82a3980> for the key path "contentSize" from <UITextView 0x13f2e760> because it is not registered as an observer.'
I've checked iOS6 beta 1 builds and this behavior is fixed (as is the crash).
Which leads to a question: is there a way to walk around this somehow in iOS5.1 ?

Related

GKLeaderboard in SpriteKit?

How can I use a GKLeaderboard in SpriteKit ?
When I try to present a Leaderboard a got this issue.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x17017fb00'
First throw call stack:
(0x18df0ef50 0x19a4181fc 0x18df13c04 0x18df11930 0x18de315dc 0x100069e00 0x190ed8670 0x190ed83f4 0x190fccd08 0x18df13700 0x18de2ceec 0x1911d5ee4 0x18ed278dc 0x18df13700 0x18de2ceec 0x19a9f0014 0x19a9effd4 0x19a9f31dc 0x18decec2c 0x18deccf6c 0x18de0dc20 0x193af5c0c 0x190f3efdc 0x1000dcb34 0x19aa0baa0)
libc++abi.dylib: terminating with uncaught exception of type NSException**
My Method to show the leaderboard:
-(void) showLeader
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController:leaderboardController animated:YES];
}
}
Thanks in advance!
presentModalViewController was deprecated in iOS 6. GKLeaderbardViewController is deprecated in iOS 7.
You an refer to this:
What should I use instead of deprecated GKLeaderboardViewController in iOS7?

Exception while setting property in subclass of MKMapView

I got a strange error. After I installed my test app in release mode I got an error:
[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40'
The Mapview was initialized and in the init method I was trying to deactivate the rotation. In the debugging mode it worked fine.
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setRotateEnabled:FALSE];
[self initDelegate];
}
return self;
}
Maybe someone knows what's going on? Thanks in advance.
It was a problem in the iOS version. RotateEnabled in available only in iOS7 like Suresh point out. I had to check if the property was there (or check if it has iOS7) like
if ([self respondsToSelector:NSSelectorFromString(elementName)])
{
[self setValue:elementInnerText forKey:elementName];
}

Cordiva CDVViewController crash gives 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'

I want create native ios app with "Cleaver" element WebView, but at compilation in simulator I get crash with error:
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
It's My code ViewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
CDVViewController* viewController = [CDVViewController new];
viewController.view.frame = CGRectMake(0, 40, 320, 450);
[self.view addSubview:viewController.view];
}
I got the same error. This is not a solution, but I got CDVViewController working using earlier version of PhoneGap (2.4.0) without problems.

creating chat room in QuickBlox

I am trying to create a chat room in QuickBlox using my iOS app.
[[QBChat instance] createPrivateRoomWithName:#"My Room"];
- (void)createPrivateRoomWithName:(QBChatRoom*)room{
NSLog(#"Private room %# was created", room.name);
// Add users to this room
NSNumber *anny = [NSNumber numberWithInt:300];
NSNumber *jim = [NSNumber numberWithInt:357];
NSArray *users = [NSArray arrayWithObjects:anny, jim, nil];
[[QBChat instance] addUsers:users toRoom:room];
}
but after using this code my application is crashing, below is the crash log.
2013-01-03 19:13:55.234 Chat.Points[11178:23d03] +[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c
2013-01-03 19:13:55.241 Chat.Points[11178:23d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c'
*** First throw call stack:
(0x32fe012 0x29eae7e 0x33892ad 0x32edbbc 0x32ed94e 0x101e05 0x2da153f 0x2db3014 0x2da3418 0x2da32a6 0x2da4280 0x2da3fcb 0x990f7b24 0x990f96fe)
libc++abi.dylib: terminate called throwing an exception
You have to login to QuickBlox Chat before creating room.
The solution is:
1) you have to add -ObjC flag to Other Linker Flags
2) Add to SplashController.h chat delegate QBChatDelegate
#interface SplashController : UIViewController <QBActionStatusDelegate, FBServiceResultDelegate, FBSessionDelegate, QBChatDelegate>{
3) Add to SplashController.m,
to if
}else if([result isKindOfClass:[QBMRegisterSubscriptionTaskResult class]]){
at the top next lines:
// Login to QuickBlox Chat
//
[[QBChat instance] setDelegate:self];
[DataManager shared].currentQBUser.password = [NSString stringWithFormat:#"%u", [[[DataManager shared].currentFBUser objectForKey:kId] hash]];
[[QBChat instance] loginWithUser:[DataManager shared].currentQBUser];
//
//
4) Finally, add to the end
#pragma mark-
#pragma mark QBChatDelegate
- (void)chatDidLogin{
[[QBChat instance] createPrivateRoomWithName:#"ChatRRoom"];
}
- (void)chatRoomDidCreate:(QBChatRoom *)room{
NSLog(#"Room did create %#", room);
myRoom = [room retain];
}
Just Add -ObjC flag in Other Linker Flags in your targets' settings. Hope it will solve your problem.

UIImagePickerController Camera Source causing the app to crash

I am getting "Received memory warning. Level = 1" when I use UIImagePickerControllerSourceTypeCamera.
If I access the camera immediately after entering the application, I get "Received memory warning. Level=1" but when I select the camera option after accessing all the other functionality in the application, the app crashes while the debugger console displays
Received memory warning. Level=1
Program received signal: “EXC_BAD_ACCESS”.
Why does this happen? I don't get any memory leaks notification when I build and analyze.
if(actionSheet.tag == 1){
addButton.enabled = YES;
UIImagePickerController * picker = [[[UIImagePickerController alloc] init] autorelease];
picker.delegate = self;
if (buttonIndex == 0)
{
NSLog(#"selecting camera");
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
else if (buttonIndex == 1){
NSLog(#"choosing album");
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}
else
{
//NSLog(#"cancel");
}
}
EXC_BAD_ACCESS normally is the opposite of a leak: An overreleased object. An object which retain count has dropped to 0 but you still hold a pointer to it somewhere. Once you access this pointer you may receive EXC_BAD_ACCESS, or other strange behavior.
There's other possibilities, too. It just means your trying to access memory, that you do not own.
In your case this does not necessarily have to do with the UIImagePickerController. The presenting of the picker just causes a memory warning to be posted, and in reaction to this warning your app releases memory in various different places. My guess is, that at least one of these objects has already been released before, and is a dangling pointer now.
To debug this you should try NSZombieEnabled. See this question for further help on finding this kind of bug: EXC_BAD_ACCESS signal received
P.S.: You should have found it when searching for for EXC_BAD_ACCESS
It is because the UIImagePicker fired your ViewDidUnload.
So that all the instance become Zombie.
Therefore, the direction to handle this problem is
"Why UIImagePicker" triggered the ViewDidUnload.
I have the same problem, and cannot found the solution yet.