Haruyuki Mohri

毛利春幸のブログです。

Try NSMutableArray using 10Seattle

the NSMutableArray of iOS I use in C++Builder 10Seattle.

It uses the iOS in C++Builder.
NSMutableArray is possible like append or remove objects.
A class to a more dynamic process NSArray.

include

#include <Macapi.ObjectiveC.hpp>
#include <Macapi.Helpers.hpp>

Two of the included is required.

code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    _di_NSMutableArray ar = TNSMutableArray::Create();
    for (int i = 0; i < 10; i++) {       //It will append the ten string.
        ar->addObject(StrToNSStr(L"日本語" + IntToStr(i))->init());
    }
    int test = ar->count();           //There were 10 objects in the array.

Take out the 10 objects that were appended to the array.
NSMutableArray Because the Delphi interface, I use _di_NSMutableArray.
It is no good by "new" in the case of this type.

 for (int i1 = 0; i1 < ar->count(); i1++) {      
        Memo1->Lines->Append(
            NSStrToStr(TNSString::Wrap( ar->objectAtIndex(i1)) )
        );
    }
}

Execution result.

f:id:mojeld:20160108135709j:plain