2 Replies - 2642 Views - Last Post: 19 December 2011 - 05:04 PM

#1 Torchi12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-December 11

Two objective c questions...

Posted 18 December 2011 - 06:05 AM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: Two objective c questions...

#2 heyoman1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 64
  • View blog
  • Posts: 735
  • Joined: 30-November 09

Re: Two objective c questions...

Posted 18 December 2011 - 07:58 PM

Dunno what ARC is, but yes, that is how you create a class pointer in Obj-C. As for the second question, the message (class method) is returning a pointer to an NSRange class already, so you can't have a pointer to another pointer. That's like a double negative. </metaphor>
Was This Post Helpful? 0
  • +
  • -

#3 GWatt  Icon User is offline

  • member icon

Reputation: 278
  • View blog
  • Posts: 3,079
  • Joined: 01-December 05

Re: Two objective c questions...

Posted 19 December 2011 - 05:04 PM

Actually [d rangeOfString: @"grapes"] does not return a pointer it returns a NSRange struct. Not a pointer to one. And you most certainly can have a pointer to a pointer. It's not a double negative.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1