I’m doing some porting from Qt Cocos2d to iOS cocos2d, am using Objective-C++ as the language for minimal efforts, now I’m wrapping the NSMutableArray in a C++ class for easier porting, basically this is my class
QList.h
#ifndef QLIST_H
#define QLIST_H
#import <Foundation/Foundation.h>
class QList {
NSMutableArray* List;
public:
QList();
~QList();
void append(id);
id at (int i);
int size();
bool isEmpty();
id takeLast();
id last();
void prepend(id);
id takeAt(int i);
id takeFirst();
void clear();
};
#endif
QList.mm
#ifndef QLIST_MM
#define QLIST_MM
#import "QList.h"
QList::QList() {
List = [[NSMutableArray alloc] init];
}
QList::~QList() {
[List autorelease];
List = nil;
}
void QList::append(id object) {
[List addObject:object];
}
id QList::at(int i) {
return [List objectAtIndex:i];
}
int QList::size() {
return [List count];
}
bool QList::isEmpty() {
if ([List count] == 0)
return true;
return false;
}
id QList::takeLast() {
id temp = [List lastObject];
[List removeLastObject];
return temp;
}
id QList::last() {
return [List lastObject];
}
void QList::prepend(id object) {
[List insertObject:object atIndex:0];
}
id QList::takeAt(int i) {
id temp = [List objectAtIndex:i];
[List removeObjectAtIndex:i];
return temp;
}
id QList::takeFirst() {
return takeAt(0);
}
void QList::clear() {
[List removeAllObjects];
}
#endif
I’m recieving EXC_BAD_SIGNAL on this line
return [List count];
Could anyone help me, I much appreciate it, thanks in advance 🙂
There’s no problem with this, the problem was in this line
I was commenting it out until a later time so I can uncomment it, and it was trying to access that 🙂 Thanks!, if you have advice for this code, let me know 😛