Questions tagged [objective-c]

Objective-c is a highly dynamic message-based object-oriented language, superset of C, that is a primarily used for programming Apple's Mac OS X and iOS platforms.

A programming language that is an object-oriented Smalltalk-based extension to C. It was not developed by Apple but it is now heavily used by Apple in OSX and iOS.

194 questions
25
votes
2 answers

Why is Objective-C not widely used beyond Cocoa environments?

Objective-C features nice object orientation, simplicity, elegance, and (as a superset of C), low level ability. It could seem like the simple, modern alternative to C++ that many people look for and try to find in Go. But it is just used at Cocoa…
6
votes
2 answers

What is the standard for naming variables and why?

I'm going through some training on objective-c. The trainer suggests setting single character parameter names. The .NET developer in me is crying. Is this truly the convention? Why? For example, @interface Square : NSObject { int…
5
votes
1 answer

Why check if object is nil

What's the point of the if statement in the following code: - (NSArray *)myMethod { NSArray *array = nil; if (!array) { array = [[NSArray alloc] initWithObjects...] } return array; } What's the point of the check if we…
Jessica
  • 153
4
votes
2 answers

see what ARC does?

If I understand correctly, all ARC does is automatically add memory-management statements such as retain and autorelease in the proper places in a program. Is there any way to see all the memory-management statements that ARC automatically adds to a…
JoelFan
  • 7,091
3
votes
1 answer

Pragma Mark in Cocoa

I'm a newb to cocoa programming and looking around in various open source code online I see things like: #pragma mark global variable declaration and I was wondering what the meaning of "pragma mark" is in that is it any different than a // or /*…
Zac Brown
  • 33
  • 1
  • 3
3
votes
3 answers

Why does Objective-C store objects on the heap instead of on the stack?

I have a basic understanding of what a "stack" and "heap" are. You use a stack to store items in memory that should be read and/or removed in a last-in-first-read/removed manner. To steal another example from someone else's Website, you use it to…
moonman239
  • 2,053
3
votes
1 answer

What is the name of the method to find index from array, in Objective-c?

I have a following method to find index of a book object which have a book name: +(NSInteger)indexXXX:(NSString *)bookName XXX:(NSArray *)books { for (NSInteger i = 0; i < books.count; i++) { NSDictionary *book = [books objectAtIndex:i]; …
js_
  • 143
  • 1
  • 5
1
vote
2 answers

Why is "working with files" is an important subject when learning Objective C?

I'm reading a book on Objective C, and I was wondering how important the subject Working with files for learning to develop iOS in particular? On you tube the tutorials are very short, maybe 10 min of video that teaches you how to do stuff with…
JohnBigs
  • 171
1
vote
3 answers

How to indicate the word is method name in Objective-C?

You can indicate that XXX is method name by writing XXX(). But in Objective-C, you can not write XXX() for XXX method. If you write XXX, you can't tell if XXX is method name or other type of identifier. How can you indicate that XXX is method name…
js_
  • 143
  • 1
  • 5
-2
votes
1 answer

How come the keyword for declaring a class is 'interface'

What is the relationship between a class and an interface in objective-c? How come we declare a class using @interface instead of @class?
-2
votes
3 answers

Is explicit else needed in initialisers?

I have a custom designated initialiser like this: - (id)initWithLocation:(CLLocation *)location { if (location == nil) { return nil; } self = [super init]; if (self) { self.location = location; } …
Earl Grey
  • 628
-3
votes
2 answers

What's the benefit of a singleton over a class in objective-c?

They both seem to take about the same amount of effort to use: Singleton: needs a .h and .m file, has to be imported into any class you want to call it from and then has to be instantiated How is that any different than a class?
PruitIgoe
  • 1
  • 3