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

  • Home
  • SEARCH
  • 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 7924193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:37:33+00:00 2026-06-03T17:37:33+00:00

I have a model.h and model.m to keep my data and variables which various

  • 0

I have a model.h and model.m to keep my data and variables which various view controllers access for data(Using MVC). The problem is, When i try to set and get the variables from them, They are always 0. I’m obviously done something wrong, but have no idea.

Here is my model.h and model.m (changed names so its easier.

model.h

@interface modeler : NSObject
{
   int abc;
   int def;
}
@property (nonatomic,assign) int abc;
@property (nonatomic,assign) int def;

model.m

#import "modeler.h"
@interface modeler()
@end
@implementation modeler
@synthesize abc = _abc;
@synthesize def = _def;

Thats how i set up the two variables, here are the view controllers.
vc.h

#import "modeler.h"
@interface vcViewController : UITableViewController
@property (nonatomic,strong) modeler *datas;
@end

vc.m

@interface vcViewController ()
@end
@implementation vcViewController
@synthesize datas = _datas;

This is how im trying to set them to something in vc.m

NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
NSLog(@"1-%i",selectedRowIndex.row);
_datas.abc = selectedRowIndex.row;
NSLog(@"2-%i",_datas.abc);

The selected row prints out 2, but the _data.abc is always 0. What did i miss? I am guessing its not calling it, maybe because its an instance of it ? Any quick tips?

  • 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-03T17:37:35+00:00Added an answer on June 3, 2026 at 5:37 pm

    I don’t see where you’re setting the view controller’s datas property (or the _datas ivar) to an instance of your modeler class. If that’s not happening, _datas.abc is a message to nil — so using it as a setter does nothing and using it as a getter returns 0.

    In addition, you’re declaring abc and def as ivars on your modeler class, and then declaring properties with the same names but different ivars (_abc and _def). This almost certainly isn’t causing the problem you’re seeing, but is bound to lead to confusion later. It’d be better to either not declare ivars (and let the @synthesize directives take care of that) or not specify ivars in your @synthesize directives (so that the same-named ivars are used by default. I tend to prefer the former.

    Furthermore, it’s also probably not connected to your problem, but it’s generally a good thing to use generated accessors instead of ivars unless you have a good reason not to. (That is, use self.datas instead of datas.)

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

Sidebar

Related Questions

I have a JTable which is loaded from a data-structure using table model.The data-structure
I have various models of which I would like to keep track and collect
I have this administration site that is using (Fluent) NHibernate for data access. As
Here's the scenario... I have several float attributes in my data model which I
I have a situation in which I am attempting to keep my model and
I have started using asp.net MVC and as traditional way I want to keep
So, I have a nice domain model built. Repositories handle the data access and
I have a model 'Car' that has_many 'features' . I keep all the features
I have model show which has_many performances and a performance has a certain location.
I have model Foo which has field bar. The bar field should be unique,

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.