Re: Beginner with Objective-C was Re: scanf...?
Re: Beginner with Objective-C was Re: scanf...?
- Subject: Re: Beginner with Objective-C was Re: scanf...?
- From: Óscar Morales Vivó <email@hidden>
- Date: Mon, 10 Apr 2006 11:56:50 -0400
Although I agree that a good foundation in C is indispensable to
learn Objective-C and, by extension, Cocoa, I'm not sure the
intricacies and quirks of the C string libraries are a required part
of that foundation. Once you get into libraries rather than the
language itself, it's certainly recommended to use the given
Foundation classes over the C libraries in most cases. It may be
better to learn about string manipulation with more sensible
libraries than the C ones. If one must learn string.h later on, at
least he'll have first learned how it's done right :P
Just my 2c
On Apr 10, 2006, at 11:10 , Erik Buck wrote:
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
_______________________________________________
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