• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: split up alloc and init?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: split up alloc and init?


  • Subject: Re: split up alloc and init?
  • From: John Terranova <email@hidden>
  • Date: Mon, 11 Feb 2008 08:25:42 -0800

I'm not sure I follow.

Once I call [NSInvocationOperation initWithTarget:selector:object:], then the object is set and unchangeable. I guess one option would be to learn about NSInvocation and modify the parameters in it directly.

DDLThumbMakerOp *opBig = [[DDLThumbMakerOp alloc] initWithTarget:self selector:@selector(threadedThumbMaker:) object:[NSNull null]; // placeholder object
NSInvocation *inv = [opBig invocation];
[inv setArgument:&opBig atIndex:3];


Hmmm, that might be an option.

	john


On Feb 11, 2008, at 12:46 AM, Scott Andrew wrote:

Wouldn't it be better to make it a wrapper around invocation object? Ten the problem goes away. You could then have a function

-(InvocationObject*) invocationObject;

or even a static init that returnes an auto released invocation object that has a single instance of your op class. Something like..


@interface DDLThumbMakerOp { NSInteger pageIndex; CGFloat thumbSize; }

@property(assign, readwrite) NSInteger pageIndex;
@property(assign, readwrite) CGFloat thumbSize;

-(InvocationObject*) invocationObjectForTarget:(id)target selector: (SEL)selector;

@end

You call can then use.

DDLThumbMakerOp *opBig = [[[DDLThumbMakerOp alloc] init] autorelease];

opBig.pageIndex = index;
opBig.thumbSize = size;

NSInvocationObject* invocationObject = [opBig invocationObjectForTarget:self selector:@selector(threadedThumbWithData)];

[opQ addOperation: invocationObject];

The invocation creation would be.

-(InvocationObject*) invocationObjectForTarget:(id)target selector: (SEL)selector
{
return [[NSInvocationObject alloc] initWithTarget:target selector:selector object:self];
}


This will make your DLLThumbMakerOp still a parameter of the selector. And i think its a bit easier on the eyes, at least to me and encapsulated nicely.

Scott

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: split up alloc and init?
      • From: Alastair Houghton <email@hidden>
    • Re: split up alloc and init?
      • From: Scott Andrew <email@hidden>
References: 
 >split up alloc and init? (From: John Terranova <email@hidden>)
 >Re: split up alloc and init? (From: Scott Andrew <email@hidden>)

  • Prev by Date: Re: split up alloc and init?
  • Next by Date: Re: split up alloc and init?
  • Previous by thread: Re: split up alloc and init?
  • Next by thread: Re: split up alloc and init?
  • Index(es):
    • Date
    • Thread