objective c - iOS how to copy/reference a C-Array? -


i have 3 arrays ints (enums):

static int *openenv[] = {ingmenuitemlogon,ingmenuitemspace,ingmenuitemappointment,ingmenuiteminfo,ingmenuitemsettings}; static int *closedenv[] = {ingmenuitemlogoff,ingmenuitemspace,ingmenuitemoverview,ingmenuitemaccounts,ingmenuitemtransfer,ingmenuitemanalyse,ingmenuitemappointment,ingmenuiteminfo,ingmenuitemsettings}; int *currentenv[]; 

if user taps on button want currentenv change openenv or closedenv

- (void) tap {     if( closed ) currentenv = closedenv;     else currentenv = openenv; } 

but gives build errors. openenv , closedenv have 2 different sizes, should copy it? can makes reference or copy static array?

you have declared arrays of pointers int. correct be

static int openenv[] = {ingmenuitemlogon,ingmenuitemspace,ingmenuitemappointment,ingmenuiteminfo,ingmenuitemsettings}; static int closedenv[] = {ingmenuitemlogoff,ingmenuitemspace,ingmenuitemoverview,ingmenuitemaccounts,ingmenuitemtransfer,ingmenuitemanalyse,ingmenuitemappointment,ingmenuiteminfo,ingmenuitemsettings}; 

(without star *) declare arrays of int, and

int *currentenv; 

as pointer int. can assign e.g. currentenv = openenv currentenv points elemens of openenv.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -