Yes mate already done, if you need it i will show you my version with the TAG implementation.
Try to do it by yourself, use the tag when you do a alert (myAlert.tag = 10000
and if the alert in the clicked is the tag you want you can process as you done.
If you need, i have also the EditBox that work much better than the AppGameKit one and you can use it everywhere without the annoying WaitInput.
It also have the "Move View Up" when it goes under the half size of the device
Mine don't need loops checks, but go directly to the variable you need
But anyway i'm happy you are learning Obj C that is very useful, expecially for things "Utility" like this.
Mixed with the AppGameKit is a great power....
Now i suggest you another thing...
In the template.h you need now to add this:
//Example variables but this is the concept
struct _Setting { bool myValue; int points; string nick; };
extern vector <_Setting> Setting;
In the template.cpp add this:
vector <_Setting> Setting(1);
....
....
void InitSettings(){
Settings[0].myValue = false;
Settings[0].points = 0;
Settings[0].nick = "Noname";
}
void app::Begin( void ){
....
InitSettings();
}
//Now if you use the alert with the edit inside you can do from the OBJ C
//the alert with chose your nick
Another gift for you ... (this is the one i use for the GG Basic to choose the filename and description.
You can do the same using the nickname.
!!!! REMEMBER !!!!
You need that loop run without do nothing sometimes, until the PAGE is changed by the OBJ C Clicked function.
I suggest to use a stupid PAGE called "Idle" that do nothing.
if(Page == "Idle"){
//Fake page wait the page change again
}
- (void) showAlertWithEdit: (NSString *)title :(NSString*) quale
{
if([quale isEqualToString:@"create"]){
UIAlertView *alert = [[UIAlertView alloc] init];
UILabel *filename_label;
UILabel *filename_desc;
UITextField *file_edit;
UITextField *file_desc;
alert.title = title;
alert.delegate = self;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"Create"];
alert.tag = 18000;
alert.message = @"\r\n\r\n\r\n\r\n";
filename_label = [[UILabel alloc] initWithFrame:CGRectMake(15, 60, 50, 25)];
filename_desc = [[UILabel alloc] initWithFrame:CGRectMake(15, 100, 50, 25)];
file_edit = [[UITextField alloc] initWithFrame:CGRectMake(70, 60, 200, 25)];
file_desc = [[UITextField alloc] initWithFrame:CGRectMake(70, 100, 200, 25)];
filename_label.text = @"File:";
filename_label.backgroundColor = [UIColor clearColor];
filename_label.textColor = [UIColor yellowColor];
filename_desc.text = @"Info:";
filename_desc.backgroundColor = [UIColor clearColor];
filename_desc.textColor = [UIColor greenColor];
[file_edit setTag:18001];
[file_edit setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[file_edit setAutocorrectionType:UITextAutocorrectionTypeNo];
file_edit.placeholder = @"Noname.php";
[file_edit setBackgroundColor:[UIColor whiteColor]];
file_edit.layer.cornerRadius = 3;
[file_edit becomeFirstResponder];
[file_desc setTag:18002];
[file_desc setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[file_desc setAutocorrectionType:UITextAutocorrectionTypeNo];
file_desc.placeholder = @"Description...";
[file_desc setBackgroundColor:[UIColor whiteColor]];
file_desc.layer.cornerRadius = 3;
[alert addSubview:filename_label];
[alert addSubview:file_edit];
[alert addSubview:filename_desc];
[alert addSubview:file_desc];
[file_edit release];
[file_desc release];
[filename_label release];
[filename_desc release];
[alert show];
[alert release];
}
}
- (void) alertView:(UIAlertView *) _alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(_alert.tag == 18000){
if(buttonIndex == 0){
Page = "Menu";
refresh_pages = 1;
} else if(buttonIndex == 1){
UITextField* filename = (UITextField*)[_alert viewWithTag:18001];
UITextField* descrizione = (UITextField*)[_alert viewWithTag:18002];
if([filename.text length] == 0 || [descrizione.text length] == 0){
.........
} else {
......
Page = "NewFile";
Opzioni[0].file_editable = true;
refresh_pagine = 1;
}
}
}
}
- (void) AuthLocalPlayer
{
//This happen when the authentication is done in Game Center
.....
Setting[0].nick = [GKLocalPlayer localPlayer].alias.UTF8String;
//if i remember well this is the way to retrieve the online nick
//So now you don't need to do Loop check to give variable to it's place.
}
So as you can see, you need to avoid the Loop too times, so better you do some struct that you can externalize in the .m code!!!
Do particularly attention to this, to learn another great thing:
UITextField* filename = (UITextField*)[_alert viewWithTag:18001];
We get it as a general Object, and we know what is it, so we declare it directly (UITextField*).
You can use this trick on other much Object. (In this case you know is an alert that include an edit view)
Enjoy!!!
Long life to Steve!