first of all I've checked a lot of posts in here, but i couldn't find a proper solution. I'm new to ObjC so i'm not able to find a solution by myself! Problem: I have a TabBArController with 2 Tabs each of them holds a TableviewController. From my first ViewController i'm tryin to add different Url strings to an Array of my SecondTableViewController.
Method from FirstviewController which should add the url to the Array of the SecondViewController:
- (IBAction)setJobs:(id)setJobs
{
NSString *parameterString = [[NSString alloc]init];
for (UITextField*textField in textFields)
{
parameterString = [parameterString stringByAppendingString:[NSString stringWithFormat:@"%@,",textField.text]];
}
NSString*user = [[NSString alloc]init];
NSString*password = [[NSString alloc]init];
NSString*firmenId = [[NSString alloc]init];
user = [[NSUserDefaults standardUserDefaults] objectForKey:@"Username"];
password = [[NSUserDefaults standardUserDefaults] objectForKey:@"Password"];
firmenId = [[NSUserDefaults standardUserDefaults] objectForKey:@"FirmenId"];
NSString*urlString=[[NSString alloc]initWithFormat:@"http://www.someurl.com/firmenid=%@;projectid=%@;user=%@;kennwort=%@;appparminfo=%@",firmenId,[self.detailRowArray objectAtIndex:1],user,password,parameterString];
[projektsInUse addObject:urlString];
// Here the url should be passed to the other Viewcontroller
TableAnswerController *tAVC=[[TableAnswerController alloc]init];
[tAVC.tabbleArray addObject:urlString];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(connection)
{
//connection didReceiveData
}
else
{
// Error Handling
}
}
here is my SecondTableViewController:
#import "TableAnswerController.h"
@interface TableAnswerController ()
@end
@implementation TableAnswerController
@synthesize timer,tabbleArray;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
if(!self.tabbleArray)
{
self.tabbleArray = [NSMutableArray array];
}
}
- (IBAction)refreshAnswers:(id)sender
{
NSLog(@"TableArray: %@",tabbleArray);
}