Application error - debug says "objc_msgsend"

I started a 2d tile game for iphone, I will go directly to the class I have and the problem. I have completely 2 classes for now Tile, Table and Base main class Tile

`@interface Tile : NSObject { CCSprite *sprite; CCSprite *outline; int row,column; BOOL highLight; } 

@property (nonatomic , retain)CCSprite *sprite; @property (nonatomic , retain)CCSprite *outline;

@property (nonatomic, readonly) int row, column; @property (nonatomic , readwrite)BOOL highLight; -(id) initWithSpriteName: (NSString*)argSpriteName Row:(int)argRow Column:(int)argColumn Position:(CGPoint)argPosition;

@end`

Table

 `@interface Table : NSObject { CCLayer *layer; CGSize size; NSArray *icons; NSMutableArray *content; 

} @property(nonatomic, retain) NSMutableArray *content; @property(nonatomic, retain) CCLayer *layer; @property(nonatomic, readonly) CGSize size; -(id) initWithTableSize:(CGSize)argSize; -(void)render; -(Tile *) objectAtX: (int) x Y: (int) y; `

Call Class (Primary)

 @interface HelloWorld : CCLayer { CGSize size; Table *tableLayer; } @property (retain) Table *tableLayer; 
code>

Implementation

 -(id) init { // always call "super" init // Apple recommends to re-assign "self" with the "super" return value if( (self=[super init] )) { ...... tableLayer = [[Table alloc] initWithTableSize:CGSizeMake(4,7) ]; tableLayer.layer = self; [tableLayer render]; self.isTouchEnabled = YES; self.isAccelerometerEnabled = YES; [self schedule:@selector(render:)]; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 30)]; 

} return self; }

. . .

-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView: [touch view]]; CGPoint touchCorrected; touchCorrected.x = location.x; touchCorrected.y = 480 - location.y; int x = (int)(touchCorrected.x/48); int y = (int)(touchCorrected.y/48); printf("X = %d Y = %d \n",x,y); if (x!=0 && y!=0) { Tile *tile = [tableLayer objectAtX:(1) Y:(1)]; [tile setHighLight:YES]; } }

My program crashes when I call the next statement in the callback

  Tile *tile = [tableLayer objectAtX:(1) Y:(1)]; 

I read a few blogs, but itโ€™s really hard to find a messaging concept, could you explain to me what is causing the objc_msgsend application to crash.

+2
objective-c
Dec 22 2018-10-12T00:
source share
1 answer

This is most likely a memory management error. I would have looked at the Hamster Emporium blog post, โ€œSo you crashed in objc_msgSend () . โ€ It is very useful.

+7
Dec 22 '10 at 4:45
source share



All Articles