NSArray Protected Access

Hi,

How do I get around this, I am getting protected access to NSArray

e.g.

NSArray < GKAchievement > arrayAchievement = new NSArray < GKAchievement > (achievement);

*error message: ‘NSArray(org.moe.natj.general.Pointer)’ has protected access in ‘apple.foundation.NSArray’

Thanks in advance.

Best regards,
mc

Dear le_mc,

to instantiate Objective-C classes, you need to use Objective-C methods:

NSArray arrayAchievement = NSArray.alloc().initWithObject(achievement);

Best Regards,
Kristóf

Hi Kristóf,

Thank you for your prompt response. I can’t search

NSArray.alloc().initWithObject…

Does NSArray.initWithObject(achievement) the same? As I couldn’t try out now.

Best regards,
mc

Dear le_mc,

sorry, I mixed it up with a factory method:

NSArray arrayAchievement = NSArray.arrayWithObject(achievement);

Best Regards,
Kristóf

2 Likes