Sorry if it is not a standard question, but now your solutions can help me out. In my app, I have two classes: ClassA
and ClassB
. ClassB
You pass the value to your class or object constructor. You then save the value to a property in that class. You then access that property from the view did load, or your other events.
This is more a general programming concept, than anything related to objective c, the iPad, etc.
So, in your header file, you define a property. Then you synthesize that property the c file. Then you set the property in the constructor. Then you access the property in your view did load event.
Why don't you declare a property for that?
@interface ClassB:...
@property (nonatomic, copy) NSString * columnName
@end
and synthesize it in the implementation.
When you are creating ClassB
instance from ClassA
then do this,
ClassB * classB = [[ClassB alloc] initWithNibName:.. bundle:..];
classB.columnName = theColumnName;
[self pushViewController:classB animated:YES];
[classB release];
Make use of this parameter in viewDidLoad
.
You normally create a property on the target class and populated it with whatever you need to pass along, then you push the other class onto the stack, or tell it to update.
I'd recommend you write a setter method for your query. Once Class B is instantiated you can call the method any time to update the data set and the table view.
You'll need to adjust the parameters to handle whatever form of representation you'll be using for your query.
ClassB.h
@interface ClassB : UITableViewController {
}
@property (nonatomic, copy) NSString *query;
ClassB.m
// method declared in ClassB
@implementation
@synthesize query;
// other methods here ...
- (void)setQuery:(NSString *)newQuery
{
// query is an instance variable declared in your .h
[newQuery retain];
[query release];
query = newQuery;
// perform your new data fetch with the supplied query
[self.tableView reload];
}
@end
ClassA.m
- (void)viewDidLoad
{
[super viewDidLoad];
classB = [[ClassB alloc] initWithNibName:@"ClassB" bundle:nil];
[classB setQuery:@"your query string here"];
}