I'm trying to support undo/redo in an iOS app that uses GLKit.
When I try the following:
GLKVector3 currentTranslation = _panningObject.translation;
[[self.undoManager prepareWithInvocationTarget:_panningObject] setTranslation:currentTranslation];
I get a crash:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSMethodSignature signatureWithObjCTypes:]: unsupported type encoding spec '(' in '4(_GLKVector3={?=fff}{?=fff}{?=fff}[3f])8''
Any ideas?
Still got no idea why GLKVector3 won't play nice, but I'm using this as a workaround:
- (void)setObject:(DrawableObject *)object translationX:(CGFloat)x y:(CGFloat)y z:(CGFloat)z {
GLKVector3 translation = GLKVector3Make(x, y, z);
GLKVector3 currentTranslation = object.translation;
[[self.undoManager prepareWithInvocationTarget:self] setObject:object
translationX:currentTranslation.x y:currentTranslation.y z:currentTranslation.z];
[object setTranslation:translation];
}
EDIT:
https://twitter.com/bddckr/status/370144778090192896
https://twitter.com/bddckr/status/370145021804425216
Related
Getting above error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCProgressTimer progressWithSprite:]: unrecognized selector sent to class 0x1a8194
here is my code
arrow_base = [CCSprite spriteWithFile:ARROW_OUTER];
arrow_base.position = ccp(m_pBullet.position.x,m_pBullet.position.y);
arrow = [CCProgressTimer progressWithSprite:#"arrow_inner.png"];//[CCSprite spriteWithFile:ARROW_INNER]];
arrow.type=kCCProgressTimerTypeHorizontalBarLR;
//arrow.type = kCCProgressTimerTypeBar;
// arrow.midpoint = ccp(0,0.5);
arrow.position = ccp(m_pBullet.position.x,m_pBullet.position.y);
arrow.percentage = 100;
[m_pBulletCover addChild:arrow_base];
[m_pBulletCover addChild:arrow];
progressWithSprite takes CCSprite object as input not NSString.
arrow = [CCProgressTimer progressWithSprite:[CCSprite spriteWithFile:#"arrow_inner.png"]];
i have check its library file,the error cause as there is no method ProgressWithSprite, instead of that its having progressWithFile method. May be its due to Cocos2d version problem as help provided by LearnCocos2d,
So i use it now and its working fine
arrow = [CCProgressTimer progressWithFile:#"arrow_inner.png"];
#define PROPERTY_SECTION 0
#define SUBTOTAL_ROW 0
UITableViewCell *subtotalCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:SUBTOTAL_ROW inSection:PROPERTY_SECTION]];
When i debug it in ios 6 it working perfect, But in ios 5 app crashed with following reason"
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSIndexPath indexPathForItem:inSection:]: unrecognized selector sent to class 0x1d41f20'
*** First throw call stack:
(0x26b4022 0x2083cd6 0x26b5aad 0x261aed0 0x261acb2 0xc956a 0xc9d4a 0xca3e9 0x12af38f 0x12af5eb 0x12bdb2b 0x12af38f 0x12af5eb 0x12b04ed 0x121da0c 0x26b5e99 0x121e464 0x121e495 0x1222fc1 0x121d14b 0x16864ce 0x162bd61 0x16114d0 0x12ae5ab 0x4ab35 0x14ade29 0x14ad133 0x14ae3bf 0x14b0a21 0x14b097c 0x14a93d7 0x268899e 0x261f640 0x25eb4c6 0x25ead84 0x25eac9b 0x2d167d8 0x2d1688a 0x11e6626 0x248d 0x23b5)
terminate called throwing an exception(lldb)
+ (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section; is a method only works in UICollectionView in iOS 6. You can't use it in UITableView in iOS 5.
you are probably looking for indexPathForRow:inSection:
Use
[NSIndexPath indexPathForRow:indexRow inSection:indexSection];
instead of
[NSIndexPath indexPathForItem:indexRow inSection:indexSection];
It must be a method that is added in iOS6, because it doesn't exist in the iOS5 documentation located here :
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/Reference/Reference.html
Edit: This method is only for a collection view, not a UITableView. Collection views are not supported in iOS 5
Im Extracting Data from NSMuableDictionary to NSString and try compering to String like this:
NSDictionary *error = [[NSDictionary alloc]init];
NSString *errorCode = [[NSString alloc]init];
error = [sing.globalCallsDitionary valueForKey:#"Error"];
NSLog(#"error code %#",[error valueForKey:#"error_code"]);
errorCode = [error valueForKey:#"error_code"];
if ([errorCode isEqualToString:#"-1"]) {
When the if statement executed i get this error talking about an array, the error looks like this:
2012-04-27 06:34:49.686 CallBiz[10319:707] error code (
"-1"
)
2012-04-27 06:35:00.602 CallBiz[10319:707] -[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x16fc10
2012-04-27 06:35:00.608 CallBiz[10319:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x16fc10'
*** First throw call stack:
(0x3541f88f 0x36846259 0x35422a9b 0x35421915 0x3537c650 0xb2a3 0x353793fd 0x32458faf 0x32458f6b 0x32458f49 0x32458cb9 0x324595f1 0x32457ad3 0x324574c1 0x3243d83d 0x3243d0e3 0x3667222b 0x353f3523 0x353f34c5 0x353f2313 0x353754a5 0x3537536d 0x36671439 0x3246be7d 0x2e61 0x28fc)
terminate called throwing an exception
It is as xCode is looking on my NSString *errorCode = [[NSString alloc]init]; as if it is an NSArray, can someone help me with this?
Error occurs because your errorCode came as a array, instead of string. If you are sure that only 1 object come here, then you can use -
if ([[errorCode objectAtIndex:0] isEqualToString:#"-1"])
It will work, although it will through a warning, because errorCode is defined as a string object. So you ned to sure what data you are getting in response and then define data structure appropriately.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I check if a UILabel's value is more than 0 in an if statement?
Why is the following code not working?
if([Period2 isEqualToString:#"PSHEEC"])
{
NSLog(#"TEST");
}
I am getting this error:
2011-12-02 08:45:52.579 iDHSB[7605:707] -[UILabel isEqualToString:]:
unrecognized selector sent to instance 0x4884c50 2011-12-02
08:45:52.581 iDHSB[7605:707] * Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UILabel
isEqualToString:]: unrecognized selector sent to instance 0x4884c50'
* First throw call stack: (0x323e28bf 0x35cfa1e5 0x323e5acb 0x323e4945 0x3233f680 0x3152b191 0x9c905 0x316cf871 0x323e5814
0x323407e1 0x323403ff 0x34767e5b 0x323e4ab3 0x3233f680 0x323e5814
0x323407e1 0x33dcb43d 0x33dde8dd 0x323b6b03 0x323b62cf 0x323b5075
0x323384d5 0x3233839d 0x378b7439 0x315558e1 0x2d77 0x27c0) terminate
called throwing an exception[Switching to process 7171 thread 0x1c03]
(gdb)
The error you are getting is propably due to memory mamagement issues, the pointer of Period2 is not pointing to you string any more and is now pointing to some label. Make sure you have retained it correctly.
On an other note, variable, properties, methods should not start with a capital, and if you label is a properties you should use self.period2 .
if period2 is your label use...
[period2.text isEqualToString:#"PSHEEC"]
It may be helpful
NSString *str = label.text;
if([str isEqualToString:#"PSHEEC"])
{
NSLog(#"Equal");
}
else
{
NSLog(#"Not Equal");
}
What is Period2? You can't test equivalence that way. If you want to test string equivalence, you need to do something like the following:
(assuming Period2 is an NSString)
if ([Period2 isEqualToString:#"PSHEEC]) {
NSLog(#"They are equal.");
}
Why am I getting NSFastEnumerationMutationHandler crash all of a sudden in my code. I am blank why this crash popped up all of a sudden and how to squash it.
Crash Error:
**** Terminating app due to uncaught exception 'NSGenericException', reason: '* **Collection <__NSArrayM: 0x610000859410> was mutated while being enumerated.'*
You must be trying to change an array while you using fast enumeration.
Example
for ( id anObject in anArray ) {
if ( /* anObject satisfies some condition */ ) {
[anArray removeObject:anObject];
}
}
That shouldn't be done. Use a different array or probably filteredArrayUsingPredicate: method to filter. Remedy, however, depends on what you're trying to do.
Came here looking for a solution and ended up taking a copy of the original array to get around the issue.
for (NSObject *object in [array copy]) {
if(condition) {
[array removeObject....]
break;
}
}