Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:29:13+00:00 2026-06-09T13:29:13+00:00

This is my action UIButton: -(IBAction)favoriteButtonPressed:(id)sender { if (favoriteButtonSelected == 0) { [sender setSelected:YES];

  • 0

This is my action UIButton:

-(IBAction)favoriteButtonPressed:(id)sender
{
if (favoriteButtonSelected == 0) {

    [sender setSelected:YES];

    favoriteButtonSelected = 1;
    [sender setImage:[UIImage imageNamed:@"favoritedItem.png"]];
    [selectedObject setValue:@"Yes" forKey:@"Favorite"];

} else {

    [sender setSelected:NO];

    favoriteButtonSelected = 0;
    [sender setImage:[UIImage imageNamed:@"notFavorite.png"]];
    [selectedObject setValue:@"No" forKey:@"Favorite"];
}
}

How to make a reference to the button in viewDidLoad? To make the following code work:

- (void)viewDidLoad
{
[super viewDidLoad];

if ([[selectedObject valueForKey:@"Favorite"] isEqual:@"Yes"])  {

    [favoriteButton setImage:[UIImage imageNamed:@"favoritedItem.png"]];
    [favoriteButton setSelected:YES];
    favoriteButtonSelected = 1;

} else {

    [favoriteButton setImage:[UIImage imageNamed:@"notFavorite.png"]];
    [favoriteButton setSelected:NO];
    favoriteButtonSelected = 0;
}
}

EDIT FOR PROGRESS:

Now I did like this: Ctrl-drag from UIButton to ViewController in Assistant Editor. Connection: Outlet, name: favoriteButton, type: UIButton, storage: weak. But errors still there. + error for synthesize & error in viewDidUnload.. suggestion?

The Assistant Editor header for View Controller with the added property from Ctrl-drag:

@interface DetailViewController : UIViewController {
IBOutlet UIScrollView *viewScroller;
}

@property (nonatomic, strong) IBOutlet UILabel *mylLabel;

@property (nonatomic, strong) NSString *selectedObj;

@property (strong, nonatomic) NSArray *detailsDataSource;
@property int detailIndex;
@property (weak, nonatomic) IBOutlet UIButton *favoriteButton; //The added property

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:29:15+00:00Added an answer on June 9, 2026 at 1:29 pm

    Control drag from your button to the header of the viewcontroller to create a property. (You can do this while in assistant mode, second button on the top right)..

    Then you can reference your button from wherever using that property

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using : [button addTarget:self action:@selector(moved:) forControlEvents:UIControlEventTouchDragInside]; Function code move: - (IBAction)moved:(id)sender { UIButton
I have the next action. - (IBAction)openThumbMap:(UIButton *) sender { ThumbmapViewController *viewController = [[ThumbmapViewController
I am using this code to launch google map fine. -(void)buttonPressed:(UIButton *)sender{ NSString *urlstring=[NSString
Tried this but only works for UIButton: [btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
i have a button that i create in my CustomCell. - (IBAction)onoffBtn:(id)sender { UIButton
this action is generated in symfony 1.2 when you create a module: public function
I have this action for updating data: def edit @project = Project.find(params[:id]) if @project.team
I have to do through Action like this: Action action = () => {
I'm using webBrowser.Navigate(url) control to display page. I noticed this action steals focus from
How can I prevent caching on exception? I have this action: caches_page :index ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.