xcode - Using arg[v] as int? - Objective C -


i'm trying pass arguments , integer variable @ start of program in xcode using objective c. far methods i've found have given me variety of error messages or crashed vm.

int numcols, numrows;  int main(int argc, const char * argv[]) { @autoreleasepool {      if (argc != 3){         nslog(@"%2s", "wrong number of arguments");         exit(1);     }      //numrows = (int)(argv[1] - '0');      //numcols = (int)(argv[2] - '0'); these lines cause crash     numrows = 3;     numcols = 4; 

i want numrows take first argument , numcols take second. went settings in xcode change starting arguments 3 , 4, if check them or print them come out random numbers.

first of question not clear, how understand can say. argc means argument count , argv means argument value. if want cast char int. try this

[[nsstring stringwithformat:@"%s", argv[2]] intvalue]; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -