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 8997389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:52:58+00:00 2026-06-15T23:52:58+00:00

I have a class with two NSString data members Header file @interface WebSiteFavorites :

  • 0

I have a class with two NSString data members

Header file

@interface WebSiteFavorites : NSObject

@property (strong, nonatomic) NSString *titleName;
@property (strong, nonatomic) NSString *url;`

- (id) initWithTitleName: (NSString *)titleName url: (NSString *)url;

@end

I have a TVC that uses this class as its data source, and I have hard coded some instances of my class in the appDelegate to populate the TV which works. From the TV i have a add button with a modal transition to a VC. In this view controller I have two text fields where the user enters a name and a url and then I using protocols and delegate to update the TVC (which i don’t quite understand). My problem is that after the entering the required info in the text fields my class instance is null.

Here is my code for this

Header
@interface WebSiteFavoritesAddFavoritesViewController : UIViewController

@property (strong, nonatomic) WebSiteFavorites *favorites;

@property (weak, nonatomic) IBOutlet UITextField *titleTextField;
@property (weak, nonatomic) IBOutlet UITextField *urlTextField;

@property (strong) id<WebSiteFavoritesDelegate> delegate;

- (IBAction)titleTextFieldChanged;
- (IBAction)urlTextFieldChanged;

- (IBAction)doneButtonTapped:(id)sender;
- (IBAction)cancelButtonTapped:(id)sender;

@end

Implementation

@implementation WebSiteFavoritesAddFavoritesViewController

@synthesize favorites = _favorites;
@synthesize urlTextField = _urlTextField;
@synthesize titleTextField = _titleTextField;


- (IBAction)titleTextFieldChanged
{
    self.favorites.titleName = self.titleTextField.text;

}

- (IBAction)urlTextFieldChanged
{
   self.favorites.url = self.urlTextField.text;

}

- (IBAction)doneButtonTapped:(id)sender
{  
    [self.delegate newFavoriteAdded:self.favorites];
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)cancelButtonTapped:(id)sender
{
    [self dismissModalViewControllerAnimated:YES];
}

#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
@end

After the IBAction methods i have used break points and favorites is null.
Also I have some questions about protocols and delegates just for understanding. I have created a separate header file for my protocol, my TVC conforms to the protocol, in my VC i have created the delegate which you can see in my posted code. In my TVC i have implemented the function from my protocol. Is this the proper sequence?

  • 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-15T23:52:59+00:00Added an answer on June 15, 2026 at 11:52 pm

    You must instantiate favorites. Without instantiating objects don’t hold the values you assign to them.

    So you must do…

    favorites=[[WebSiteFavorites alloc] init];
    

    or as you have another method initWithTitleName:url:, do use that to instantiate.

    Hope this helps!

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

Sidebar

Related Questions

I have two classes. APPagine.h #import <Foundation/Foundation.h> @interface APPagineMedia : NSObject @property (nonatomic, retain)
I have a data class: @interface Car : NSObject { Engine *_engine; } //...
I've got a class with two properties: @interface Contact : NSObject { NSString *lastname;
I have an example class containing two data points: public enum Sort { First,
I have two class (AppDelegate and WebViewController) with two nib file: one is the
I have created a new class of type NSObject, which created two files --
I have two class libraries MyLibrary.dll and MyLibraryEditor.dll for a Unity runtime and editor
I have two class files hudlayer.m and actionlayer.m I have a method named jump
So i have two Class's Class A and Class B . I have a
I have a class with two constructors (C#). Here is the code snippet: public

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.