It looks like you're new here. If you want to get involved, click one of these buttons!
#import <UIKit/UIKit.h>
#import \"Drink.h\"
@protocol firstViewControllerDelegate <NSObject>
- (NSMutableArray *) getFavourites;
- (void) setFavourites: NSMutableArray;
@end
@interface FirstViewController : UIViewController
{
id <firstViewControllerDelegate> delegate;
NSMutableArray *labels;
UIButton *button1;
UIButton *button2;
UIButton *button3;
UIButton *button4;
}
- (IBAction) buttonClick: (id) sender;
@property (nonatomic, assign) id <firstViewControllerDelegate> delegate;
@property (nonatomic, retain) IBOutlet UIButton *button1;
@property (nonatomic, retain) IBOutlet UIButton *button2;
@property (nonatomic, retain) IBOutlet UIButton *button3;
@property (nonatomic, retain) IBOutlet UIButton *button4;
@end
#import \"FirstViewController.h\"
#import \"Drink.h\"
@implementation FirstViewController
@synthesize button1, button2, button3, button4;
@synthesize delegate;
.........
- (void) viewDidAppear:(BOOL)animated
{
NSMutableArray *favourites = [self.delegate getFavourites];
// Favourites is empty
Drink *drink = [favourites objectAtIndex:1];
NSLog(@\"NAME VAR IS: %@\", [drink name]);
[button1 setTitle:[[favourites objectAtIndex:1] name] forState:UIControlStateNormal];
NSLog(@\"VIEW APPEARED. BUTTON TITLE IS: %@\", button1.currentTitle);
}
.......
#import <UIKit/UIKit.h>
#import \"FirstViewController.h\"
@interface SecondViewController: UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, firstViewControllerDelegate>
{
UITableView *PrefsTable;
NSMutableArray *favourites;
NSMutableArray *drinks;
}
@property (nonatomic, retain) IBOutlet UITableView *PrefsTable;
@property (nonatomic, retain) NSMutableArray *drinks;
@property (nonatomic, retain, getter = getFavourites) NSMutableArray *favourites;
- (void) addDrink: (NSString *) name;
@end
#import \"SecondViewController.h\"
#import \"Drink.h\"
@implementation SecondViewController
@synthesize PrefsTable;
@synthesize drinks, favourites;
........
- (void)viewDidDisappear:(BOOL)animated
{
NSMutableArray *array = [self getFavourites]; // THIS METHOD WORKS IN THIS CLASS
}
Replies
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeNew app - See screenshots and details at www.globaclock.com.
If you want to
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeNew app - See screenshots and details at www.globaclock.com.
If you want to
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome