Questions tagged [ivar]

In object-oriented programming, an instance variable is a variable defined in a class (i.e. a member variable), for which each object of the class has a separate copy, or instance.

In object-oriented programming, an instance variable is a variable defined in a class (i.e. a member variable), for which each object of the class has a separate copy, or instance.

140 questions
0
votes
2 answers

Storing a Boolean for access by Parse login

I want to store a Boolean which grants access to certain options when a user logs in with Parse, but when I log in and declare it to be true, the variable seems to remain false. I tried using NSUserDefaults and storing a global variable. This is…
GJZ
  • 2,482
  • 3
  • 21
  • 37
0
votes
1 answer

IOS Data Between View Controllers

I have a navigation controller with 2 view controllers, A and B. A and B both have a property @property (strong, nonatomic) NSString *string; string is created in controller A and passed to controller B ViewControllerB.string =…
stefano_cdn
  • 1,362
  • 2
  • 15
  • 29
0
votes
3 answers

Retain object without using a property

I have a control that works like this: MyCustomControl *control = [[MyCustomControl alloc] initWithNavigationController:self.navigationController]; control.completion = ^{ [self controlCompletedAction]; }; [control…
ebi
  • 4,862
  • 6
  • 29
  • 40
0
votes
1 answer

Setting and using ivars or passed parameters in setter functions

I know this sounds like a really silly and stupid question but is there any difference in using the target ivars or the passed parameters when making extended setter functions like in: - (void)setText:(NSString)text { _text = text; …
rolling_codes
  • 15,174
  • 22
  • 76
  • 112
0
votes
1 answer

iOS instance variable declaration

I would like to know what's the difference between declaring my instance variables like this: // inside the implementation file (.m) @interface MyCustomObject() { id _myIvar; } @end @implementation MyCustomObject ... @end And like…
Teo
  • 3,394
  • 11
  • 43
  • 73
0
votes
2 answers

When should I declare an instance variable rather than property in the header?

For example, in the following codes. @interface TUTViewController : UIViewController { NSTimer *timer; } @end and @interface TUTViewController : UIViewController @property (weak, nonatomic) NSTimer *timer; @end In which scenario do we use…
user3586299
  • 153
  • 1
  • 2
  • 10
0
votes
3 answers

Use property in class extension instead of ivar in post ARC

The recommended practice is to use property, including private ones through class extension instead of ivar (except in init and dealloc) in the post ARC environment. Aside from it being a recommended practice, what are the main drawbacks in someone…
Boon
  • 40,656
  • 60
  • 209
  • 315
0
votes
1 answer

There is no visible ivar for property named "image"?

Suppose dummy VC has a private property "image" dummyVC.h @interface dummyVC : UIViewController @end dummyVC.m @interface dummyVC () @property (nonatomic, strong) UIImage *image; @end - (void)setImage:(UIImage *)image { if(!_image) { //…
David Liu
  • 16,374
  • 12
  • 37
  • 38
0
votes
1 answer

EXC_BAD_ACCESS on property access, (OS X 10.8.5)

I'm using an autosynthesized @property. When I access the property in a method, I'm getting an EXC_BAD_ACCESS exception. Here's are the relevant sections of code from my implementation file: #import "BBBluetoothController.h" #import…
GarlicFries
  • 8,095
  • 5
  • 36
  • 53
0
votes
1 answer

Notify iVar Value change

I wanted to get notification when iVar's value changes. Suppose we are changing the vale of a string without calling setter then how i will get to know in same class. Because KVO and overriding setter works with calling setter only. Not with iVar.
Sachin
  • 333
  • 1
  • 4
  • 19
0
votes
2 answers

Which one is initialized, property or its instance variable

Suppose I have a property called myPropertyName defined in my class MyClassName. Manual memory management is used throughout this post. MyClassName.h #import @interface MyClassName : NSObject { @private NSObject*…
George
  • 3,384
  • 5
  • 40
  • 64
0
votes
1 answer

Change OBJC_IVAR_$ in binary

In an older version of a framework there were two class, A and B, with A being a subclass of B. In the newer version B no longer exists and everything in B (ivars etc.) is now in A. An executable file is linked against the old version, so it looks…
user1000039
  • 785
  • 1
  • 7
  • 19
0
votes
2 answers

Explicitly setting iVar class in Ruby (ala Obj-C)

I'm an experienced Obj-C/Java programmer, and am getting into Ruby. Obviously the fact that it's so dynamic is great (re-opening classes is awesome!) but there's one thing that bugs me/worries me for when I start writing Ruby code. I'd be interested…
Patrick
  • 2,769
  • 2
  • 25
  • 29
0
votes
2 answers

Prevent ObjC "abstract" class' init method from being called while allowing [super init]?

Say I have a pseudo-abstract base class that users should not instantiate. Basically I want to throw a warning when they're trying to call init on the class, or return one of the concrete instances with default values. However, the concrete…
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
0
votes
1 answer

putting ivars into init

I have two view controllers: BSViewController which contains the source ivars number and array, and BSotherViewController which as the target needs to receive the ivars . One way of producing the desired result was provided in this question. The…
zerowords
  • 2,915
  • 4
  • 29
  • 44