首先我在这里检查了很多帖子,但我找不到合适的解决方案。我是ObjC的新手,所以我自己无法找到解决方案! 问题: 我有一个带有2个Tab的TabBArController,每个Tab都包含一个TableviewController。从我的第一个ViewController开始,我试着将不同的Url字符串添加到我的SecondTableViewController的数组中。
- (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
}
}
#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);
}
答案 0 :(得分:0)
您需要先初始化数组
TableAnswerController *tAVC=[[TableAnswerController alloc]init];
tAVC = [NSMutableArray new];
[tAVC.tabbleArray addObject:urlString];
OR
NSArray *arr = [[NSArray alloc]initWithObjects:urlString, nil];
[tAVC setTabbleArr:arr];