Beginner with Objective-C was Re: scanf...?
Beginner with Objective-C was Re: scanf...?
- Subject: Beginner with Objective-C was Re: scanf...?
- From: Erik Buck <email@hidden>
- Date: Mon, 10 Apr 2006 08:10:39 -0700 (PDT)
I actually disagree with many who say it is not necessary to thoroughly understand the C programming language before learning Cocoa. However, we may all be talking at cross purposes, and we may even be saying the same thing in different ways.
As several people have stated, Objective-C is a superset of C. Objective-C includes all of C and adds just a little bit more to facilitate a dynamic kind of object oriented programming. I think those who say just skip C and start with Objective-C are misguided for the following reason: Objective-C is trivial to learn if you already know C. A truly raw beginner needs a lot of foundation skills and concepts, and frankly the C part of Objective-C will take a lot longer to learn than the objective part.
I am not saying that a four year education in Computer Science is needed to master Objective-C, although I think every programmer would benefit from the breadth and depth that such a course will provide. I am however saying that Objective-C programmers need to know about pointers, details of C syntax including things like pointers to functions, the nature of C strings and arrays, etc.
An Objective-C programmer needs to understand what this code from http://developer.apple.com/documentation/Performance/Conceptual/CodeSpeed/Articles/CriticalCode.html does and why:
#import <Foundation/Foundation.h>
#include <objc/objc-class.h>
static void DoSomethingWithString( NSString *string )
{
typedef NSRange (*RangeOfStringImp)(id object, SEL selector,
NSString * string, long options, NSRange range);
NSRange foundRange;
NSRange searchRange;
RangeOfStringImp rangeOfStringImp;
searchRange = NSMakeRange(0, [string length]);
// The following two lines of code are equivalent to this method invocation:
// foundRange = [string rangeOfString:@"search string"
// options:0
// range:searchRange];
rangeOfStringImp = (RangeOfStringImp)
[string methodForSelector:@selector(rangeOfString:options:range:)];
foundRange = (*rangeOfStringImp)(string,
@selector(rangeOfString:options:range:),
@"search string", 0, searchRange);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden