ivar Questions

3

Solved

I know it's not a great idea to try and place properties in a category. Can I access a class' instance variables from within a category that extends it? Or is it necessary to expose an accessor on ...
Shareeshareholder asked 16/3, 2014 at 19:10

5

Solved

I have been unable to find any information on this topic and most of what I know about it has come by complete accident (and a few hours of trying to figure out why my code wasn't working). While l...
Timecard asked 13/7, 2012 at 20:39

3

Solved

Sometimes I declare an ivar but after a while I am no longer using it. I would like to remove this sort of cruft from my code, but I cannot find a warning that will show me my unused ivars. Is th...
Veator asked 13/1, 2014 at 22:59

1

Solved

I understand we can use associative references to invoke ivar-like behavior in categories. But what's the specific reason behind not being able to declare new ivars in categories? Is it because we...
Spell asked 10/1, 2014 at 3:24

4

Solved

I have an application that I'm writing that uses solely @properties. I have not one ivar declared at all in any of my class files. As I understand it ivars are no longer needed with the introductio...
Dwarfism asked 25/1, 2012 at 21:34

3

Solved

I have a @class Foo which contains a __weak id bar ivar. Several actions from methods in different classes can cause the object to disappear and thus get bar niled. I want to perform an action whe...
Abuttals asked 19/2, 2013 at 12:21

1

Solved

General Problem Until now, I always thought self->_ivar is equivalent to _ivar. Today I found out that this is not entirely true. See, for example the following code snippet: @interface TestC...
Laing asked 29/10, 2013 at 15:0

4

Solved

In implementing an interface it seems the common method in tutorials and literature is to declare an ivar and then set the @property then @synthesize. @interface MyClass : NSObject { NSString *myS...
Disposure asked 5/4, 2011 at 17:13

2

Solved

I know Objective-C doesn't allow you to use C arrays as property types. I get the compiler error I expect in that case. But I'm surprised at the behavior I'm seeing with regards to C arrays inside...
Synesthesia asked 25/7, 2013 at 23:51

1

Solved

I'm trying to declare some instance variables for a custom button class in Objective-C (for iOS): @interface PatientIDButton : UIButton { NSUInteger patientID; NSString * patientName; } @end H...
Mochun asked 7/7, 2013 at 2:38

7

Solved

I usually see this question asked the other way, such as Must every ivar be a property? (and I like bbum's answer to this Q). I use properties almost exclusively in my code. Every so often, howeve...
Disembowel asked 31/1, 2012 at 20:51

2

Solved

I have a read-only property isFinished in my interface file: typedef void (^MyFinishedBlock)(BOOL success, NSError *e); @interface TMSyncBase : NSObject { BOOL isFinished_; } @property (nonatom...

3

Solved

This has been asked a lot, but this question is to get examples of when you would use each of these methods. Please use examples other than the setter and getter infinite loop example. .h...
Gecko asked 26/3, 2013 at 18:10

2

In most project before Xcode 4.4, I realized that developers declared simultaneous an ivar and a property with the same name. Example @interface SecondViewController : UIViewController { NSString...
Auriscope asked 2/3, 2013 at 9:25

2

Solved

Though I'm sure they exists, I'm having difficulties finding or pinning down an official best practice for declaring outlets in a ViewController. There are 3 options so far as I can see: ivar on...
Zillion asked 26/4, 2012 at 8:51

3

Solved

If I have a @property which I didn't want to have backed via an ivar I simply omitted the @synthesize and had manual getters which returned a calculated value. However, now since Xcode 4.4 if I do...
Lavoisier asked 17/10, 2012 at 11:57

1

Solved

I am confused as to why some classes declare a property but do not declare an ivar and vice versa. Is it standard practice when declaring an instance variable to also declare it as a property as ...
Carpogonium asked 18/8, 2012 at 2:19

2

Solved

I was messing around in Objective-C earlier, and I ran into a quite common situation: I had a class, which was not a singleton, that needed a variable shared between method calls, like static, but...
Fingerbreadth asked 17/8, 2012 at 1:59

1

I am quite confused about how to change an instance variable inside of a block. The interface file (.h): @interface TPFavoritesViewController : UIViewController { bool refreshing; } The implem...
Kamerad asked 1/8, 2012 at 4:19

2

Assume the following code under ARC, typedef void (^MyResponseHandler) (NSError *error); @interface MyClass : NSObject { MyResponseHandler _ivarResponseHandler; } - (void)myMethod:(MyResponseHan...

7

Solved

What is the proper syntax for accessing an instance variable in Objective-C? Assume we have this variable: @interface thisInterface : UIViewController { NSMutableString *aString; } @property (n...
Ridicule asked 15/6, 2011 at 15:22
1

© 2022 - 2024 — McMap. All rights reserved.