From 577399d2cb9b1371faf3ff3a5885300fc44879e1 Mon Sep 17 00:00:00 2001 From: Ming Date: Wed, 14 Jul 2010 03:02:06 +0000 Subject: [PATCH] issue #6: add getObjectAtIndex() to NSMutableArray --- cocos2dx/cocoa/NSMutableArray.cpp | 14 ++++++++++++++ cocos2dx/cocoa/NSMutableArray.h | 1 + 2 files changed, 15 insertions(+) diff --git a/cocos2dx/cocoa/NSMutableArray.cpp b/cocos2dx/cocoa/NSMutableArray.cpp index 4703d422e4..6342d0d71c 100644 --- a/cocos2dx/cocoa/NSMutableArray.cpp +++ b/cocos2dx/cocoa/NSMutableArray.cpp @@ -25,6 +25,7 @@ THE SOFTWARE. #include "NSMutableArray.h" #include #include +#include using namespace std; @@ -252,3 +253,16 @@ NSMutableArray* arrayWithArray(NSMutableArray *pArray) return pNewArray; } + +NSObject* NSMutableArray::getObjectAtIndex(UINT32 uIndex) +{ + assert(uIndex < count()); + assert(uIndex >= 0); + + if (uIndex <= 0 || uIndex >= count()) + { + return NULL; + } + + return m_array[uIndex]; +} diff --git a/cocos2dx/cocoa/NSMutableArray.h b/cocos2dx/cocoa/NSMutableArray.h index 7951482c63..d9dcb4570a 100644 --- a/cocos2dx/cocoa/NSMutableArray.h +++ b/cocos2dx/cocoa/NSMutableArray.h @@ -41,6 +41,7 @@ public: UINT32 getIndexOfObject(NSObject *pObject); bool containsObject(NSObject *pObject); NSObject* getLastObject(void); + NSObject* getObjectAtIndex(UINT32 uIndex); // Adding objects void addObject(NSObject *pObject);