FROM : Shaun Wexler
DATE : Fri Apr 01 20:06:31 2005
On Apr 1, 2005, at 9:52 AM, Julian Cain wrote:
> Well, the thing is in my custom cell I am doing all this...
>
> _imageLeft = [[[NSImage imageNamed:@"TB_Segment_LeftCap"]
> setFlipped:YES] retain];
Please RTFM, and you'll see that the -setFlipped: method does not
return an object. You're retaining nothing, and thus your ivars are
undefined. If you really want to stack all that gack into one line,
you'd have to do something ugly like:
[(_imageLeft = [[NSImage imageNamed:@"TB_Segment_LeftCap"] retain])
setFlipped:YES];
[(_imageRight = [[NSImage imageNamed:@"TB_Segment_RightCap"] retain])
setFlipped:YES];
It's better to create your objects, retain them, and cache the pointer.
Then you can send them messages:
// create all of my static images
_imageLeft = [[NSImage imageNamed:@"TB_Segment_LeftCap"] retain];
_imageRight = [[NSImage imageNamed:@"TB_Segment_RightCap"] retain];
...
// flip all images
[_imageLeft setFlipped:YES];
[_imageRight setFlipped:YES];
...
It's easier to read the code when blocks of identical messages are
grouped together, and it's more cache-friendly.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
DATE : Fri Apr 01 20:06:31 2005
On Apr 1, 2005, at 9:52 AM, Julian Cain wrote:
> Well, the thing is in my custom cell I am doing all this...
>
> _imageLeft = [[[NSImage imageNamed:@"TB_Segment_LeftCap"]
> setFlipped:YES] retain];
Please RTFM, and you'll see that the -setFlipped: method does not
return an object. You're retaining nothing, and thus your ivars are
undefined. If you really want to stack all that gack into one line,
you'd have to do something ugly like:
[(_imageLeft = [[NSImage imageNamed:@"TB_Segment_LeftCap"] retain])
setFlipped:YES];
[(_imageRight = [[NSImage imageNamed:@"TB_Segment_RightCap"] retain])
setFlipped:YES];
It's better to create your objects, retain them, and cache the pointer.
Then you can send them messages:
// create all of my static images
_imageLeft = [[NSImage imageNamed:@"TB_Segment_LeftCap"] retain];
_imageRight = [[NSImage imageNamed:@"TB_Segment_RightCap"] retain];
...
// flip all images
[_imageLeft setFlipped:YES];
[_imageRight setFlipped:YES];
...
It's easier to read the code when blocks of identical messages are
grouped together, and it's more cache-friendly.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
| Related mails | Author | Date |
|---|---|---|
| Julian Cain | Apr 1, 15:30 | |
| j o a r | Apr 1, 17:06 | |
| Julian Cain | Apr 1, 18:25 | |
| daniel | Apr 1, 18:52 | |
| Julian Cain | Apr 1, 19:52 | |
| j o a r | Apr 1, 20:00 | |
| Shaun Wexler | Apr 1, 20:06 | |
| Julian Cain | Apr 1, 20:28 | |
| Will Mason | Apr 1, 20:37 | |
| Guy English | Apr 1, 20:47 | |
| daniel | Apr 1, 20:49 | |
| Sean McBride | Apr 1, 20:53 |






Cocoa mail archive

