How do I make one thread wait until another thread exits?

2009-02-12 Thread Oleg Krupnov
This seems a trivial question for a multi-threading app, but I haven't
been successful in implementing this in Cocoa. I've got deadlocks and
strange logs for seemingly no reason.

Here's my problem: There is the main thread that starts a worker
NSOperation to do some job (-[NSOperationQueue addOperation]). In case
if the main thread is asked to start another NSOperation, it must
cancel the current operation, *wait until it exits*, and start another
one.

What I have tried: the operation object creates and locks an NSLock
object in its -init. When the main thread cancels the operation
(-cancel), it does the following:

// cancel
[m_operation cancel];
// wait until operation exits
[[m_operation isCompletedLock] lock];

// the operation object eventually checks the -isCancelled flag and
then sends -unlock to the lock, and its thread exits.

// unlock the lock
[[m_operation isCompletedLock] unlock];
// release
[m_operation release];
m_operation = nil;

The effect is that sometimes it works but sometimes not, and I get
logs in the console:

*** -[NSLock lock]: deadlock (NSLock: 0x197a90 '(null)')
*** -[NSLock unlock]: lock (NSLock: 0x197a90 '(null)') unlocked from
thread which did not lock it
*** Break on _NSLockError() to debug.

Is this a valid way of implementing the subject? Am I using NSLock
correctly for this purpose? Or if not, can someone please post the
correct way of doing this?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] Abort/remove all running/pending animations

2009-02-12 Thread Ruotger Skupin

Hi,

I'm resizing and moving the content of a UIScrollView in the - 
scrollViewDidEndZooming:withView:atScale: method including the  
removing/adding of views. This usually results in the content bouncing  
more or less uncontrollable.


My question:

Is it possible to remove/abort *all* (really all) pending/running  
animations (especially those in UIScrollView) to reorder all the views  
and start custom animations from there?


Ruotger


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Garbage Collection and NSManagedObject

2009-02-12 Thread Samuel Strupp

Hi guys

i have problem with the garbage collector. May App is a CoreData App  
(not document based). If i try to change the database and load a new  
one. The grabage collector collects the old NSMangedObjects from the  
old store. But this happens in the gabage collector thread. The  
mainThread is executing, too. So some of the managed objects will be  
finalized after the deletion of the database. This results in an  
exception like this:


GC: -finalize resulted in an exception (0x1477cd0) being thrown, break  
on objc_exception_during_finalize_error to debug

The NSManagedObject with ID:XXX XXX has been invalidated.


The main problem is that such objects seems to get observer messages  
and then they will hang up the app if they try to access there  
parameters from the store.


One solution would be to perform the gabage collection in the main  
thread. But I don't know how.
Another solution should be to wait for the gabage collector until it  
is finished with somethig stupid like this:


while ([[NSGarbageCollector defaultCollector] isCollecting]) {
[NSThread sleepForTimeInterval:0.5];
}

But this hangs up the app, too. I don't know why!

So has somebody a solution or idea for this garbage collector problem?

Thanks  Regrads
Samuel Strupp
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Saving IKImageBrowser Order and Content?

2009-02-12 Thread Chunk 1978
topic says it all.  i have installed an IKImageBrowser which allows me
to drop images and reorder them.  it would be great to be able to
automatically save the dropped images as well as their order so that
the next time the app starts and the image browser loads up everything
is still there.

can someone please direct me to where i should be looking to
accomplish this?  any known tutorials maybe?

thanks
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Reading packets from an audio file

2009-02-12 Thread Michael Ash
On Thu, Feb 12, 2009 at 6:17 AM, rethish reth...@newtok.com wrote:
 Hi all,

 I need to append an newly recorded audio file with the end of an existing
 file.

 I use the function , AudioFileOpenURL (
[snip]

This is completely off-topic here. You'll probably get much better
results on the coreaudio-api list.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How do I make one thread wait until another thread exits?

2009-02-12 Thread Michael Ash
On Thu, Feb 12, 2009 at 4:25 AM, Oleg Krupnov oleg.krup...@gmail.com wrote:
 This seems a trivial question for a multi-threading app, but I haven't
 been successful in implementing this in Cocoa. I've got deadlocks and
 strange logs for seemingly no reason.

 Here's my problem: There is the main thread that starts a worker
 NSOperation to do some job (-[NSOperationQueue addOperation]). In case
 if the main thread is asked to start another NSOperation, it must
 cancel the current operation, *wait until it exits*, and start another
 one.

 What I have tried: the operation object creates and locks an NSLock
 object in its -init. When the main thread cancels the operation
 (-cancel), it does the following:

 // cancel
 [m_operation cancel];
 // wait until operation exits
 [[m_operation isCompletedLock] lock];

 // the operation object eventually checks the -isCancelled flag and
 then sends -unlock to the lock, and its thread exits.

 // unlock the lock
 [[m_operation isCompletedLock] unlock];
 // release
 [m_operation release];
 m_operation = nil;

Yeah, don't do this. Locks are for mutual exclusion *only*.

Use NSConditionLock, something like this:

#define OPERATION_FINISHED 1

// operation exit
[condLock lock];
[condLock unlockWithCondition:OPERATION_FINISHED];

// wait for exit
[condLock lockWhenCondition:OPERATION_FINISHED];
[condLock unlock];

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Garbage Collection and NSManagedObject

2009-02-12 Thread I. Savant
On Thu, Feb 12, 2009 at 9:52 AM, Samuel Strupp str...@synium.de wrote:

 i have problem with the garbage collector. May App is a CoreData App (not
 document based). If i try to change the database and load a new one.

  It's not clear what you mean here. Be *very* specific (and show code).

--
I.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


newbie question on creating .png files

2009-02-12 Thread Smith, Steven (MCP)
Hi folks,

I'm relatively new to Cocoa and need some direction on creating .png files.
I need to create 365 png files (one for each day of the year)
to be used as tags by other folks (eg JAN01.png JAN2.png...DEC31.png).

I think I understand the draw/graphics concept, but I've been unable to get
clear direction on how to transform(aka create) the picture to 48x48 .png files.

I'm not looking for code (its welcome of course), but a direction on the 
'bridge'
between create/displaying an image and saving it to a file.

Thanks in advance,
Steven  ___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving IKImageBrowser Order and Content?

2009-02-12 Thread douglas welton
I will assume that you are using an array controller to handle the  
backing data for you IKImageBrowserView.  If so, all you will need to  
do is archive the array controller's arrangedObjects (or content plus  
any filter predicate) and save it to a file - perhaps using NSArray's  
handy-dandy -writeToFile:atomically: method.


if my assumption is wrong, then you'll need to provide details of what  
you are actually doing (for data-sourcing) and what you have tried  
before you asked your question.


regards,

douglas

On Feb 12, 2009, at 10:01 AM, Chunk 1978 wrote:


topic says it all.  i have installed an IKImageBrowser which allows me
to drop images and reorder them.  it would be great to be able to
automatically save the dropped images as well as their order so that
the next time the app starts and the image browser loads up everything
is still there.

can someone please direct me to where i should be looking to
accomplish this?  any known tutorials maybe?

thanks

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Garbage Collection and NSManagedObject

2009-02-12 Thread Samuel Strupp

Hi

I simply want to delete the actual database (SQL Database) and load a  
new one.


First: all controllers which hold refs to NSManagedObjects will be  
deleted.
Then the i call [[NSGarbageCollector defaultCollector]  
collectExhaustively];

Then i disconnect from the database.

This is the code to disconnect from the databse:

-(BOOL) removeData {
 NSError *error;

if (managedObjectContext != nil) {
if ([managedObjectContext commitEditing]) {
if ([managedObjectContext persistentStoreCoordinator]
			  [[[managedObjectContext persistentStoreCoordinator]  
persistentStores] count]  0) {
if ([managedObjectContext hasChanges]  ![managedObjectContext  
save:error]) {

NSLog(@Save Error.);
}
}
}
}

managedObjectContext = nil;
persistentStoreCoordinator = nil;
managedObjectModel = nil;

return YES;
}


The problem is that the disconnect and the collection of garbage is  
parallel. So the invalidate exception is thrown.


I have no problems with the disconnect from the old and the reconnect  
to new databse. Thats working. Only the old NSManagedObjects seems to  
be not deleted and create errors.




Am 12.02.2009 um 16:30 schrieb I. Savant:

On Thu, Feb 12, 2009 at 9:52 AM, Samuel Strupp str...@synium.de  
wrote:


i have problem with the garbage collector. May App is a CoreData  
App (not

document based). If i try to change the database and load a new one.


 It's not clear what you mean here. Be *very* specific (and show  
code).


--
I.S.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextView and keyDown: in the responder chain

2009-02-12 Thread Ross Carter


On Feb 11, 2009, at 10:21 PM, Tom wrote:

However, I've found that when an NSTextView receives a keyDown event  
that doesn't handle, it doesn't bother to send the event down the  
responder chain and just calls NSBeep().


I expect that there isn't a keyDown event that NSTextView doesn't  
handle. It sends them all to -interpretKeyEvents. The events go  
through the system input manager and get back to the NSTextView in the  
form of -insertText: or -doCommandBySelector:. It is  
doCommandBySelector: that is firing the beep. You can set a breakpoint  
on NSBeep to see the call stack.


Ross
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How do I make one thread wait until another thread exits?

2009-02-12 Thread Oleg Krupnov
Thanks, Mike.

I assume that I need to also use

#define OPERATION_NOT_FINISHED 0

and

condLock = [[NSConditionLock alloc] initWithCondition: OPERATION_NOT_FINISHED];

Right?

I have a doubt here, however. What if the cancel message is sent even
before the worker thread had the possibility to start? In that case,
the NSOperation may remove itself from the queue and never start its
worker thread altogether. Than the main thread will deadlock because
the condition will never be OPERATION_FINISHED. How to fix this?




 Yeah, don't do this. Locks are for mutual exclusion *only*.

 Use NSConditionLock, something like this:

 #define OPERATION_FINISHED 1

 // operation exit
 [condLock lock];
 [condLock unlockWithCondition:OPERATION_FINISHED];

 // wait for exit
 [condLock lockWhenCondition:OPERATION_FINISHED];
 [condLock unlock];

 Mike

On Thu, Feb 12, 2009 at 3:09 PM, Oleg Krupnov oleg.krup...@gmail.com wrote:
 Can someone please give me a sample of the valid way of using
 NSCondition for this? I am still confused regarding how I can avoid
 the subtle sync errors.

 I've tried the following code

 // main thread
 // cancel operation
 [m_operation cancel];
 // wait until operation exits
 [m_operationCompletionCondition lock];
 [m_operationCompletionCondition wait];
 [m_operationCompletionCondition unlock];

 The operation object:

 - (id) initWithCompletionCondition:(NSCondition*)completionCondition
 {
...
  m_completionCondition = [completionCondition retain];
  // lock the condition while in the main thread
  [m_completionCondition lock];

 }

 // Worker thread's main
 - (void)main
 {
...
// signal operation completed from the worker thread
[m_completionCondition signal];
[m_completionCondition unlock];
 }

 The problem is however that sometimes the worker thread exits in
 between the -cancel message and before the -wait message. So there is
 nothing to wait anymore and the program waits endlessly. I don't see
 how to resolve this problem without going too sophisticated. I must be
 doing something wrong, don't I?


 On Thu, Feb 12, 2009 at 1:39 PM, Andrew Farmer andf...@gmail.com wrote:
 On 12 Feb 09, at 01:25, Oleg Krupnov wrote:

 This seems a trivial question for a multi-threading app, but I haven't
 been successful in implementing this in Cocoa. I've got deadlocks and
 strange logs for seemingly no reason.

 snip

 // the operation object eventually checks the -isCancelled flag and
 then sends -unlock to the lock, and its thread exits.

 This is not an appropriate use of locks, and the runtime error you're
 getting (lock unlocked from thread which did not lock it) is a sign of
 this misuse. Indeed, the design you've described actually contains a subtle
 synchronization error that could cause deadlock if your code attempts to
 cancel a thread before it has fully initialized.

 As a general point, though, locks are designed for mutual exclusion on
 shared resources, not inter-thread signalling. Use NSCondition for this sort
 of communication; alternatively, you may want to investigate pthread_cancel
 for a more specific solution.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: newbie question on creating .png files

2009-02-12 Thread Jean-Daniel Dupas


Le 12 févr. 09 à 16:31, Smith, Steven (MCP) a écrit :


Hi folks,

I'm relatively new to Cocoa and need some direction on creating .png  
files.

I need to create 365 png files (one for each day of the year)
to be used as tags by other folks (eg JAN01.png  
JAN2.png...DEC31.png).


I think I understand the draw/graphics concept, but I've been unable  
to get
clear direction on how to transform(aka create) the picture to  
48x48 .png files.


I'm not looking for code (its welcome of course), but a direction on  
the 'bridge'

between create/displaying an image and saving it to a file.

Thanks in advance,



All drawing code require a valid graphic context.
When you draw on screen (in an NSView for example), the framework  
setups a valid 'on screen' context before calling the drawRect: method.


If you want to draw into an image, you just have to setup a graphic  
context on an image, and call your drawing code.


A simple way to do this it to create an NSImage, and then using  
lockFocus, you can get a graphics context to draw in this image (just  
like you draw on screen).


Conceptually:

NSImage *img = [[NSImage alloc] initWithSize:48, 48];
[img lockFocus];

// you drawing code goes here

[img unlockFocus]

// Now, you can save your image using standard NSImage functions.

Unfortunately, I don't think you can save an NSImage as a PNG (it only  
supports the TIFFRepresentation method).



To have a greater control over the output format, you have to create a  
bitmap (NSBitmapImageRep)


And so, you will have a chance to use the longuest Cocoa method name:

- (id)initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide: 
(NSInteger)width pixelsHigh:(NSInteger)height bitsPerSample: 
(NSInteger)bpssamplesPerPixel:(NSInteger)spp hasAlpha:(BOOL)alpha  
isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName  
bitmapFormat:(NSBitmapFormat)bitmapFormatbytesPerRow: 
(NSInteger)rowBytes bitsPerPixel:(NSInteger)pixelBits


Create your image rep using this method.
create a graphics context using +[NSGraphicsContext  
graphicsContextWithBitmapImageRep:]


Save the current graphic state +[NSGraphicsContext saveGraphicsState]
Set your new context as the current context [NSGraphicsContext  
setCurrentContext:myContext];


Call your drawing function.

restore the graphic state +[NSGraphicContext restoreGraphicsState];

And now, your bitmap image is ready to be saved (using  
representationUsingType:).




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Garbage Collection and NSManagedObject

2009-02-12 Thread I. Savant
On Thu, Feb 12, 2009 at 10:55 AM, Samuel Strupp str...@synium.de wrote:

 I simply want to delete the actual database (SQL Database) and load a new
 one.

  Okay.

 First: all controllers which hold refs to NSManagedObjects will be deleted.

  What do you mean deleted? Do you just mean you're disconnecting
them from their managed object context?

 Then the i call [[NSGarbageCollector defaultCollector] collectExhaustively];

  Why? If you're going to do it at all, I'd imagine you'd do it after
the tear-down of *everything* related to your context and persistent
store.

 Then i disconnect from the database.

  Again, I'd do this *before* forcing collection.

 This is the code to disconnect from the databse:

 -(BOOL) removeData {
  NSError *error;
 if (managedObjectContext != nil) {
 if ([managedObjectContext commitEditing]) {
 if ([managedObjectContext persistentStoreCoordinator]
  
 [[[managedObjectContext persistentStoreCoordinator] persistentStores] count]
 0) {
 if ([managedObjectContext hasChanges] 
 ![managedObjectContext save:error]) {
 NSLog(@Save Error.);
 }
 }
 }
 }
 managedObjectContext = nil;
 persistentStoreCoordinator = nil;
 managedObjectModel = nil;
 return YES;
 }


  I don't see any code related to removing the context and
disconnecting from the persistent store. Are you really pulling the
store's file (the sqlite database) out from underneath Core Data and
expecting it to work normally? I wouldn't.

 The problem is that the disconnect and the collection of garbage is
 parallel. So the invalidate exception is thrown.

  Are you *sure* that's the problem? It may not be. My first suspect
is that I don't see anywhere that you're actually tearing down the
right parts of the Core Data stack (the context and the persistent
store).

 I have no problems with the disconnect from the old and the reconnect to new
 databse. Thats working. Only the old NSManagedObjects seems to be not
 deleted and create errors.

  Well, no, it's not really working, is it? The managed objects should
go away with your context. If they're sticking around and throwing
errors, that's your first clue that you're likely not handling the
Core Data stack properly during this disconnect process.

  Core Data lets you create and remove as many contexts as you like to
a persistent store - this is one of the features that makes Core Data
shine (and even gives it the ability to handle multithreading with
grace). If you've got managed objects hanging around after you dispose
of a context, you're doing it wrong:

Core Data Programming Guide
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html

Low Level Core Data Tutorial
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/chapter_1_section_1.html

--
I.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: newbie question on creating .png files

2009-02-12 Thread Felix Franz


On 12.02.2009, at 17:14, Jean-Daniel Dupas wrote:



Unfortunately, I don't think you can save an NSImage as a PNG (it  
only supports the TIFFRepresentation method).




You can create a new NSBitmapImageRep using the TIFFRepresentation and  
use representationUsingType:properties:

to get the PNG-data:

NSData* TIFFData = [img TIFFRepresentation];
	NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep  
imageRepWithData:TIFFData];
	NSData* PNGData = [bitmapImageRep  
representationUsingType:NSPNGFileType properties:nil];

[PNGData writeToFile: @JAN01.png atomically: YES];

HTH,

felix
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Garbage Collection and NSManagedObject

2009-02-12 Thread I. Savant
On Thu, Feb 12, 2009 at 11:23 AM, I. Savant idiotsavant2...@gmail.com wrote:

  Are you *sure* that's the problem? It may not be. My first suspect
 is that I don't see anywhere that you're actually tearing down the
 right parts of the Core Data stack (the context and the persistent
 store).

  ... sorry, every where I spoke about the persistent store, I'm
referring to manipulating the persistent store coordinator
(NSPersistentStoreCoordinator).

  It also occurs to me that it'd probably be far easier to simply
delete all managed objects in your context and save ... why replace
the actual file?

--
I.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving IKImageBrowser Order and Content?

2009-02-12 Thread Chunk 1978
hi douglas,

i am not using an array controller... my current method is copying
images to the pasteboard (they are produced images from within the
app) and writing them to a folder when they are dropped into the image
browser.  i'm assuming it shouldn't be too difficult to incorporate an
array controller into what i have already to handle the arrangements
of the images and hopefully have no problem trying to get the
imagebrowser to read the array when it opens (it appears that the
IKImageBrowser class isn't documented very strongly), but i've never
used an array controller before.  know of any tutorials off the top of
your head?




On Thu, Feb 12, 2009 at 10:52 AM, douglas welton
douglas_wel...@earthlink.net wrote:
 I will assume that you are using an array controller to handle the backing
 data for you IKImageBrowserView.  If so, all you will need to do is archive
 the array controller's arrangedObjects (or content plus any filter
 predicate) and save it to a file - perhaps using NSArray's handy-dandy
 -writeToFile:atomically: method.

 if my assumption is wrong, then you'll need to provide details of what you
 are actually doing (for data-sourcing) and what you have tried before you
 asked your question.

 regards,

 douglas

 On Feb 12, 2009, at 10:01 AM, Chunk 1978 wrote:

 topic says it all.  i have installed an IKImageBrowser which allows me
 to drop images and reorder them.  it would be great to be able to
 automatically save the dropped images as well as their order so that
 the next time the app starts and the image browser loads up everything
 is still there.

 can someone please direct me to where i should be looking to
 accomplish this?  any known tutorials maybe?

 thanks

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Design Question

2009-02-12 Thread David Duncan

On Feb 12, 2009, at 9:50 AM, David Blanton wrote:

Do I understand correctly that if a layer with explicit animations  
is hidden the animation is still running?



Yes, animations always run, regardless of the hidden state of a layer  
(hidden is just another render attribute).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Design Question

2009-02-12 Thread David Blanton

So besides hiding a layer I should also removeAnimationForKey:

Thanks!

On Feb 12, 2009, at 11:16 AM, David Duncan wrote:


On Feb 12, 2009, at 9:50 AM, David Blanton wrote:

Do I understand correctly that if a layer with explicit animations  
is hidden the animation is still running?



Yes, animations always run, regardless of the hidden state of a  
layer (hidden is just another render attribute).

--
David Duncan
Apple DTS Animation and Printing





David Blanton





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving IKImageBrowser Order and Content?

2009-02-12 Thread douglas welton

Two things:

1)  when I typed NSArrayController into the search field on the ADC  
site, I got 209 possible places where you could begin your search for  
info on how to use NSArrayController bindings with  
IKImageBrowserView.  If none of these is sufficient or you are a  
novice to the binding concept, I suggest that you put Cocoa bindings  
into the ADC search field.  This option netted me over 1060 places to  
begin my search for enlightenment.


2) if you are not using a bound array controller, then you must be  
using some sort of datasource object.  The straightforward solution  
would seem to be simply saving the data that your datasource object is  
computing with when the application terminates and re-read said data  
when the application starts.   Is that not an option?  (for example,  
using the image-browser sample code from the ADC site, you might  
simply save the array of objects kept in the variable images)


regards,

douglas

On Feb 12, 2009, at 12:53 PM, Chunk 1978 wrote:


hi douglas,

i am not using an array controller... my current method is copying
images to the pasteboard (they are produced images from within the
app) and writing them to a folder when they are dropped into the image
browser.  i'm assuming it shouldn't be too difficult to incorporate an
array controller into what i have already to handle the arrangements
of the images and hopefully have no problem trying to get the
imagebrowser to read the array when it opens (it appears that the
IKImageBrowser class isn't documented very strongly), but i've never
used an array controller before.  know of any tutorials off the top of
your head?




On Thu, Feb 12, 2009 at 10:52 AM, douglas welton
douglas_wel...@earthlink.net wrote:
I will assume that you are using an array controller to handle  
the backing
data for you IKImageBrowserView.  If so, all you will need to do is  
archive

the array controller's arrangedObjects (or content plus any filter
predicate) and save it to a file - perhaps using NSArray's handy- 
dandy

-writeToFile:atomically: method.

if my assumption is wrong, then you'll need to provide details of  
what you
are actually doing (for data-sourcing) and what you have tried  
before you

asked your question.

regards,

douglas

On Feb 12, 2009, at 10:01 AM, Chunk 1978 wrote:

topic says it all.  i have installed an IKImageBrowser which  
allows me

to drop images and reorder them.  it would be great to be able to
automatically save the dropped images as well as their order so that
the next time the app starts and the image browser loads up  
everything

is still there.

can someone please direct me to where i should be looking to
accomplish this?  any known tutorials maybe?

thanks



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/douglas_welton%40earthlink.net

This email sent to douglas_wel...@earthlink.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: newbie question on creating .png files

2009-02-12 Thread David Duncan

On Feb 12, 2009, at 8:28 AM, Felix Franz wrote:

You can create a new NSBitmapImageRep using the TIFFRepresentation  
and use representationUsingType:properties:

to get the PNG-data:

NSData* TIFFData = [img TIFFRepresentation];
	NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep  
imageRepWithData:TIFFData];
	NSData* PNGData = [bitmapImageRep  
representationUsingType:NSPNGFileType properties:nil];

[PNGData writeToFile: @JAN01.png atomically: YES];



While this might be fine for a one-off application where performance  
and memory usage doesn't matter, this is really not the best way to  
convert an NSImage into a PNG. In fact, imageRepWithData: should work  
with any file type that is supported by ImageIO, which natively  
includes PNG, so you could pass in the original file data rather than  
going through NSImage.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Proper NSOperation isCancelled handling

2009-02-12 Thread Alex Curylo
So I'm a bit confused about how my NSOperation subclass should  
implement the cancel method. The documentation says that isCancelled  
is a KVO-compliant property. So I figured that calling [super cancel]  
ought to take care of that. But it doesn't. Doesn't appear to do  
anything, actually, whether I call it or not [self isCancelled] still  
returns the expected value in my -start method, but no apparent  
isCancelled KVO notification is generated. So I decided to implement  
my cancel method as


- (void)cancel
{
   // if we have started the operation, cancel it
   if (self.downloadConnection)
  [self.downloadConnection cancel];

   // this generates isExecuting and isFinished notifications as needed
   [self sendKVONotifications:nil];

   // ok ... what should we do about the isCancelled property?
   [self willChangeValueForKey:@isCancelled];
   [super cancel];
   [self didChangeValueForKey:@isCancelled];
}

... which just doesn't seem quite right. What's the correct thing to do?

--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

I just can't accept that 24 reserves, 3 hospitalizations and
 one fatality are in any way acceptable for what should be the
 premier event on the paragliding calendar. -- Mark Hayman



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparent Image

2009-02-12 Thread Benjamin Dobson


On 12 Feb 2009, at 04:37:35, Michael Ash wrote:


On Wed, Feb 11, 2009 at 3:41 PM, Christian Graus
christian.gr...@gmail.com wrote:

Please file a bug and request this functionality.
OK - that would not have occurred to me at all.  That works in the  
Mac world
? Awesome !! I've found plenty of Microsoft bugs, and I was even an  
MVP at
the time, they always ignored me, or told me they were features  
( and I

found some MAJOR bugs in WPF ).  I assume if I go to the Apple Dev
Connection and log in, I'll be able to find a place to log bugs ?


Hah, Apple do something about filed bugs, right. Looking at the list
of bugs I've filed, the most common state is Open. The next most
common state is Duplicate. And don't think that Duplicate means
your bug gets merged into the original and now you get told about
what's happening with the original bug. No, Duplicate is a black
hole of information. Once your bug is marked Duplicate, you lose,
game over, no more information will be arriving, ever.

Filing bugs can be worthwhile. Perhaps 5% of the time it actually gets
results. But be prepared for very little reward.

Mike


Apple have asked for more information on about half of my bugs, but  
most of them do remain unfixed.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Binding to custom NSCell

2009-02-12 Thread Ken Tozier
24 hours later, still completely stumped on this one. The sticking  
point seems to be that Apple's NSTextFieldCell is doing something that  
is not clearly defined in the Key-Value Observing/Key-Value coding  
documentation to allow the following to work


[column bind: @value toObject: arrayController withKeyPath:  
@arrangedObjects.name options: nil];


I suspect that all I'm missing is some required accessor, but nowhere  
in the documentation does Apple offer a step by step example on how to  
write a bindable custom NSCell subclass. What methods are absolutely  
required? What methods are optional?


Here's my custom cell code. Where am I going wrong?

Thanks for any help

@interface PMXDocumentCell : NSCell
{
NSButtonCell*addButton;

NSImage *backImage,
*backSelectedImage,
*addButtonImage,
*addButtonSelectedImage,
*currentBackImage;

NSString*documentName;

NSDictionary*textAttributes;
}

+ (id) documentCell;
- (void) initImages;
- (void) initSubCells;

- (NSString *) documentName;
- (void) setDocumentName:(NSString *) inName;

- (id) objectValue;
- (void) setObjectValue:(id) inObject;


@end

#define ADD_BUTTON_SIZE 17

@implementation PMXDocumentCell

+ (id) documentCell
{
return [[[PMXDocumentCell alloc]
init]
autorelease];
}

- (id) init
{
self = [super init];
if (self)
{
[self initImages];
[self initSubCells];

currentBackImage= backImage;
textAttributes  = [[NSDictionary alloc] 
initWithObjectsAndKeys:

[NSColor blackColor], NSForegroundColorAttributeName,
[NSFont 
systemFontOfSize:13], NSFontAttributeName,
nil];   
}

return self;
}

- (void) initImages
{
NSBundle*bundle = [NSBundle 
bundleForClass: [self class]];
NSString*path;

path= [bundle pathForResource: @add_button 
ofType: @png];
addButtonImage  = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @add_button_white ofType:  
@png];
	addButtonSelectedImage	= [[NSImage alloc] initWithContentsOfFile:  
path];


path= [bundle pathForResource: @toolbar_25 
ofType: @png];
backImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @toolbar_25_focus ofType:  
@png];

backSelectedImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

// set resizing
[addButtonImage setScalesWhenResized: YES];
[addButtonSelectedImage setScalesWhenResized: YES];
[backImage setScalesWhenResized: YES];
[backSelectedImage setScalesWhenResized: YES];

// size button images
[addButtonImage setSize: NSMakeSize(ADD_BUTTON_SIZE, ADD_BUTTON_SIZE)];
	[addButtonSelectedImage setSize: NSMakeSize(ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE)];

}

- (void) initSubCells
{
addButton   = [[NSButtonCell alloc] init];
[addButton setBordered: NO];
[addButton setButtonType: NSMomentaryChangeButton];
[addButton setImage: addButtonImage];
[addButton setAlternateImage: addButtonSelectedImage];
}

- (void) drawWithFrame:(NSRect) inCellFrame
inView:(NSView *) inControlView
{
	NSRect		buttonFrame		= NSMakeRect(inCellFrame.size.width -  
ADD_BUTTON_SIZE - 6, inCellFrame.origin.y, ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE),
nameFrame		= NSMakeRect(6, inCellFrame.origin.y,  
inCellFrame.size.width - ADD_BUTTON_SIZE - 12 , ADD_BUTTON_SIZE);


	NSPoint		textPoint		= NSMakePoint(inCellFrame.origin.x + 1,  
inCellFrame.origin.y);


	currentBackImage		= [self isHighlighted] ? backSelectedImage :  
backImage ;


[currentBackImage drawAtPoint: inCellFrame.origin
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];

[addButton drawWithFrame: buttonFrame
inView: inControlView];

[documentName drawInRect: nameFrame
   

Re: Transparent Image

2009-02-12 Thread Corbin Dunn


On Feb 11, 2009, at 8:37 PM, Michael Ash wrote:


On Wed, Feb 11, 2009 at 3:41 PM, Christian Graus
christian.gr...@gmail.com wrote:

Please file a bug and request this functionality.
OK - that would not have occurred to me at all.  That works in the  
Mac world
? Awesome !! I've found plenty of Microsoft bugs, and I was even an  
MVP at
the time, they always ignored me, or told me they were features  
( and I

found some MAJOR bugs in WPF ).  I assume if I go to the Apple Dev
Connection and log in, I'll be able to find a place to log bugs ?




http://bugreporter.apple.com


Hah, Apple do something about filed bugs, right.
Looking at the list
of bugs I've filed, the most common state is Open. The next most
common state is Duplicate. And don't think that Duplicate means
your bug gets merged into the original and now you get told about
what's happening with the original bug. No, Duplicate is a black
hole of information. Once your bug is marked Duplicate, you lose,
game over, no more information will be arriving, ever.

Filing bugs can be worthwhile. Perhaps 5% of the time it actually gets
results. But be prepared for very little reward.



For what it's worth, filing bugs is *very* worthwhile. It lets Apple  
know what issues are important to developers and what problems they  
are encountering. Logging duplicates is also fine, as it gives us an  
idea of what problems are constantly being reported. The 'original'  
bug has references to the other bugs, and we use that when diagnosing  
the problem; it helps us *greatly* to have that information. Please do  
not disregard it as a fruitless effort.


If you encounter a problem that you think is a bug, please go ahead  
and log a bug, and include the radar number when you post to this  
list. People who have radar access may want to take a look at the  
issue you are talking about in your post.


thanks,
corbin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Binding to custom NSCell

2009-02-12 Thread Corbin Dunn


On Feb 12, 2009, at 1:18 PM, Ken Tozier wrote:

24 hours later, still completely stumped on this one. The sticking  
point seems to be that Apple's NSTextFieldCell is doing something  
that is not clearly defined in the Key-Value Observing/Key-Value  
coding documentation to allow the following to work


Your best bet is to probably just subclass NSTextFieldCell -- which is  
probably correct for your cell, since you want to draw some text and  
other sub cells. Modify the rect that you want the text to draw in,  
and just call [super] to do the real drawing work.




[column bind: @value toObject: arrayController withKeyPath: @arrangedObjects.name 
 options: nil];


I suspect that all I'm missing is some required accessor, but  
nowhere in the documentation does Apple offer a step by step example  
on how to write a bindable custom NSCell subclass. What methods are  
absolutely required? What methods are optional?


Please do log a bug requesting our documentation be clarified for how  
to do this, and also log a bug saying that you can't bind the value  
parameter of a plain NSCell. If you can, also enclose your test  
project/code.


thank you!

corbin



Here's my custom cell code. Where am I going wrong?

Thanks for any help

@interface PMXDocumentCell : NSCell
{
NSButtonCell*addButton;

NSImage *backImage,
*backSelectedImage,
*addButtonImage,
*addButtonSelectedImage,
*currentBackImage;

NSString*documentName;

NSDictionary*textAttributes;
}

+ (id) documentCell;
- (void) initImages;
- (void) initSubCells;

- (NSString *) documentName;
- (void) setDocumentName:(NSString *) inName;

- (id) objectValue;
- (void) setObjectValue:(id) inObject;


@end

#define ADD_BUTTON_SIZE 17

@implementation PMXDocumentCell

+ (id) documentCell
{
return [[[PMXDocumentCell alloc]
init]
autorelease];
}

- (id) init
{
self = [super init];
if (self)
{
[self initImages];
[self initSubCells];

currentBackImage= backImage;
textAttributes  = [[NSDictionary alloc] 
initWithObjectsAndKeys:

[NSColor blackColor], NSForegroundColorAttributeName,
[NSFont 
systemFontOfSize:13], NSFontAttributeName,
nil];   
}

return self;
}

- (void) initImages
{
NSBundle*bundle = [NSBundle 
bundleForClass: [self class]];
NSString*path;

path= [bundle pathForResource: @add_button 
ofType: @png];
addButtonImage  = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @add_button_white ofType:  
@png];
	addButtonSelectedImage	= [[NSImage alloc] initWithContentsOfFile:  
path];


path= [bundle pathForResource: @toolbar_25 
ofType: @png];
backImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @toolbar_25_focus ofType:  
@png];

backSelectedImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

// set resizing
[addButtonImage setScalesWhenResized: YES];
[addButtonSelectedImage setScalesWhenResized: YES];
[backImage setScalesWhenResized: YES];
[backSelectedImage setScalesWhenResized: YES];

// size button images
	[addButtonImage setSize: NSMakeSize(ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE)];
	[addButtonSelectedImage setSize: NSMakeSize(ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE)];

}

- (void) initSubCells
{
addButton   = [[NSButtonCell alloc] init];
[addButton setBordered: NO];
[addButton setButtonType: NSMomentaryChangeButton];
[addButton setImage: addButtonImage];
[addButton setAlternateImage: addButtonSelectedImage];
}

- (void) drawWithFrame:(NSRect) inCellFrame
inView:(NSView *) inControlView
{
	NSRect		buttonFrame		= NSMakeRect(inCellFrame.size.width -  
ADD_BUTTON_SIZE - 6, inCellFrame.origin.y, ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE),
nameFrame		= NSMakeRect(6, inCellFrame.origin.y,  
inCellFrame.size.width - ADD_BUTTON_SIZE - 12 , ADD_BUTTON_SIZE);


Re: Communication between objects

2009-02-12 Thread Jason Wiggins
Thanks all to who replied for taking the time to sort me out. Your  
replies have and will be helpful to my understanding of what goes on.
I'll let it sink into my head a bit more in the morning (It's 3:16am  
here in Sydney).


Kind regards to all,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Converting a CMYK NSImage to RGB

2009-02-12 Thread Ron Aldrich

Folks,

I'm having an issue where CMYK images aren't being recognized by my  
quartz compositions, so I need to convert them to RGB for display.


I've written a routine to do it, but its causing problems.

  NSImageRep* theImageRep = [inputImage bestRepresentationForDevice:  
[NSDictionary dictionaryWithObject: NSDeviceRGBColorSpace
   forKey 
: NSDeviceColorSpaceName]];


  NSString* theColorSpace = [theImageRep colorSpaceName];

  if ([theColorSpace isEqualToString: NSDeviceCMYKColorSpace])
  {
NSBitmapImageRep* theRGBImageRep = [[[NSBitmapImageRep alloc]  
initWithBitmapDataPlanes: NULL
pixelsWide 
: [theImageRep pixelsWide]
pixelsHigh 
: [theImageRep pixelsHigh]
 bitsPerSample 
: 8
   samplesPerPixel 
: 4
  hasAlpha 
: YES
  isPlanar 
: NO
colorSpaceName 
: NSDeviceRGBColorSpace
   bytesPerRow 
: 0
  bitsPerPixel 
: 0] autorelease];


[inputImage lockFocus];

NSGraphicsContext* theContext = [NSGraphicsContext  
graphicsContextWithBitmapImageRep: theRGBImageRep];

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: theContext];

NSRect theBoundsRect = NSMakeRect(0.0, 0.0, [theRGBImageRep  
pixelsWide], [theRGBImageRep pixelsHigh]);


[[NSColor clearColor] set];
NSRectFill(theBoundsRect);

[theImageRep drawInRect: theBoundsRect];

[NSGraphicsContext restoreGraphicsState];

[inputImage unlockFocus];

ASSIGNOBJECT(rgbImage, [[[NSImage alloc] initWithSize:  
[theImageRep size]] autorelease]);


[rgbImage addRepresentation: theRGBImageRep];
  }
  else
  {
ASSIGNOBJECT(rgbImage, inputImage);
  }

The resulting image is correct, but somewhere along the line, my  
original image (inputImage) is being modified - the CMYK  
representation is being removed, and replaced with a downsampled RGB  
representation.  The goal here was to leave inputImage unmodified, so  
that when it is finally sent to the printer, the CMYK representation  
would be used.


inputImage before creating the RGB version.

NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
NSBitmapImageRep 0xd8201c0 Size={340.08, 340.08}  
ColorSpace=NSDeviceCMYKColorSpace BPS=8 BPP=32 Pixels=1417x1417  
Alpha=NO Planar=NO Format=0

)

inputImage after creating the RGB version.

NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
NSCachedImageRep 0xd824530 Size={340, 340}  
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=340x340 Alpha=NO

)

Clearly, I'm doing something wrong.  I added calls to [inputImage  
lockFocus] and [inputImage unlockFocus] in order to resolve a multi- 
thread problem, but that seems to have caused this problem.


So, what's the best way for me to convert an NSImage of unknown  
pedigree to a simple RGB representation?


Thanks,

Ron Aldrich
Software Architects, Inc.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


CALayer wierdness

2009-02-12 Thread David Blanton

I set up a CALayer

is shows in the iPhone Simulator
does not show in the iPhone

How can that be?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer wierdness

2009-02-12 Thread Brian Christensen

On Feb 12, 2009, at 21:23, David Blanton wrote:


I set up a CALayer

is shows in the iPhone Simulator
does not show in the iPhone

How can that be?


I doubt anyone can answer your question without seeing relevant code  
snippets.


/brian

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Binding to custom NSCell

2009-02-12 Thread Ken Tozier

Hmmm. Making my cell a subclass of NSTextFieldCell solved the problem.

I would dearly love to get a look at the the source for  
NSTextFieldCell to see what it's doing, behind-the-scenes, that makes  
this binding work. In general, it would be a boon to developers if  
Apple would open up the source for these types of core AppKit classes.  
It's not like NSTextFieldCell is some cutting edge class and would be  
a great way for developers to see how to create subclasses the right  
way.


Anyway, thanks for the tip, it works perfectly now. Just wish I knew  
why...


-Ken




On Feb 12, 2009, at 6:18 PM, Corbin Dunn wrote:



On Feb 12, 2009, at 1:18 PM, Ken Tozier wrote:

24 hours later, still completely stumped on this one. The sticking  
point seems to be that Apple's NSTextFieldCell is doing something  
that is not clearly defined in the Key-Value Observing/Key-Value  
coding documentation to allow the following to work


Your best bet is to probably just subclass NSTextFieldCell -- which  
is probably correct for your cell, since you want to draw some text  
and other sub cells. Modify the rect that you want the text to draw  
in, and just call [super] to do the real drawing work.




[column bind: @value toObject: arrayController withKeyPath:  
@arrangedObjects.name options: nil];


I suspect that all I'm missing is some required accessor, but  
nowhere in the documentation does Apple offer a step by step  
example on how to write a bindable custom NSCell subclass. What  
methods are absolutely required? What methods are optional?


Please do log a bug requesting our documentation be clarified for  
how to do this, and also log a bug saying that you can't bind the  
value parameter of a plain NSCell. If you can, also enclose your  
test project/code.


thank you!

corbin



Here's my custom cell code. Where am I going wrong?

Thanks for any help

@interface PMXDocumentCell : NSCell
{
NSButtonCell*addButton;

NSImage *backImage,
*backSelectedImage,
*addButtonImage,
*addButtonSelectedImage,
*currentBackImage;

NSString*documentName;

NSDictionary*textAttributes;
}

+ (id) documentCell;
- (void) initImages;
- (void) initSubCells;

- (NSString *) documentName;
- (void) setDocumentName:(NSString *) inName;

- (id) objectValue;
- (void) setObjectValue:(id) inObject;


@end

#define ADD_BUTTON_SIZE 17

@implementation PMXDocumentCell

+ (id) documentCell
{
return [[[PMXDocumentCell alloc]
init]
autorelease];
}

- (id) init
{
self = [super init];
if (self)
{
[self initImages];
[self initSubCells];

currentBackImage= backImage;
textAttributes  = [[NSDictionary alloc] 
initWithObjectsAndKeys:

[NSColor blackColor], NSForegroundColorAttributeName,
[NSFont 
systemFontOfSize:13], NSFontAttributeName,
nil];   
}

return self;
}

- (void) initImages
{
NSBundle*bundle = [NSBundle 
bundleForClass: [self class]];
NSString*path;

path= [bundle pathForResource: @add_button 
ofType: @png];
addButtonImage  = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @add_button_white ofType:  
@png];
	addButtonSelectedImage	= [[NSImage alloc] initWithContentsOfFile:  
path];


path= [bundle pathForResource: @toolbar_25 
ofType: @png];
backImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @toolbar_25_focus ofType:  
@png];

backSelectedImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

// set resizing
[addButtonImage setScalesWhenResized: YES];
[addButtonSelectedImage setScalesWhenResized: YES];
[backImage setScalesWhenResized: YES];
[backSelectedImage setScalesWhenResized: YES];

// size button images
	[addButtonImage setSize: NSMakeSize(ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE)];
	[addButtonSelectedImage setSize: NSMakeSize(ADD_BUTTON_SIZE,  
ADD_BUTTON_SIZE)];

}

- (void) initSubCells
{

Re: Binding to custom NSCell

2009-02-12 Thread Ken Tozier
Just for kicks, I tried stepping back a level and making my cell a  
subclass of NSActionCell and that works too. So it seems that whatever  
magic Apple is performing happens inside NSActionCell.



On Feb 12, 2009, at 11:09 PM, Ken Tozier wrote:


Hmmm. Making my cell a subclass of NSTextFieldCell solved the problem.

I would dearly love to get a look at the the source for  
NSTextFieldCell to see what it's doing, behind-the-scenes, that  
makes this binding work. In general, it would be a boon to  
developers if Apple would open up the source for these types of core  
AppKit classes. It's not like NSTextFieldCell is some cutting edge  
class and would be a great way for developers to see how to create  
subclasses the right way.


Anyway, thanks for the tip, it works perfectly now. Just wish I knew  
why...


-Ken




On Feb 12, 2009, at 6:18 PM, Corbin Dunn wrote:



On Feb 12, 2009, at 1:18 PM, Ken Tozier wrote:

24 hours later, still completely stumped on this one. The sticking  
point seems to be that Apple's NSTextFieldCell is doing something  
that is not clearly defined in the Key-Value Observing/Key-Value  
coding documentation to allow the following to work


Your best bet is to probably just subclass NSTextFieldCell -- which  
is probably correct for your cell, since you want to draw some text  
and other sub cells. Modify the rect that you want the text to draw  
in, and just call [super] to do the real drawing work.




[column bind: @value toObject: arrayController withKeyPath:  
@arrangedObjects.name options: nil];


I suspect that all I'm missing is some required accessor, but  
nowhere in the documentation does Apple offer a step by step  
example on how to write a bindable custom NSCell subclass. What  
methods are absolutely required? What methods are optional?


Please do log a bug requesting our documentation be clarified for  
how to do this, and also log a bug saying that you can't bind the  
value parameter of a plain NSCell. If you can, also enclose your  
test project/code.


thank you!

corbin



Here's my custom cell code. Where am I going wrong?

Thanks for any help

@interface PMXDocumentCell : NSCell
{
NSButtonCell*addButton;

NSImage *backImage,
*backSelectedImage,
*addButtonImage,
*addButtonSelectedImage,
*currentBackImage;

NSString*documentName;

NSDictionary*textAttributes;
}

+ (id) documentCell;
- (void) initImages;
- (void) initSubCells;

- (NSString *) documentName;
- (void) setDocumentName:(NSString *) inName;

- (id) objectValue;
- (void) setObjectValue:(id) inObject;


@end

#define ADD_BUTTON_SIZE 17

@implementation PMXDocumentCell

+ (id) documentCell
{
return [[[PMXDocumentCell alloc]
init]
autorelease];
}

- (id) init
{
self = [super init];
if (self)
{
[self initImages];
[self initSubCells];

currentBackImage= backImage;
textAttributes  = [[NSDictionary alloc] 
initWithObjectsAndKeys:

[NSColor blackColor], NSForegroundColorAttributeName,
[NSFont 
systemFontOfSize:13], NSFontAttributeName,
nil];   
}

return self;
}

- (void) initImages
{
NSBundle*bundle = [NSBundle 
bundleForClass: [self class]];
NSString*path;

path= [bundle pathForResource: @add_button 
ofType: @png];
addButtonImage  = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @add_button_white ofType:  
@png];
	addButtonSelectedImage	= [[NSImage alloc] initWithContentsOfFile:  
path];


path= [bundle pathForResource: @toolbar_25 
ofType: @png];
backImage   = [[NSImage alloc] 
initWithContentsOfFile: path];

	path	= [bundle pathForResource: @toolbar_25_focus ofType:  
@png];
	backSelectedImage		= [[NSImage alloc] initWithContentsOfFile:  
path];


// set resizing
[addButtonImage setScalesWhenResized: YES];
[addButtonSelectedImage setScalesWhenResized: YES];
[backImage setScalesWhenResized: YES];
[backSelectedImage setScalesWhenResized: YES];

   

Re: Window Max Zoom Size

2009-02-12 Thread John C. Randolph


On Feb 12, 2009, at 9:42 AM, Anthony Smith wrote:

What is the best way to set the max zoom size for NSWindow? I was  
able to implement a solution by overriding zoom but that feels  
rather invasive so I'm assuming there's probably a better way.


Check the docs for -windowWillResize:toSize:.

-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: memory leak analyzer tools

2009-02-12 Thread John C. Randolph


On Feb 10, 2009, at 11:32 PM, Valentin Dan wrote:


Hi,



What tools are there to analyze memory leaks in programs ? Is there
something that would tell the exact location of the leak (the object
that's not being released) ?


Try /Developer/Applications/Instruments.  It has a template  
specifically for finding leaks.


-jcr

The problem with trying to child-proof the world, is that it makes  
people neglect the far more important task of world-proofing the  
child. -- Hugh Daniel


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparent Image

2009-02-12 Thread Michael Ash
On Thu, Feb 12, 2009 at 5:48 PM, Corbin Dunn corb...@apple.com wrote:
 For what it's worth, filing bugs is *very* worthwhile. It lets Apple know
 what issues are important to developers and what problems they are
 encountering. Logging duplicates is also fine, as it gives us an idea of
 what problems are constantly being reported. The 'original' bug has
 references to the other bugs, and we use that when diagnosing the problem;
 it helps us *greatly* to have that information. Please do not disregard it
 as a fruitless effort.

Right, it's useful (or so we are told by people who would know, like
yourself), it just doesn't generate directly visible results in the
bug reporter most of the time. So the instant gratification aspect of
the whole endeavor is unfortunately missing, but it's still a
worthwhile activity.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Binding to custom NSCell [Solved]

2009-02-12 Thread Ken Tozier
After looking at NSActionCell, I noticed the setControlView method  
and this seems to be the missing link. NSActionCell sets it's control  
view while NSCell does not. When I manually set the control view for  
my custom cell to the table that contains it, viola! It works.


So, for any other NSCell subclassers out there, the progression of  
steps is


MyCell  *cell   = [[[MYCell alloc] init] autorelease];
NSTableColumn   *column = [[[NSTableColumn alloc] init] autorelease];
NSTableView *table  = [[NSTableView alloc] initWithFrame: aFrame];

[cell setControlView: table];
[column setDataCell: cell];
[table addTableColumn: column];

[column bind: @value toObject: arrayController withKeyPath:  
@arrangedObjects.key options: nil];


Hope this saves someone else a lost couple of days figuring this out...



On Feb 12, 2009, at 11:32 PM, Ken Tozier wrote:

Just for kicks, I tried stepping back a level and making my cell a  
subclass of NSActionCell and that works too. So it seems that  
whatever magic Apple is performing happens inside NSActionCell.



On Feb 12, 2009, at 11:09 PM, Ken Tozier wrote:

Hmmm. Making my cell a subclass of NSTextFieldCell solved the  
problem.


I would dearly love to get a look at the the source for  
NSTextFieldCell to see what it's doing, behind-the-scenes, that  
makes this binding work. In general, it would be a boon to  
developers if Apple would open up the source for these types of  
core AppKit classes. It's not like NSTextFieldCell is some cutting  
edge class and would be a great way for developers to see how to  
create subclasses the right way.


Anyway, thanks for the tip, it works perfectly now. Just wish I  
knew why...


-Ken




On Feb 12, 2009, at 6:18 PM, Corbin Dunn wrote:



On Feb 12, 2009, at 1:18 PM, Ken Tozier wrote:

24 hours later, still completely stumped on this one. The  
sticking point seems to be that Apple's NSTextFieldCell is doing  
something that is not clearly defined in the Key-Value Observing/ 
Key-Value coding documentation to allow the following to work


Your best bet is to probably just subclass NSTextFieldCell --  
which is probably correct for your cell, since you want to draw  
some text and other sub cells. Modify the rect that you want the  
text to draw in, and just call [super] to do the real drawing work.




[column bind: @value toObject: arrayController withKeyPath:  
@arrangedObjects.name options: nil];


I suspect that all I'm missing is some required accessor, but  
nowhere in the documentation does Apple offer a step by step  
example on how to write a bindable custom NSCell subclass. What  
methods are absolutely required? What methods are optional?


Please do log a bug requesting our documentation be clarified for  
how to do this, and also log a bug saying that you can't bind the  
value parameter of a plain NSCell. If you can, also enclose your  
test project/code.


thank you!

corbin



Here's my custom cell code. Where am I going wrong?

Thanks for any help

@interface PMXDocumentCell : NSCell
{
NSButtonCell*addButton;

NSImage *backImage,
*backSelectedImage,
*addButtonImage,
*addButtonSelectedImage,
*currentBackImage;

NSString*documentName;

NSDictionary*textAttributes;
}

+ (id) documentCell;
- (void) initImages;
- (void) initSubCells;

- (NSString *) documentName;
- (void) setDocumentName:(NSString *) inName;

- (id) objectValue;
- (void) setObjectValue:(id) inObject;


@end

#define ADD_BUTTON_SIZE 17

@implementation PMXDocumentCell

+ (id) documentCell
{
return [[[PMXDocumentCell alloc]
init]
autorelease];
}

- (id) init
{
self = [super init];
if (self)
{
[self initImages];
[self initSubCells];

currentBackImage= backImage;
textAttributes  = [[NSDictionary alloc] 
initWithObjectsAndKeys:

[NSColor blackColor], NSForegroundColorAttributeName,
[NSFont 
systemFontOfSize:13], NSFontAttributeName,
nil];   
}

return self;
}

- (void) initImages
{
NSBundle*bundle = [NSBundle 
bundleForClass: [self class]];
NSString*path;

path= [bundle 

Chnaging icon of running app

2009-02-12 Thread Erg Consultant
Is it possible to change the icon of a running app after it has already been 
started? My app has no .icns file not will it - but I want to set it to some 
other bundle's icon after my app has already launched. I've seen discussions in 
the archives about how to change the Dock icon, but not the one of the running 
app (I am thinking for Command-Tab).

Thanks,

Erg



  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Chnaging icon of running app

2009-02-12 Thread Rick Langschultz

Adium has a great example of what you're looking to do

Sent from my iPhone

On Feb 12, 2009, at 10:57 PM, Erg Consultant  
erg_consult...@yahoo.com wrote:


Is it possible to change the icon of a running app after it has  
already been started? My app has no .icns file not will it - but I  
want to set it to some other bundle's icon after my app has already  
launched. I've seen discussions in the archives about how to change  
the Dock icon, but not the one of the running app (I am thinking for  
Command-Tab).


Thanks,

Erg




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ricklangschultz%40me.com

This email sent to ricklangschu...@me.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: memory leak analyzer tools

2009-02-12 Thread Alex Kac

CLANG worked quite well for us.

On Feb 12, 2009, at 10:45 PM, John C. Randolph wrote:



On Feb 10, 2009, at 11:32 PM, Valentin Dan wrote:


Hi,



What tools are there to analyze memory leaks in programs ? Is there
something that would tell the exact location of the leak (the object
that's not being released) ?


Try /Developer/Applications/Instruments.  It has a template  
specifically for finding leaks.


-jcr

The problem with trying to child-proof the world, is that it makes  
people neglect the far more important task of world-proofing the  
child. -- Hugh Daniel


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net

This email sent to a...@webis.net


Alex Kac - President and Founder
Web Information Solutions, Inc.

In the Country of the Blind, the one-eyed man is king.
--Desiderius Erasmus





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer wierdness

2009-02-12 Thread David Blanton


The Simulator is not case sensitive when it comes to file names.

The file name in the project is Level 1 top.png  Capital L

This code yields a nil provider in the iPhone, ergo no layer contents

imageFileName = [[[NSBundle mainBundle] resourcePath]  
stringByAppendingPathComponent:@level 1 top.png]; lower case l

provider = CGDataProviderCreateWithFilename([imageFileName UTF8String]);
_topLayer.contents = (id)CGImageCreateWithPNGDataProvider(provider,  
NULL, true, kCGRenderingIntentDefault);


Whereas in the iPhone Simulator provider is not nil;



On Feb 12, 2009, at 8:42 PM, Brian Christensen wrote:


On Feb 12, 2009, at 21:23, David Blanton wrote:


I set up a CALayer

is shows in the iPhone Simulator
does not show in the iPhone

How can that be?


I doubt anyone can answer your question without seeing relevant code  
snippets.


/brian





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[SOLVED] Re: NSTextView and keyDown: in the responder chain

2009-02-12 Thread Tom


On 13/02/2009, at 1:58 AM, Ross Carter wrote:



On Feb 11, 2009, at 10:21 PM, Tom wrote:

However, I've found that when an NSTextView receives a keyDown  
event that doesn't handle, it doesn't bother to send the event down  
the responder chain and just calls NSBeep().


I expect that there isn't a keyDown event that NSTextView doesn't  
handle. It sends them all to -interpretKeyEvents. The events go  
through the system input manager and get back to the NSTextView in  
the form of -insertText: or -doCommandBySelector:. It is  
doCommandBySelector: that is firing the beep. You can set a  
breakpoint on NSBeep to see the call stack.


Ross


You were spot on, Ross. Thanks for the help. Instead of keyDown: being  
passed down the responder chain it is doCommandBySelector:.


The solution I've used is to override doCommandBySelector: and convert  
it back into a keyDown: call in the last responder in the chain.  
Here's the code:


- (void)doCommandBySelector:(SEL)aSelector
{
NSEvent* e = [NSApp currentEvent];
if([e type] == NSKeyDown){
[self keyDown:e];
} else {
[super doCommandBySelector:aSelector];
}
}

Kind regards,

Tom





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Matching String With ObjectForKey?

2009-02-12 Thread Chunk 1978
how can i equate an NSString to an ObjectForKey (which is also an
NSString)?  kinda driving me crazy.

-=-=-=-
NSString *desktopPlist =
[@~/Library/Preferences/com.apple.desktop.plist
stringByExpandingTildeInPath];
NSString *originalDesktopBackgroundImage = NSDictionary
dictionaryWithContentsOfFile: desktopPlist]
objectForKey:@Background] objectForKey:@default]
objectForKey:@ImageFilePath];
NSLog(originalDesktopBackgroundImage);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:originalDesktopBackgroundImage
forKey:@OriginalBackground];

NSString *pathy = @/Library/Desktop Pictures/Nature/Aurora.jpg;
if ([defaults objectForKey:@OriginalBackground] == pathy)
{
NSLog(@Same);
}
else
{
NSLog(@Not Same);
}
-=-=-=-

so i'm getting the path of the current desktop background and setting
it to the defaults.  the current desktop image in the Aurora image.

my IF statement isn't working as i am expecting. the output reads:

-=-=-=-
2009-02-13 01:44:51.911 Test[33576:10b] /Library/Desktop
Pictures/Nature/Aurora.jpg
2009-02-13 01:44:51.913 Test[33576:10b] Not Same
-=-=-=-

but they are the same!  aren't they?!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Matching String With ObjectForKey?

2009-02-12 Thread Volker in Lists

Hi,

you compare objects with == but what you really want is  
isEqualToString: since you want to compare the string contents.


Cheers,
Volker
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Matching String With ObjectForKey?

2009-02-12 Thread John C. Randolph


On Feb 12, 2009, at 10:45 PM, Chunk 1978 wrote:


if ([defaults objectForKey:@OriginalBackground] == pathy)

..


but they are the same!  aren't they?!


Nope.  You're comparing two addresses, not the contents of the objects  
at those addresses.


Try:

if ([[defaults objectForKey:@OriginalBackground] isEqualToString:  
pathy])


-jcr
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Matching String With ObjectForKey?

2009-02-12 Thread Chunk 1978
ahh... that old trap again ;)...

thanks guys

On Fri, Feb 13, 2009 at 1:56 AM, John C. Randolph j...@mac.com wrote:

 On Feb 12, 2009, at 10:45 PM, Chunk 1978 wrote:

if ([defaults objectForKey:@OriginalBackground] == pathy)

 ..

 but they are the same!  aren't they?!

 Nope.  You're comparing two addresses, not the contents of the objects at
 those addresses.

 Try:

 if ([[defaults objectForKey:@OriginalBackground] isEqualToString: pathy])

 -jcr

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com