but then why is it crashing?
EDIT: nvm, I found that the reason for the crashing was the for loops, I calculated 7,800 loops for each time the button was pressed, that might be a little too much for the iPhone to handle, I'll try to reduce that and see how that effects the performance.
EDIT2: FIXED

DD I'll post the new code below to show how I resolved the problem (just in case you cared XD)
and btw, I don't plan on release this on the appstore, so it doesn't matter if I used the private API, but thanks for the tip anyway, I'll try to get into the habit of not using those.
Code:
#import "iEncryptViewController.h"
#import "table.h"
#import <iostream>
#import <string>
#define MAXLENGTH 30
@implementation iEncryptViewController
-(IBAction)encrypt {
UIAlertView *ealert = [[UIAlertView alloc]initWithTitle:@"Encrypt" message:@"Enter Text to encrypt" delegate:self cancelButtonTitle: nil otherButtonTitles:@"Encrypt", nil];
[ealert addTextFieldWithValue:nil label:@""];
[[ealert textField] setDelegate:self];
[[ealert textField] setKeyboardType:UIKeyboardTypeDefault];
[[ealert textField] setKeyboardAppearance:UIKeyboardAppearanceDefault];
[[ealert textField] setReturnKeyType:UIReturnKeyDone];
[[ealert textField] setAutocorrectionType:UITextAutocorrectionTypeNo];
ealert.tag = 1;
[ealert show];
[ealert release];
}
-(IBAction)decrypt {
UIAlertView *dalert = [[UIAlertView alloc]initWithTitle:@"Decrypt" message:@"Enter Text to decrypt" delegate:self cancelButtonTitle: nil otherButtonTitles:@"Decrypt", nil];
[dalert addTextFieldWithValue:nil label:@""];
[[dalert textField] setDelegate:self];
[[dalert textField] setKeyboardType:UIKeyboardTypeDefault];
[[dalert textField] setKeyboardAppearance:UIKeyboardAppearanceDefault];
[[dalert textField] setReturnKeyType:UIReturnKeyDone];
[[dalert textField] setAutocorrectionType:UITextAutocorrectionTypeNo];
dalert.tag = 2;
[dalert show];
[dalert release];
}
using namespace std;
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == 1) {
if ((([[alertView textField] text].length) > 0) && (([[alertView textField] text].length) < MAXLENGTH)) {
NSString *temp = [[alertView textField] text];
string phrase = [temp cString];
int a;
int b = ([[alertView textField] text].length);
for (a=0; a < b; a++) {
char have;
int tabe;
have = phrase[a];
for (tabe=0; tabe < 26; tabe++)
{
if (table[0][tabe] == have){
phrase[a] = (table[17][tabe]);
break; }
else if (table[1][tabe] == have){
phrase[a] = (table[18][tabe]);
break; }
else if (table[2][tabe] == have){
phrase[a] = (table[19][tabe]);
break; }
else
continue;
}
}
const char* tempt = phrase.c_str();
NSString *ans = [[NSString alloc] initWithCString: tempt];
UIAlertView *anse = [[UIAlertView alloc] initWithTitle:@"Your encrypted message is:" message: ans delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[anse show];
[anse release];
[ans release];
}
else if (([[alertView textField] text].length) > MAXLENGTH) {
UIAlertView *anse = [[UIAlertView alloc] initWithTitle:@"ERROR" message: @"The text you have entered is too long to be encrypted, try shortening the message." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[anse show];
[anse release];
}
}
else if (alertView.tag == 2) {
if ((([[alertView textField] text].length) > 0) && (([[alertView textField] text].length) < MAXLENGTH)) {
NSString *temp = [[alertView textField] text];
string phrase = [temp cString];
int a;
int b = ([[alertView textField] text].length);
for (a=0; a < b; a++) {
char have;
int tabe;
have = phrase[a];
for (tabe=0; tabe < 26; tabe++)
{
if (table[17][tabe] == have){
phrase[a] = (table[0][tabe]);
break; }
else if (table[18][tabe] == have){
phrase[a] = (table[1][tabe]);
break; }
else if (table[19][tabe] == have){
phrase[a] = (table[2][tabe]);
break; }
else
continue;
}
}
const char* tempt = phrase.c_str();
NSString *ans = [[NSString alloc] initWithCString: tempt];
UIAlertView *anse = [[UIAlertView alloc] initWithTitle:@"Your decrypted message is:" message: ans delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[anse show];
[anse release];
[ans release];
}
else if (([[alertView textField] text].length) > MAXLENGTH) {
UIAlertView *anse = [[UIAlertView alloc] initWithTitle:@"ERROR" message: @"The text you have entered is too long to be decrypted, try shortening the message." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[anse show];
[anse release];
}
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end