Objective-C 2.0 is a revision of the Objective-C language created by Apple to include, amongst other things, an enhanced syntax.
169
votes
4answers
26k views
Should IBOutlets be strong or weak under ARC?
I am developing exclusively for iOS 5 using ARC. Should IBOutlets to UIViews (and subclasses) be strong or weak?
The following:
@property (nonatomic, weak) IBOutlet UIButton *button;
Would get rid ...
88
votes
2answers
17k views
Can I use Objective-C blocks as properties?
Is it possible to have blocks as properties using the standard property syntax?
Are there any changes for ARC?
58
votes
18answers
5k views
Style: Dot notation vs. message notation in Objective-C 2.0
In Objective-C 2.0 we got the "dot" notation for properties. I've seen various back and forths about the merits of dot notation vs. message notation. To keep the responses untainted I'm not going to ...
46
votes
3answers
30k views
UIView and initWithFrame and a NIB file. How can i get the NIB file loaded?
I have a UIView called baseViewand in that i have initWithFramewhere i add some other views and do some custom stuff. The same view also has a NIB file.
Now i have a UIViewController class named ...
23
votes
1answer
8k views
Existing ivar 'title' for unsafe_unretained property 'title' must be __unsafe_unretained
I'm just getting to grips with Objective-C 2.0
When I try to build the following in Xcode it fails. The error from the compiler is as follows:
Existing ivar 'title' for unsafe_unretained property ...
21
votes
2answers
7k views
Objective-C 2.0 properties: Why both retain and readonly?
I've noticed that some of Apple's examples include both a retain and readonly modifier on properties. What's the point of including retain if no setter gets generated when we're using the readonly ...
18
votes
3answers
3k views
Does Objective-C support Mixin like Ruby?
In Ruby, there's Modules and you can extend a class by "mixing-in" the module.
Module myModule
def printone
print "one"
end
end
Class myClass
extend myModule
end
theOne = myClass.new
...
17
votes
3answers
5k views
What's the purpose of an ivar when a property exists?
The following doesn't complain at compilation nor runtime about no name ivar. So why is it so common to see an ivar and @property/@synthesize.
@interface PropTest : NSObject
{
}
@property (retain) ...
16
votes
4answers
1k views
Why is “atomic” a default @property qualifier in Objective C when I find myself using nonatomic 100% of the time?
In my few years as an iOS developer I don't think I've ever used atomic on a property. If I can see potential race conditions or data integrity issues due to threading, using atomic on a @property ...
15
votes
2answers
3k views
What's the Difference Between nil and Nil
In Objective C?
Are they really the same thing?
How to test that an object is nil?
14
votes
3answers
3k views
Can multiple (two) persistent stores be used with one object model, while maintaining relations from one to the other?
Introduction
My iOS project ships with a Core Data persistent store weighing some 160MB in SQLite format. There is a ton of grouped information in there, in which users should be able to mark ...
14
votes
4answers
21k views
QR Code library for iphone [duplicate]
Possible Duplicate:
QR code reader for iPhone
am developing an application for iphone to read & create QR Code. is there any common library available in open source ?
11
votes
3answers
2k views
Since when is it possible to declare Objective-C 2.0 properties in a category?
I always thought that one cannot declare an object property in a category.
Until my partner did it in our app's code, and it seemed to work.
I went on a SO and Google binge to try to explain to him ...
11
votes
5answers
7k views
How to programmatically get iOS's alphanumeric version string
I've been working with the nice PLCrashReport framework to send to my server the crash reports from my user's iOS devices.
However, to symbolicate the crash report, the symbolicatecrash utility ...
11
votes
8answers
13k views
(null) libc++abi.dylib: terminate called throwing an exception
I use Xcode 4.5PR and iOS 6beta 2.
I didn't change any codes, my application throw an exception mentioned in the Title.
I used Debug Window which function caused this exception, but it showing
...
9
votes
3answers
3k views
Will GNUstep support @property and @synthesize?
I'm working on a Cocoa app with the intention of using it on Windows and Linux using GNUstep. I've been avoiding Objective-C 2.0 features thus far, but I'd really love to start using at least ...
7
votes
2answers
2k views
Objective-C 2.0 dot notation - Class methods?
Please note I am specifically referring to the fact that dot notation is being used on class methods, not instance methods.
Out of curiosity, I wanted to see what would happen if I tried to use ...
7
votes
2answers
340 views
How does the Objective-C runtime retrieve the list of classes and methods?
If I get the following Objective-C source file:
// test.m
#import <objc/Object.h>
@interface MySuperClass: Object {
}
-(void) myMessage1;
@end
@implementation MySuperClass
-(void) myMessage1 ...
7
votes
2answers
2k views
What do you bind NSArrayController's Managed Object Context to in Xcode 4?
I am trying to build an document-based application for beer reviewing that allows you to enter your notes. I have built the model in Core Data and the view in Interface Builder. Following some Xcode ...
6
votes
1answer
112 views
What is an Objective-C 2.0 class interface and implementation converted into by GCC or Clang
Since Objective-C is a C superset, all Objective-C specific statements are converted into C statements during the compiling of a .m file (by the preprocessor, I guess). So, for example, a message ...
6
votes
1answer
1k views
Returning from method inside a @synchronized block
I'd just like to know if it's advised to return from a method within a @synchronized block? For example:
- (id)test {
@synchronized(self) {
if (a) return @"A";
else return @"B";
}
}
...
6
votes
4answers
831 views
Objective-C property assignment returns the assigned value?
Say I have the following:
@interface MyClass : NSObject { NSString* _foobar; }
@property (nonatomic, retain) NSString* foobar;
@end
@implementation MyClass
@dynamic foobar;
- (void) ...
6
votes
1answer
400 views
Objective-C 2.0 ABI specification
Does documentation for the Objective-C 2.0 ABI exist somewhere on the Internet? The release notes for objc4-493.9 say:
Forthcoming documentation will describe the ABI for the use of compilers and ...
5
votes
3answers
985 views
What are the real advantages of using blocks in Objective-C? [closed]
I have learned about blocks in ObjC, the syntax is clear and simple. I can read “blocks are a great feature, the syntax is...” almost everywhere. However, I miss the real advantages of their using.
...
5
votes
2answers
2k views
Is any memory leak in iOS accepted at all?
I am new to Objective-C (coming from Java) and I think I am getting a pretty good understanding of memory management.
But when my app loads, I get a extremely small memory leak, that only occurs when ...
5
votes
3answers
2k views
objective-c: double pointers to property not allowed?
I want to create a method like this:
- (void) checkAndUpdateStringProperty: (NSString **) property{
if (...)
*property = @"whatever";
}
I want to use this to pass in a property for the ...
5
votes
1answer
632 views
__strong and __weak keyword placement - Objective-C
The compiler seems to have no problem with the two following declarations:
NSObject * __weak weakThing;
__weak NSObject *anotherWeakThing;
Is there a difference between the two? Is the behavior ...
5
votes
1answer
710 views
Objective C: ARC with IVars declared in implementation file
I found an interesting post describing how, in Objective-C 2.0, instance variables can be declared in the implementation file. Consider this example:
@interface MyClass {}
@end
@implementation ...
5
votes
1answer
187 views
Why Are Almost All iOS SDK Delegate Methods Optional?
I understand the pros and cons of optional vs. required delegate methods. But I was struck by how few of the iOS delegate methods are required. Is there some wisdom that the iOS SDK designers have ...
5
votes
1answer
263 views
Get the object which called a method
If I have a call from within a random class like this:
@implementation SomeClass
- (void) classMethodFoo
{
int a = [SomeSingleton sharedInstance].aValue;
}
@end
Inside SomeSingleton ...
5
votes
2answers
1k views
How does one use Obj-C 2.0 with GNUstep?
I'm aware of the existence of libobjc2, and I gather that I'll need to use clang rather than GCC, but I can't find any basic instructions of what's different about the compilation process.
Can anyone ...
4
votes
4answers
1k views
What is the point of @property and @synthesize?
I haven't been able to figure it out, and there are no websites which explain it clearly enough... what exactly are the purposes of @property and @synthesize?
Thanks in advance!
4
votes
2answers
290 views
objective-c union “->” vs “.”
let me start by saying i am pretty new to the whole struct and union thing. i have done my homework before posting this and honestly trying to get legitimate clarification. if this is the wrong way to ...
4
votes
1answer
2k views
For…in statement Objective-C
I am studying Objective-C and I came across this "for...in" statement. I searched for it but i still don't get how it works. Could someone so nice and explain to me in a noob-friendly how this ...
4
votes
3answers
1k views
How do I make a MKAnnotationView touch sensitive?
I currently have a map view with some annotation on it. I have the annotation with custom images. The problem I am trying to fix is the sensitivity of the images. When I try to drag them, it feels ...
4
votes
4answers
833 views
Planning on writing operating system in Objective-C
At the moment I'm learning objective c 2.0, and soon I plan on learning assembly language, so I can write an operating system. I know it won't be easy, and I know it will take months, perhaps years, ...
4
votes
2answers
362 views
Testing multi-threading
I'm trying to make sure that my implementation of ObjC multithreading is proper when I transfer the application from single-thread to multiple.
Right now I have unit tests set up to make sure ...
4
votes
1answer
94 views
Having trouble understanding Objective-C Block Documentation
I'm currently having trouble understanding the fundamentals of Obj-C blocks and the __block storage type. From the following documentation:
...
3
votes
3answers
733 views
What is the difference between instancesRespondToSelector and respondsToSelector in Objective-C?
The only difference I observed on my own is that respondsToSelector's receiver can either be a class or an instance, while instancesRespondToSelector can only have a class receiver. What else makes ...
3
votes
3answers
921 views
Objective-C: preferred way to retrieve the superclass of a Class instance
I am wondering which of the two following methods is the correct or preferred one to retrieve the superclass of a Class variable:
Class getSuperclass(Class cls) { return [cls superclass]; }
Class ...
3
votes
3answers
305 views
Is object free / freed on dealloc and / or release?
I recently took an objective-c test to see how I would do.
Turns out my score wasn't anywhere near as good as I hoped. That means more studying.
During the test, I was asked this question:
How do ...
3
votes
2answers
187 views
Why Objective-C properties are sort of inconvenient?
It is more of a complain than a question, though maybe someone has some good points on it. So basically if you want an ivar in your Objective-C class have accessor-methods you have to mention it 3 ...
3
votes
1answer
121 views
How are instance variables and methods stored in an Objective-C 2.0 object?
In the legacy version of Objective-C, an objc_class struct is implemented like this:
struct objc_class {
Class isa;
Class super_class;
const char *name;
long version;
long info;
...
3
votes
4answers
732 views
Synthesize property to a Base class' ivar
I have a hierarchy of model objects which I will be displaying on different type of UITableViewCell subclasses. All decision is made on the fly as to which model object should be used and ...
3
votes
1answer
3k views
NSLog(@“%d”, a) NSLog(@“%g”, a); difference between @“%d” and @“%g”
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Hello, ...
3
votes
1answer
1k views
Error “Create a concrete instance!”
I've got another problem in the same code...
I'm getting this error:
initialization method -initWithCharactersNoCopy:length:freeWhenDone: cannot be sent to an abstract object of class ...
3
votes
4answers
1k views
Getter and Setter Explained?
I am just learning OOP from a book I picked up (Big Nerd Ranch), and it just went through the getter and setter chapter. I would just like to clarify I understand what I have just done. Instead of ...
3
votes
2answers
206 views
When declaration of property is unavoidable — Objective C 2.0
Working on a maintenance project, I am struggling with lot of messy code. In the current assignment, I found that the previous developer has defined property (and synthesize) for each and every iVar ...
3
votes
1answer
589 views
Which NSTextView is the First Responder?
I'm working on a Cocoa programming exercise, and I need to be able to determine which of two NSTextView objects is currently being edited. I think it's something to do with finding the first responder ...
3
votes
1answer
247 views
Admob banner position not coming correct in ipad/iphone
I have implemented admob in my 2d game, i am using cocos2d for developing this game, can any one help me to set the position admob banner, I have universal game which is in portrait mood, i want to ...