1.
Now with ARC, how would a simple little program like this look like with ARC?:

#import <Foundation/Foundation.h>
#import "FakeClass.h"

int main(int argc, const char* argv[])
{
NSAutoreleasePool *pool = [ [NSAutoreleasePool alloc] init];

FakeClass *object = [ [FakeClass alloc] init];

//do some stuff

[object release];
[pool drain];

return 0;
}

2.
NSString *d = @"Dont feed grapes to dogs!";

NSRange range = [d rangeOfString:@"grapes"];

why is the NSString object a pointer but not the NSRange object?

Recommended Answers

In answer to the first question, drop the statement creating the autorelease pool
and
[object release]
[pool drain]
statements

NSString is an object
NSRange is a foundation data type, ie not an object, and as such does not require the *

Jump to Post

All 3 Replies

Anyone?

Aaanyone?

In answer to the first question, drop the statement creating the autorelease pool
and
[object release]
[pool drain]
statements

NSString is an object
NSRange is a foundation data type, ie not an object, and as such does not require the *

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.