Questions tagged [objective-c]

This tag should be used only on questions that are about Objective-C features or depend on code in the language. The tags [cocoa] and [cocoa-touch] should be used to ask about Apple's frameworks or classes. Use the related tags [ios], [macos], [apple-watch] and [tvos] for issues specific to those platforms.

Objective-C is an object-oriented programming language combining features of C () and Smalltalk (). It is a strict superset of C (any valid C code is equally valid Objective-C code, with the minor exception that id is a free identifier for user use in C while it is a keyword in Objective-C), and it inherits its object-oriented capabilities from Smalltalk. All procedural syntax is identical to that of C, and all object-oriented syntax is an implementation of Smalltalk messaging.

Objective-C was created primarily by Brad Cox and Tom Love in the early 1980s at their company Stepstone. It is now primarily developed by Apple, Inc.

Objective-C is a general-purpose, high-level, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. It is the main programming language used by Apple for and and their respective APIs, and .

Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods. It also adds language-level support for object graph management and object literals while providing dynamic typing and binding, deferring many responsibilities until run time.

Hello World in Objective-C

#import <Foundation/Foundation.h>

int main(void)
{
    NSLog(@"Hello World!");
    return 0;
}

Syntax

Objective-C is a thin layer on top of C, and moreover is a strict superset of C; it is possible to compile any C program with an Objective-C compiler, and to freely include C code within an Objective-C class. Objective-C derives its object syntax from Smalltalk. All of the syntax for non-object-oriented operations (including primitive variables, pre-processing, expressions, function declarations, and function calls) is identical to that of C, while the syntax for object-oriented features is an implementation of Smalltalk-style messaging.

Objective-C has many powerful features as detailed below:


References

Frequently posted questions in the Objective-C tag

Books

Video Tutorial

  • Developing iOS 7 Apps for iPhone and iPad by Stanford University - FREE
    From the site, "Tools and APIs required to build applications for the iPhone and iPad platform using the iOS SDK. User interface designs for mobile devices and unique user interactions using multi-touch technologies. Object-oriented design using model-view-controller paradigm, memory management, Objective-C programming language." (Similar courses are also available for iOS 8 & 9, but only in Swift)

Related Tags

292452 questions
60
votes
4 answers

Why use weak pointer for delegation?

I can't understand why it is correct to define a delegate with weak pointer : @property (nonatomic,weak) id delegate; I can't realize why isn't necessary to retain a reference to the delegate... i don't want the object that i use as the delegate…
MatterGoal
  • 16,038
  • 19
  • 109
  • 186
60
votes
2 answers

`[super viewDidLoad]` convention

I see some example code with [super viewDidLoad] called before your implementation and after your implementation. I know you don't always have to call super (as seen in many other discussions). When you do call it, is it expected before or after you…
Corey Floyd
  • 25,929
  • 31
  • 126
  • 154
60
votes
1 answer

How is view initialized when loaded via a storyboard?

When view is loaded manually, developer remains in control when it comes to initializations, we choose what initializer to call, what variables to set etc. When view is loaded from the storyboard segue ... what happens to that initializer? Where…
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
60
votes
6 answers

How to press "Back" button in UINavigationController programmatically

I have a UIViewController called FriendsViewController inside a UINavigationController. And a second UIViewController called FriendsDetailedViewController. When navigating from the first view controller to the second, I want to programmatically…
60
votes
8 answers

BOOL to NSString

If I have a method that returns a BOOL, how do I cast that to an NSString so I can print it out in console? For example, I tried doing this, which isn't working: NSLog(@"Is Kind of NSString:", ([thing isKindOfClass:[NSString class]]) ? @"YES" :…
Craig
  • 16,291
  • 12
  • 43
  • 39
60
votes
9 answers

Scroll to top of UITableView by tapping status bar

I know there's tons of code out there to scroll a tableview to the top, but I want to do this when the top status bar is tapped, just like in Apple's native apps. Is this possible?
iOSDev
  • 1,028
  • 4
  • 13
  • 21
60
votes
21 answers

Why Emacs/Vim/Textmate? Isn't Xcode good enough?

Hi I mostly do C++, Objective-C programming. And I found Xcode plus an auto completion/macro plugin (Completion Dictionary) quite adequate. However, all people seem to praise over their pure text editors. I tried Textmate for a bit; liked its…
ivanTheTerrible
  • 2,836
  • 4
  • 25
  • 25
60
votes
5 answers

Optional arguments in Objective-C 2.0?

In Objective-C 2.0, is it possible to make a method where the argument is optional? That is, you can have a method call like this: [aFraction print]; as well as this: [aFraction print: someParameter]; in the same program. Apple's Objective-C 2.0…
willc2
  • 38,991
  • 25
  • 88
  • 99
60
votes
8 answers

set background image for entire iPhone / iPad app

I have a single image I want as the background for my app no matter what viewcontroller they are on - how do you accomplish this?
Slee
  • 27,498
  • 52
  • 145
  • 243
60
votes
8 answers

iOS 11 large-title navigation bar not collapsing

The Apple guy in the What's new in Cocoa Touch WWDC video said that the new large-title navigation bar will magically hook into the top-level scroll view of the underlying view controller and collapse/expand itself automatically while scrolling up…
Tamás Zahola
  • 9,271
  • 4
  • 34
  • 46
60
votes
13 answers

UIImageView doesn't always tint template image

In the case below, there are two UIImageViews with the same settings and the same template image... But one tints the image, and one does not I duplicated working UIImageView and placed it instead of the other and it worked. This happened to me…
Zuzana Paulis
  • 941
  • 1
  • 8
  • 19
60
votes
3 answers

Getting the top most UIViewController

If I push view controllers and/or present modal view controllers on a UINavigationController, how can I find out what is the top most UIViewController? Or in my case, I want to know if a certain UITableViewController is the top most or not. I tried…
Senseful
  • 86,719
  • 67
  • 308
  • 465
60
votes
3 answers

Error in iOS 10 : Unable to copy asset information from https://mesu.apple.com/assets/ for asset type

2016-10-05 13:36:21.383340 MyApp[1867:72704] 0x60000015e350 Copy matching assets reply: XPC_TYPE_DICTIONARY { count = 1, transaction: 0, voucher = 0x0, contents = "Result" => : 29 } 2016-10-05…
Rahul Mayani
  • 3,761
  • 4
  • 25
  • 40
60
votes
12 answers

How to check if array is null or empty?

I want to check if my array is empty or null, and on base of which I want to create a condition for example. if(array == EMPTY){ //do something } I hope I'm clear what I am asking, just need to check if my array is empty? regards
Shishir.bobby
  • 10,994
  • 21
  • 71
  • 100
60
votes
12 answers

How to open Location services screen from setting screen?

I want to open location service screen programmatically to turn on service.
Monika Patel
  • 2,287
  • 3
  • 20
  • 45