Pre-set in the app is a pretty bad idea unless you really know what you are doing, or what you are protecting is not very important. It's pretty easy for someone with a jailbroken phone to look through your app code to find the password if it's stored in text.
ETA: If you post a little more about why you want it to work this way, we could give you some better advice.
Pre-set in the app is a pretty bad idea unless you really know what you are doing, or what you are protecting is not very important. It's pretty easy for someone with a jailbroken phone to look through your app code to find the password if it's stored in text.
ETA: If you post a little more about why you want it to work this way, we could give you some better advice.
people who jailbroke their phone can look at your code???
Not the source code, but they can see and patch the binary. And I think it takes more than just jailbreaking, but the way people pirate your program involves dumping the decoded binary that is running in memory.
If you read the tutorials on Pirate protection on this board, you'll see that pirates will often look at the raw code, and patch out parts to skip code. I'm pretty sure they will also be able to see any string constants you declare in your code.
The app is for the highschool yearbook. So hacking the password isn't going to be a big deal, I just want the password so that creepers can't look at it without having the supplied password..not worried about jailbreaks. So now that that is cleared up can you help me with some code? I can send you code sample if you need it. I just need to know how to hook up the password box to the password and such
All you need is a UITextView with the "secureTextEntry" property. It's a check box in Interface Builder, or a property on the object if you create it in code.
When the user presses the button, the password will be in the .text property. Just compare it to your password, and go from there.
I don't have any code to help, but it looks like all you need to do is change the code to setup the prompt to use self as a delegate:
Code:
delegate: self
add
Code:
<UIAlertViewDelegate>
to the definition of your view Controller in your .h file,
and create a clickedButtonAtIndex: method that reads the password:
Code:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([textField2.text isEqualToString: @"MyPassword"]) {
// Do something on good password
} else{
// Do something with bad password
}
I've not compiled this, so there might be minor syntax errors, but I think that's close enough to get you started.
it shows some errors that i'm not sure how to fix...on of them being wrong type arguments to unary minus...this was after i replaced alertView with *prompt..is it me or the code?
The best thing to do is copy and paste the lines of code, and the error messages. "Unary minus" makes me think you lost a semi-colon or bracket somewhere, so it thinks the "-" at the beginning of a method definition is a math symbol instead.
i was able to get the error messages to go away by adding the end bracket before -(void) i've goofed around with it with no luck..by changing alertView to prompt I get a blank white screen after i enter. I have no clue as to how to make this work..i keep getting the same thing i had before a password box that dosent' work, here is the code i have..
// set place
[prompt setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];
[prompt show];
[prompt release];
// set cursor and show keyboard
[textField2 becomeFirstResponder];
}
- (void)promptUIAlertView *)prompt clickedButtonAtIndexNSInteger)buttonIndex {
if ([textField2.text isEqualToString: @"MyPassword"]) {
// Do something on good password
} else{
The code you posted is scrambled somehow. It looks like you are declaring the clickedButtonAtIndex method in the middle of the viewDidLoad method. It needs to be on its own. I don't see any problems other than that.
I really suck at this lol. I now placed the code under the bracket after the webView load request and i'm still having the same problem...what should I put in the if and else portion of the code..i've put [webView release]; and every release i can think of...i don't know if that what i'm supposed to put in there..The password screen just seems to go away no matter what..right now i can run the app but the password screen lets me enter whether there is a password or not. I really appreciate all your help on this you have helped me bunches already.
Don't beat yourself up, it sounds like you are just still very new at this. What do you want to happen when the user picks the wrong password? One easy way would be to have the UIAlertView come back up in the "else" part of the code after you've checked for a password. That way the user can't do anything until they get the password right.
alrighty, thank you very much! i was able to get it to work..you can stop replying now! i'm sure you super excited about that lol..thanks for everything