this is my coding am used to get local top 10 highscore but , debugging terminated error occurs.
[OFHighScoreService getPageWithLoggedInUserForLeaderboard: theLeaderboardID onSuccess:OFDelegate(self, #selector(_scoresDownloaded:))
onFailure:OFDelegate()];
selector:-
- (void)_scoresDownloaded:(OFPaginatedSeries*)page
{
NSMutableArray* highscores = nil;
if ([page count] > 0)
{
if ([[page objectAtIndex:0] isKindOfClass:[OFTableSectionDescription class]])
{
highscores = [(OFTableSectionDescription*)[page objectAtIndex:0] page].objects;
}
else
{
highscores = page.objects;
}
}
NSString *userID = [OpenFeint lastLoggedInUserName];
for (OFHighScore* score in highscores)
{
ccColor3B theColor = ccBLACK;
if ([score.user.name isEqualToString: userID] ) {
//score now contains the users data... Do what I want with it.
NSLog(#"%d %# %d", score.rank, score.user.name, score.score);
break;
}
}
}
this is my console window error:-
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Levelone canReceiveCallbacksNow]: unrecognized selector sent to instance 0x6af2070'
*** Call stack at first throw:
terminate called after throwing an instance of 'NSException'
As the error says, the object you are using as the callback delegate for OFHighScoreService does not recognize the selector canReceiveCallbacksNow. As per OpenFeint documentation, your callback must implement the OFCallbackable protocol which defines this. Simply implement the function, e.g. just have it return YES all the time.
OpenFeint only stores the latest qualifying score per player on a given leaderboard. No user would ever appear ranked at more than one slot on a leaderboard.
Related
I'm developing tweaks for jailbroken iphone, iOS 7, and I have a problem that I can't solve for a while,
is it possible to close all apps running in the background directly from Springboard without opening the background switcher panel?
All the tweaks and source codes I've seen, like Purge, Slide2Kill working from the app switcher panel using self for the controller.
I've tried the following ways:
SBAppSliderController* switcherController = MSHookIvar<SBAppSliderController*>(self, "_switcherController");
//or
SBUIController *sharedUI = [objc_getClass("SBUIController") sharedInstance];
SBAppSliderController * switcherController = [sharedUI _appSliderController];
//tried this:
SBAppSliderController * switcherController = [sharedUI _switcherController];
//and
SBAppSliderController * switcherController = MSHookIvar<SBAppSliderController *>(sharedUI, "_switcherController");
To quit all apps I need to call _quitAppAtIndex with all application index available
[switcherController _quitAppAtIndex:appIndex];
%hook SBAppSliderController
- (void)_quitAppAtIndex:(unsigned int)arg1
{
%log;
if (arg1 == 0) {
for (NSString *appID in [self applicationList]) {
if (![appID isEqualToString:#"com.apple.springboard"])
[self _quitAppAtIndex:[[self applicationList] indexOfObject:appID]];
}
}
else
%orig;
}
Every time I call the function I get the next error, even if I want to close only one app, and I call it with specific index:
: -[ _quitAppAtIndex:1]
: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSDictionaryM removeObjectForKey:]: key cannot be nil'
What I'm doing wrong? any help would be appreciated
Thank you.
You have to toggle switcher first, this code works for me:
static SBAppSliderController *_localSBAppSliderC = nil;
%hook SBAppSliderController
-(id)init {
%log;
id r = %orig;
_localSBAppSliderC = (SBAppSliderController *)r;
NSLog(#" = %#", r);
return r;
}
%end
-(void) KillAllApps {
SBUIController * SBUIC = [objc_getClass("SBUIController") sharedInstance];
[SBUIC _toggleSwitcher];
if (_localSBAppSliderC) {
NSLog(#"----------applist %#",[_localSBAppSliderC applicationList]);
for (NSString *identifier in [_localSBAppSliderC applicationList]) {
if ( ![identifier isEqualToString:#"com.apple.springboard"] )
{
int index = [[_localSBAppSliderC applicationList] indexOfObject:identifier];
NSLog(#"---_quitAppAtIndex: %d",index);
[_localSBAppSliderC _quitAppAtIndex:index];
}
}
[SBUIC dismissSwitcherAnimated:YES];
}
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];
}
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.
I get the following error after I change the rootViewControler of my UIWindow.
2012-10-16 15:12:35.653 repdocApp[22898:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914'
The strange thing is, it only occurs if I have a line in my code which will never be executed at this time.
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
AppDelegate *app = (AppDelegate *) [[UIApplication sharedApplication] delegate];
OverviewModel *model = [self.dataArray objectAtIndex:indexPath.row];
if (model.modelType == ModelTypeCatalog)
{
NSLog(#"HERE");
if (app.window.rootViewController == app.catalogViewController)
{
return;
}
// with this return no error but this branch is never executed
// return;
[UIView transitionFromView:app.window.rootViewController.view
toView:app.catalogViewController.view
duration:0.45f
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished){
app.window.rootViewController = app.catalogViewController;
}];
}
else
{
if (app.window.rootViewController == app.catalogViewController)
{
[app.navigationPopoverController dismissPopoverAnimated:NO];
[UIView transitionFromView:app.window.rootViewController.view
toView:app.splitViewController.view
duration:0.45f
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished){
app.window.rootViewController = app.splitViewController;
}];
}
}
}
I search the whole internet but I found nothing about +[NSNotificationCenter dictationViewClass] or what this can be.
EDIT:
I notice now, it only happens if I change the rootViewController in a transition, if I do it directly no error happens.
Your Error Log is 2012-10-16 15:12:35.653 repdocApp[22898:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914
You are calling wrong method .dictationViewClass does not exist in ios.
It's Simply mean you are trying to call a methods which is not exist for Corresponding Class (NSNotificationCenter).
You should Change set Notification as below
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(yourMethodWantToExcute:) name:#"NSNotificationName" object:nil];
I hope It'll be helpful to You.
unrecognized selector sent to class means that there is no such method defined for this class. Try:
Delete the line and try if it works.
Look for a category withn your sources if it contains this method
Write your own blank method with the same name
Try to figure ouy what this method meant to do and implement it
Its not a real answer on this but the same error happens on different actions again regardless of an animation.
The problem seems to be the change of the rootviewcontroller, I replace that with a hidden tabbarcontroller and switch between the tabs and the problem is gone.
In my iphone game, when run on the ios 4.0 simulator everything works fine. However when running with the 5.0 simulator or on a 5.0+ device, the app crashes on the first level leaving an error:
Terminating app due to uncaught exception 'NSGenericException', reason:
*** Collection <__NSArrayM: 0x1416eea0> was mutated while being enumerated.
*** First throw call stack:
(0x1d6a052 0x20d0d0a 0x1d69c21 0x6f8e 0x8bd48 0x94020 0xba169 0xbcee4 0x85a2db 0x85a1af 0x1d3e966 0x1d3e407 0x1ca17c0 0x1ca0db4 0x1ca0ccb 0x2702879 0x270293e 0x90fa9b 0x1f31 0x1eb5 0x1)
terminate called throwing an exception(lldb)
I've think i've narrowed the problem down to this piece of code. I understand that the problem is removing objects within the for-loop but cannot seem to figure out a solution.
Here is my code:
//remove the projectile
for (CCSprite *projectile in projectilesToDelete) {
[_projectiles removeObject:projectile];
[self removeChild:projectile cleanup:YES];
}
[projectilesToDelete release];
//remove the projectile
for (CCSprite *targetDel in targetsToDelete) {
targetDel.position = ccp(-2000, -2000);
[self removeChild:targetDel cleanup:YES];
[_targets removeObject:targetDel];
}
[targetsToDelete release];
Please help, been trying to figure out for the past few days.
In short, the expression:
for (OBJ * VAR in COLLECTION) {
uses a technique called Fast Enumeration. What happens here is the compiler inserts some hidden backing storage on the stack and requests a collection of elements from a type which may be enumerated. Because it grabs many objects at once and iterates over them, it is an error to mutate the container (COLLECTION) while it is being enumerated because the stack area and the collection can fall out of sync.
The workaround is to avoid fast enumeration when you mutate what you are enumerating -- either that, or you could enumerate a copy in some cases. The standard for(i;c;e) loop does not use fast iteration -- but the for(in) does use it.
One way to alter the program to avoid fast enumeration errors is:
// remove the projectile
while (projectilesToDelete.count) {
CCSprite * projectile = projectilesToDelete[0];
[_projectiles removeObject:projectile];
[self removeChild:projectile cleanup:YES];
}
[projectilesToDelete release];
// remove the projectile
while (targetsToDelete.count) {
CCSprite * targetDel = targetsToDelete[0];
targetDel.position = ccp(-2000, -2000);
[self removeChild:targetDel cleanup:YES];
[_targets removeObject:targetDel];
}
[targetsToDelete release];
Problem with your code is that, consider this..... projectilesToDelete array has 3 elements(A, B, C)...
In first iteration, you removeObject(A).. at that array count becomes 2 i.e., array content will be (B, C) but it considers it to be 3(B,C, Nil).
So Array got modified while enumerating. So it will give an exception.
change the code to this
// get array length
int count = projectilesToDelete. length;
// iterate through the array
for (int iter = 0; iter < count; inter++)
{
CCSprite *projectile = projectilesToDelete [iter];
[_projectiles removeObject:projectile];
[self removeChild:projectile cleanup:YES];
// decrement count
count--;
iter--;
}