*edit here is the complete project in a zip file. no Viruses from my end seeing how im uploading fro school. PLease feel free to look at the code but don't Steal it. Whouldnt be worth taking anyways (grumble amature coding)
http://www.mediafire.com/?ja4bfbcypspiaar
Im sorry for any ambiguity through the title. Hello, my name is brad. im taking an xocde development class as an elective in college. for my final project i am creating a simple rpg style type game. this is where im running into errors. I have the first start screen which incompasses a FinalViewController.h .m and .xib file(a class view controller). when the first screen loads it prompts a view with two options(buttons). the first button loads a second class view controller(SaveViewController.h .m and .xib). This works fine. my Problem Occurs when i click another button in a diffrent view from the SaveViewController, which calls a method from FinalViewController.
heres some code Snipplets i think might be helpful?
From FinalViewController.m
//this is the method used to remove the save class view and load the //Homeworld class view. i know the method works because when i call it // from inside the FinalViewController it works sucessfully. However when i // try and call it from inside SaveViewController.
I REMOVED SOME EXCESS NON RELATED CODE THE THE FILE BELOW TO SHORTEN UP POST.
WHAT HAPPENS HERE IS IN A VIEW CALLED createNewChar with a button(tapCreateNewChar) and a text box (txtNewChar). the finalViewController is an outlet linked to FinalViewController.
http://www.mediafire.com/?ja4bfbcypspiaar
Im sorry for any ambiguity through the title. Hello, my name is brad. im taking an xocde development class as an elective in college. for my final project i am creating a simple rpg style type game. this is where im running into errors. I have the first start screen which incompasses a FinalViewController.h .m and .xib file(a class view controller). when the first screen loads it prompts a view with two options(buttons). the first button loads a second class view controller(SaveViewController.h .m and .xib). This works fine. my Problem Occurs when i click another button in a diffrent view from the SaveViewController, which calls a method from FinalViewController.
heres some code Snipplets i think might be helpful?
From FinalViewController.m
//this is the method used to remove the save class view and load the //Homeworld class view. i know the method works because when i call it // from inside the FinalViewController it works sucessfully. However when i // try and call it from inside SaveViewController.
Code:
-(void)LoadHomeWorld{
[saveViewController.view removeFromSuperview];
[self.view insertSubview:homeWorldController.view atIndex:1];
}
Code:
heres the complete SaveView Controller .h and .m files
//
// SaveViewController.h
// Final
//
// Created by wctc on 4/25/11.
// Copyright 2011 WCTC. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CharData.h"
#import "FinalViewController.h"
@interface SaveViewController : UIViewController {
CharData *charData;
int SaveCount;
IBOutlet UIButton *loadButton;
IBOutlet UIPickerView *thePickerView;
IBOutlet FinalViewController* finalViewController;
NSMutableArray *charSaveArray;
int charSaveMarker;
IBOutlet UITextField *txtNewChar;
IBOutlet UIView *viewSplash;
IBOutlet UIView *viewNewChar;
}
-(NSString*)PassNewCharName;
- (IBAction)tapNewChar:(id)sender;
- (IBAction)tapCreateNewChar:(id)sender;
@end
I REMOVED SOME EXCESS NON RELATED CODE THE THE FILE BELOW TO SHORTEN UP POST.
Code:
//
// SaveViewController.m
// Final
//
// Created by wctc on 4/25/11.
// Copyright 2011 WCTC. All rights reserved.
//
#import "SaveViewController.h"
#import "FinalViewController.h"
@implementation SaveViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
#pragma mark - PickerView Implamentation - assigning colums
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
#pragma mark - PickerView Implamentation - Loading # rows needed
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [charSaveArray count];
}
#pragma mark - PickerView Implamentation - Filling Row Data
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [charSaveArray objectAtIndex:row];
}
#pragma mark - PickerView Implamentation - Delagation
// method to react to a picker view selection
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
charSaveMarker = row;
//NSLog(@"%@",[arrayAnswers objectAtIndex:0]);
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
charData = [[CharData alloc]init ];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (IBAction)tapNewChar:(id)sender {
[viewSplash addSubview:viewNewChar];
}
-(NSString*)PassNewCharName{
return txtNewChar.text;
}
- (IBAction)tapCreateNewChar:(id)sender {
[txtNewChar resignFirstResponder];
if ([txtNewChar.text length]<=0) {
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"No Name Entered" message:@"No name was Given. A name is Required." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[theAlert show]; [theAlert release];
}
if([txtNewChar.text length]<=1){
[finalViewController LoadHomeWorld];
}
}
@end
WHAT HAPPENS HERE IS IN A VIEW CALLED createNewChar with a button(tapCreateNewChar) and a text box (txtNewChar). the finalViewController is an outlet linked to FinalViewController.