I am trying to get my UITextField email in my first view controller to become the UILabel in my next view controller. It says there is an error stating there is no visible #interface for NSString declares the selector initvalue. I thought the interface was being loaded from the vc1.h file when you imported it on the vc2? any help would be nice. Heres what I have so far:
vc1.h
#import <UIKit/UIKit.h>
#interface loginUserViewController : UIViewController
#property (nonatomic, retain, strong) IBOutlet UITextField *email;
#property (nonatomic, retain) IBOutlet UITextField *password;
#property (nonatomic, retain) IBOutlet UIButton *login;
#property (nonatomic,retain) IBOutlet UIButton *registerBtn;
-(IBAction)loginUser:(id)sender;
#end
vc2.h
#import <UIKit/UIKit.h>
#import "loginUserViewController.h"
#interface Home : UIViewController
#property (weak, nonatomic) IBOutlet UILabel *username;
#property (weak, nonatomic) IBOutlet UIBarButtonItem *Nav;
#property (weak, nonatomic) IBOutlet UIBarButtonItem *logout;
-(IBAction)logout:(id)sender;
-(IBAction)bandHome:(id)sender;
#end
vc2.m
import "Home.h"
#import "loginUserViewController.h"
#interface Home ()
#end
#implementation Home
#synthesize username, band1, band2, band3;
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self){
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
loginUserViewController *object = [[loginUserViewController alloc]init];
NSString *string = [[NSString alloc] initWithFormat:#"%i",[object.email.text initValue]];
username.text = string;
}
vc1.m
#import "loginUserViewController.h"
#import "Home.h"
#import "createBandViewController.h"
#interface loginUserViewController ()
#end
#implementation loginUserViewController
#synthesize email, password;
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
- (void)viewDidload
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[self setEmail:nil];
[self setPassword:nil];
[super viewDidUnload];
}
-(IBAction)loginUser:(id)sender {
if ([email.text isEqualToString:#""] || [password.text isEqualToString:#""])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"alert" message:#"Please Fill all the field" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
return;
}
Simply replace this string:
NSString *string = [[NSString alloc] initWithFormat:#"%i",[object.email.text initValue]];
with this string:
NSString *string = [[NSString alloc] initWithFormat:#"%i",[object.email.text intValue]];
and if you want simply the email just as a string then replace it with this string
NSString *string = [[NSString alloc] initWithFormat:#"%#",object.email.text];
your error will be resolved.Hope it helps :)
First of All in VC2.h
#import <UIKit/UIKit.h>
#import "loginUserViewController.h"
#interface Home : UIViewController
#property (strong, nonatomic) IBOutlet UILabel *username; // Keep property strong to get the value
in VC2.m
#synthesize username;
Now in VC1.h
#import <UIKit/UIKit.h>
#import "homeviewcontroller.h"
#interface loginUserViewController : UIViewController
#property (nonatomic, strong) IBOutlet UITextField *email;
#property (nonatomic, strong) IBOutlet UITextField *password;
#property (nonatomic) nsstring *username;
-(void)viewDidLoad
{
[super viewDidLoad];
username= self.email.text;
homeviewcontroller *object = [[homeviewcontroller alloc]init];
object.username.text=username;
}
Related
I want to pass UITextField *nameText from GreenViewController to UILabel *nameValue in ViewController using delegate.
I made delegate, the onSave method in ViewController is called but the screen is not going back and the name is not passed.
What is the problem?
Here are the header and impelentation files:
GreenViewController.h
#import <UIKit/UIKit.h>
#protocol GreenViewDelegate <NSObject>
-(void)onSave:(NSString*)nameValue;
#end
#interface GreenViewController : UIViewController
#property id<GreenViewDelegate> delegate;
#property (nonatomic) NSString* sliderValuePassed;
#property (weak, nonatomic) IBOutlet UIButton *Next;
#property (weak, nonatomic) IBOutlet UIButton *Save;
#property (weak, nonatomic) IBOutlet UIButton *Back;
#property (weak, nonatomic) IBOutlet UILabel *sliderTextValue;
#property (weak, nonatomic) IBOutlet UITextField *NameText;
- (IBAction)save:(id)sender;
#end
GreenViewController.m
#import "GreenViewController.h"
#import "ViewController.h"
#interface GreenViewController ()
#end
#implementation GreenViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.sliderTextValue.text = self.sliderValuePassed;
}
- (IBAction)back:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)save:(id)sender {
[self.delegate onSave:self.NameText.text];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#import "GreenViewController.h"
#interface ViewController : UIViewController <GreenViewDelegate>
#property (weak, nonatomic) IBOutlet UISlider *slider;
#property (weak, nonatomic) IBOutlet UILabel *sliderTextValue;
#property (weak, nonatomic) IBOutlet UIButton *EnterName;
#property (weak, nonatomic) IBOutlet UILabel *NameValue;
#property (weak, nonatomic) IBOutlet UIButton *LikeIOS;
#property (weak, nonatomic) IBOutlet UISwitch *CheckboxIOS;
#end
ViewController.m
#import "ViewController.h"
#import "RedViewController.h"
#import "GreenViewController.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.sliderTextValue.text = [NSString stringWithFormat:#"Slider value = %d",(int)self.slider.value];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"yellowToGreen"]){
GreenViewController* gVC = segue.destinationViewController;
gVC.sliderValuePassed = [NSString stringWithFormat:#"Slider value = %d",(int)self.slider.value];
gVC.delegate = self;
}else if([segue.identifier isEqualToString:#"yellowToRed"]){
RedViewController* rVC = segue.destinationViewController;
rVC.sliderValuePassed = [NSString stringWithFormat:#"Slider value = %d",(int)self.slider.value];
rVC.CheckboxIOS = self.CheckboxIOS;
}
}
- (IBAction)sliderChangeValue:(id)sender {
int sliderVal = self.slider.value;
self.sliderTextValue.text = [NSString stringWithFormat:#"Slider value = %d",sliderVal];
}
-(void)onSave:(NSString*)nameValue{
NSLog(#"onSave in father controller");
self.NameValue.text = [NSString stringWithFormat:#"Name = %#",nameValue];
}
#end
I assume you didnt set the delegate .
Set it like this:
GreenViewController *myVc = [[GreenViewController alloc] init];
myVc.delegate = self;
Put this in your view controller view did load method!!!
try with GreenViewController.h:
#property (nonatomic, assign) id<GreenViewDelegate> delegate;
and GreenViewController.m:
- (IBAction)save:(id)sender {
[_delegate onSave:self.NameText.text];
[self.navigationController popViewControllerAnimated:YES];
}
ViewController.* seems to be OK
I've searched all over google, and stack overflow for a solution, but I wasn't able to find an answer that solved my problem. Sorry for the long post, as I'm trying to give as much information as I can. I'm new to iOS and Objective- c, but not programming in general due to being asked to switch over from Android by my company, so any help is appreciated.
I'm trying to assign a value to an NSString in one class from a TextField in another, but I get the error:
**-[ViewController name:]: unrecognized selector sent to instance 0x78712fe0**
when I run the app in the simulator.
Relevant code:
//UserInfo.h
#import <Foundation/Foundation.h>
#interface UserInfo : NSObject <NSCoding>
#property (nonatomic, strong) NSString *name;
#property (nonatomic, strong) NSString *age;
#property (nonatomic, strong) NSString *address;
#end
//UserInfo.m
#import "UserInfo.h"
static NSString *nameKey = #"userName";
static NSString *ageKey = #"userAge";
static NSString *addressKey = #"userAddress";
static NSString *userInfoKey = #"userInfoKey";
#implementation UserInfo
#synthesize name;
#synthesize age;
#synthesize address;
- (id) initWithCoder:(NSCoder *)coder
{
self = [super init];
self.name = [coder decodeObjectForKey:nameKey];
self.age = [coder decodeObjectForKey:ageKey];
self.address = [coder decodeObjectForKey:addressKey];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.name forKey:nameKey];
[coder encodeObject:self.age forKey:ageKey];
[coder encodeObject:self.address forKey:addressKey];
}
#end
//ViewController.h
#import <UIKit/UIKit.h>
#import "UserInfo.h"
#interface ViewController : UIViewController <UITextFieldDelegate, UITextViewDelegate, NSCoding>
#property (nonatomic, strong) UserInfo *userInfoObject;
#property (nonatomic, weak) IBOutlet UILabel *titleLabel;
#property (nonatomic, weak) IBOutlet UILabel *nameLabel;
#property (nonatomic, weak) IBOutlet UILabel *ageLabel;
#property (nonatomic, weak) IBOutlet UILabel *addressLabel;
#property (nonatomic, weak) IBOutlet UITextField *nameText;
#property (nonatomic, weak) IBOutlet UITextField *ageText;
#property (nonatomic, weak) IBOutlet UITextField *addressText;
#property (nonatomic, weak) IBOutlet UIButton *saveBtn;
- (IBAction)saveBtnTouched:(id)sender;
- (void) saveUserInfo;
- (void) loadUserInfo;
- (void) setUserInterfaceValues;
- (IBAction)nameText:(id)sender;
- (IBAction)ageText:(id)sender;
- (IBAction)addressText:(id)sender;
#end
//ViewController.m
#import "ViewController.h"
#import "UserInfo.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize titleLabel;
#synthesize nameLabel;
#synthesize ageLabel;
#synthesize addressLabel;
#synthesize nameText;
#synthesize ageText;
#synthesize addressText;
#synthesize saveBtn;
static NSString *userInfoKey = #"userInfoKey";
- (void)viewDidLoad {
[super viewDidLoad];
[self loadUserInfo];
if(!self.userInfoObject)
{
self.userInfoObject = [[UserInfo alloc] init];
}
[self setUserInterfaceValues];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
self.saveBtn.enabled = YES;
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
return YES;
}
- (BOOL) textFieldShouldEndEditing:(UITextField *)textField
{
[self.nameText resignFirstResponder];
[self.ageText resignFirstResponder];
[self.addressText resignFirstResponder];
return YES;
}
- (IBAction)saveBtnTouched:(id)sender
{
NSLog(#"%# was entered into the name field", self.nameText.text);
NSLog(#"%# was entered into the age field", self.ageText.text);
NSLog(#"%# was entered into the address field", self.addressText.text);
[self textFieldShouldEndEditing:self.nameText];
[self textFieldShouldEndEditing:self.ageText];
[self textFieldShouldEndEditing:self.addressText];
self.userInfoObject.name = self.nameText.text;
self.userInfoObject.age = self.ageText.text;
self.userInfoObject.address = self.addressText.text;
[self saveUserInfo];
self.saveBtn.enabled = NO;
}
- (void)saveUserInfo
{
NSData *userInfoData = [NSKeyedArchiver archivedDataWithRootObject:self.userInfoObject];
[[NSUserDefaults standardUserDefaults] setObject:userInfoData forKey:userInfoKey];
}
- (void)loadUserInfo
{
NSData *userInfoData = [[NSUserDefaults standardUserDefaults] objectForKey:userInfoKey];
if(userInfoData)
{
self.userInfoObject = [NSKeyedUnarchiver unarchiveObjectWithData:userInfoData];
}
}
- (void) setUserInterfaceValues
{
self.nameText.text = self.userInfoObject.name;
self.ageText.text = self.userInfoObject.age;
self.addressText.text = self.userInfoObject.address;
}
- (IBAction)nameText:(id)sender {
}
- (IBAction)ageText:(id)sender {
}
- (IBAction)addressText:(id)sender {
}
#end
//AppDelegate.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "UserInfo.h"
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#end
//AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#import "UserInfo.h"
#interface AppDelegate ()
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
//all the other generated methods. Taken out due to space.
#end
Three breakpoints are set that are supposidly the source of the problem:
From the ViewController.m, in - (void)setUserInterfaceValues
self.nameText.text = self.userInfoObject.name;
(I assume that this applies to the other two lines below it also)
Also from the ViewController.m, in - (void)viewDidLoad
[self setUserInterfaceValues];
And finally from the AppDelegate.m, in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window.rootViewController = self.viewController;
From what I understand, and have learned from searching this issue, the app is trying to send data to something that doesn't exist, the NSString name being the culprit. Others have suggested to make sure that my .xib file is connected to the ViewController, and I have verified that it is.
As another bit of information, I'm not using a storyboard for this app, and instead am using the interface builder. I'm aware that there are advantages to storyboards, and I would like to be using them, but my company uses the interface builder and does a lot of things programmatically, so I'm learning to develop without.
[EDIT]: Issue solved thanks to Ian.
I keep getting the declaration hides instance variable, but i don't know where to call it. I'm trying to reference it programmatically. I created the UILabel Programmatically so I don't have anything to drag it to in .xib
MapViewController.h
#import <UIKit/UIKit.h>
#import "RESideMenu.h"
#import <MapKit/MapKit.h>
#interface MapViewController : UIViewController
{
IBOutlet MKMapView *mapView;
IBOutlet UISegmentedControl *segmentedControl;
IBOutlet UILabel *parseLabel;
}
#property (nonatomic, retain) MKMapView *mapView;
#property (nonatomic, retain) UISegmentedControl *segmentedControl;
#property (nonatomic, retain) IBOutlet UILabel *parseLabel;
- (IBAction)segmentedControllChanged:(id)sender;
#end
MapViewController.m
#import "MapViewController.h"
#import "MapViewAnnotation.h"
#import "Config.h"
#interface MapViewController ()
#end
#implementation MapViewController
#synthesize mapView, segmentedControl, parseLabel;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(UILabel *)parseLabel {
UILabel *parseLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, 1, 200, 40)];
NSError *error = nil;
NSString *html = [NSString stringWithContentsOfURL:[NSURL URLWithString:#"http://harryhippie.com/app-currentlocationparse"] encoding:NSASCIIStringEncoding error:&error];
if(html) {
NSLog(#"HTML %#", html);
NSRange r = [html rangeOfString:#"<h2 class=\"font\">"];
if (r.location != NSNotFound) {
NSRange r1 = [html rangeOfString:#"</h2>"];
if (r1.location != NSNotFound) {
if (r1.location > r.location) {
NSString *subtitleString = [html substringWithRange:NSMakeRange(NSMaxRange(r), r1.location - NSMaxRange(r))];
NSLog(#"%#", subtitleString);
self.parseLabel.text = subtitleString;
}
}
}
}
return parseLabel;
}
- (void)viewDidLoad
{
[self.navigationController.navigationBar addSubview:parseLabel];
[super viewDidLoad];
}
I think i'm just overlooking something simple because its a simple error. please help :)
Its easy thing, Look at this:
in your .h you declared
#property (nonatomic, retain) IBOutlet UILabel *parseLabel;
And in you -(UILabel *)parseLabel you did this:
UILabel *parseLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, 1, 200, 40)];
The variable names are same. Thats why you are getting this error. :)
I have the following app that I've implemented a scroll view (image outlines hierarchy on storyboard:e
I have turned off Auto Layout, as severe posts here seem to indicate this creates a problem.
here is my .h file:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
#import <AssetsLibrary/ALAsset.h>
#import <AssetsLibrary/ALAssetRepresentation.h>
#import <ImageIO/CGImageSource.h>
#import <ImageIO/CGImageProperties.h>
#import <CoreLocation/CoreLocation.h>
#interface DobInAHoonViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, UITextFieldDelegate, CLLocationManagerDelegate>
{
IBOutlet UIPickerView *vehiclePickerView;
UIImagePickerController *picker1;
UIImagePickerController *picker2;
UIImage *image;
IBOutlet UIImageView *imageView;
CLLocationManager *locationManager;
CGFloat animatedDistance;
}
#property (strong, nonatomic) IBOutlet UIImageView *BackgroundImage;
#property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
#property (strong, nonatomic) NSString *Latitude;
#property (strong, nonatomic) NSString *longditute;
#property (strong, nonatomic) NSArray *toRecipients;
#property (strong, nonatomic) ALAssetsLibrary *assetsLibrary;
#property (strong, nonatomic) NSMutableArray *groups;
#property (nonatomic, retain) IBOutlet UITextField *vehilceMake;
#property (nonatomic, retain) IBOutlet UITextField *vehilceColour;
#property (nonatomic, retain) IBOutlet UITextField *regoNumber;
#property (nonatomic, retain) IBOutlet UITextField *location;
#property (nonatomic, retain) IBOutlet UITextField *additionalInfo;
#property (nonatomic, retain) IBOutlet UITextField *vehicleType;
- (IBAction)takePhoto;
-(IBAction)chooseExisting;
-(IBAction)actionEmailComposer;
-(IBAction)textFileReturn:(id)sender;
-(IBAction)DismissKeyboard:(id)sender;
#end
and my .m file:
#import "DobInAHoonViewController.h"
#interface DobInAHoonViewController ()
#end
#implementation DobInAHoonViewController
#synthesize BackgroundImage;
#synthesize vehilceColour;
#synthesize vehilceMake;
#synthesize regoNumber;
#synthesize Latitude;
#synthesize location;
#synthesize longditute;
#synthesize additionalInfo;
#synthesize toRecipients;
#synthesize assetsLibrary;
#synthesize groups;
#synthesize vehicleType;
#synthesize scrollView;
static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLLFRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 140;
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[vehilceMake resignFirstResponder];
[vehilceMake resignFirstResponder];
[vehilceColour resignFirstResponder];
[location resignFirstResponder];
[additionalInfo resignFirstResponder];
[regoNumber resignFirstResponder];
return YES;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.scrollView setScrollEnabled:YES];
[self.scrollView setContentSize:(CGSizeMake(320, 1000))];
locationManager = [[CLLocationManager alloc]init];
toRecipients = [[NSArray alloc]initWithObjects:#"scott.boon#shellharbour.nsw.gov.au", nil];
BackgroundImage.alpha = 0.3;
static int emergAlertCounter;
if (emergAlertCounter <1) {
UIAlertView *emergencyAlert = [[UIAlertView alloc]
initWithTitle:#"NOTE" message:#"Do not endanger your life to dob in a hoon. If your life is threatened, or you are reporting an emergency situation, exit this app and dial '000' IMMEDIATLY!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[emergencyAlert show];
emergAlertCounter = emergAlertCounter+1;
}
}
for some reason, when i run the app, the scroll view is not scrolling. I have set the property to scroll in the interface builder.
Any suggestions would be greatly appreciated.
You'll have to make sure your scroll view is smaller than 320 x 1000 and that the embedded view is larger than 320 x 1000
I'm having trouble implementing a Segmented Control. I believe I have everything hooked up, but the method is not being called when I click on either side of the Segmented Control.
Header File
#import <UIKit/UIKit.h>
#import "ServiceConnector.h"
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMessageComposeViewController.h>
#import <AddressBook/AddressBook.h>
#import "Global.h"
#interface ContactInfo : NSObject
#property char group;
#property (nonatomic, retain) NSString* firstName;
#property (nonatomic, retain) NSString* lastName;
#property (nonatomic, retain) NSString* phoneNumber;
#property int isSelected;
#end
#interface Friends : UIViewController<UITableViewDataSource, UITableViewDelegate, ServiceConnectorDelegate, MFMessageComposeViewControllerDelegate>{
UISegmentedControl *segmentedControl;
}
#property (nonatomic, retain) IBOutlet UITableView* tblFriends;
#property (nonatomic, retain) IBOutlet UIButton* btnAdd;
#property (nonatomic, retain) IBOutlet UIButton* btnInvite;
#property (nonatomic, retain) IBOutlet UIButton* btnDone;
#property (nonatomic, retain) NSMutableArray* contactList;
#property (nonatomic, retain) NSMutableArray* contactGroup;
#property (nonatomic, retain) NSMutableArray* friendList;
#property (nonatomic, retain) NSString* modeStr;
#property (nonatomic,retain) IBOutlet UISegmentedControl *segmentedControl;
- (IBAction) InviteClicked;
- (IBAction) AddClicked;
- (IBAction) DoneClicked;
- (IBAction)segmentSwitch;
- (void) sendSMS:(NSString*) phoneNumber;
- (void) sendInviteSMS:(NSMutableArray*) resipients;
- (void) getContacts;
- (void) groupFromContacts;
- (void) groupFromFriends;
// table delegates
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
// service connector delegate
- (void)requestReturnedData:(NSData*)data;
//message delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result;
#end
Simplified version of implementation (methods have been removed)
#import "Friends.h"
#import "JSONKit.h"
#interface Friends ()
#end
#implementation ContactInfo
#end
#implementation Friends
#synthesize segmentedControl;
- (void)viewDidLoad
{
_friendList = [[NSMutableArray alloc] init];
_contactList = [[NSMutableArray alloc] init];
[self AddClicked];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void) dealloc
{
[segmentedControl release];
[_friendList release];
[_contactList release];
[super dealloc];
}
- (IBAction)segmentSwitch {
switch (self.segmentedControl.selectedSegmentIndex) {
case 0:
[self AddClicked];
break;
case 1:
[self InviteClicked];
break;
default:
break;
}
}
#end
Here is connection inspector for the Segmented Control
You need to hook the control up to the "Value Changed" event, not the "Touch Up Inside" event.