issue #6: add getObjectAtIndex() to NSMutableArray

This commit is contained in:
Ming 2010-07-14 03:02:06 +00:00
parent c39a43c0cc
commit 577399d2cb
2 changed files with 15 additions and 0 deletions

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
#include "NSMutableArray.h" #include "NSMutableArray.h"
#include <stdarg.h> #include <stdarg.h>
#include <vector> #include <vector>
#include <assert.h>
using namespace std; using namespace std;
@ -252,3 +253,16 @@ NSMutableArray* arrayWithArray(NSMutableArray *pArray)
return pNewArray; return pNewArray;
} }
NSObject* NSMutableArray::getObjectAtIndex(UINT32 uIndex)
{
assert(uIndex < count());
assert(uIndex >= 0);
if (uIndex <= 0 || uIndex >= count())
{
return NULL;
}
return m_array[uIndex];
}

View File

@ -41,6 +41,7 @@ public:
UINT32 getIndexOfObject(NSObject *pObject); UINT32 getIndexOfObject(NSObject *pObject);
bool containsObject(NSObject *pObject); bool containsObject(NSObject *pObject);
NSObject* getLastObject(void); NSObject* getLastObject(void);
NSObject* getObjectAtIndex(UINT32 uIndex);
// Adding objects // Adding objects
void addObject(NSObject *pObject); void addObject(NSObject *pObject);