Binding -- or not -- a button created in code

2010-06-21 Thread Jerry Krinock
In a home-made "collection view", each item contains a checkbox, whose value should represent an attribute in the data model. Looking at this from a high level, it seems there are two ways to wire its value 1. The *modern* way is to -bind::: it to the model when it is created, and -unbind:: it

Re: Binding -- or not -- a button created in code

2010-06-21 Thread Kyle Sluder
On Mon, Jun 21, 2010 at 12:14 AM, Jerry Krinock wrote: > In a home-made "collection view", each item contains a checkbox, whose value > should represent an attribute in the data model. So, you are going to have multiple checkbox-style NSButtons (NSCollectionView approach), not just cell-based dr

Re: Getting Computer Name

2010-06-21 Thread Steve Steinitz
Hi John, not to question your own algorithms, but you may also want to consider checking the MAC address (ethernet) I see what you are saying but I want to keep specific hardware out of the equation. I want to be able to swap a new Mac Mini in at any time. The computer name is a convenienc

Re: Getting Computer Name

2010-06-21 Thread Steve Steinitz
Hi Kyle, On 20/6/10, Kyle Sluder wrote: Be aware that as of 10.6, this is an officially unsupported configuration, prone to breaking in point releases as happened in 10.6.2. Yes, we are more careful with Mac OS X updates now. See Ben Trumbull's post here for the nitty-gritty: http://lists.a

Threaded DOM operations

2010-06-21 Thread Matej Bukovinski
Hello everyone, I'm using WebKit to download a bunch of websites. On those sites I need to perform some basic DOM tree operations (e.g., removing some DOM nodes). WebKit makes this very straightforward by using elements such as DOMNodes to represent the document three. The problem is that those

NSAllocateCollectable memory allocation problem

2010-06-21 Thread julius
Hi, I am running XCode 3.2.2 with Garbage Collection required. Something strange is happening with NSAllocateCollectable. I am hoping someone will instantly recognise the symptoms and tell me what I'm doing wrong. Distinct memory allocations using NSAllocateCollectable are allocating the same po

Re: NSAllocateCollectable memory allocation problem

2010-06-21 Thread jonat...@mugginsoft.com
On 21 Jun 2010, at 13:06, julius wrote: > Hi, > I am running XCode 3.2.2 with Garbage Collection required. > Something strange is happening with NSAllocateCollectable. > I am hoping someone will instantly recognise the symptoms and tell me what > I'm doing wrong. > .. > > Note that other vari

Getting notification when NSTextFieldCell end editing in a table view

2010-06-21 Thread Gustavo Pizano
Hello all. I think this has very simple question, yet I hadn't figure it out. I need to change the textColor of the NXTextFieldCell when the user its editing, and when the user finish editing put back the original color. I have this in the NSTableViewDelegate method: - (BOOL)tableView:(NSTabl

Re: Getting notification when NSTextFieldCell end editing in a table view

2010-06-21 Thread Graham Cox
On 21/06/2010, at 11:10 PM, Gustavo Pizano wrote: > I can't assign any delegate to the cell but to its view, so :S Im kinda > lost here... There is only one cell, and only one field editor. The view will tell you when it ends editing (and begins for that matter), so the most appropriate h

Re: Getting notification when NSTextFieldCell end editing in a table view

2010-06-21 Thread Gustavo Pizano
Graham hello. But those methods are delegate methods for NSTextFields no? even if I implemented them they are not called, because the control view its NSTableView, unless im doing something really wrong. :( G. On Jun 21, 2010, at 3:17 PM, Graham Cox wrote: > > On 21/06/2010, at 11:10 PM,

Re: Getting notification when NSTextFieldCell end editing in a table view

2010-06-21 Thread Gustavo Pizano
Sorry, as docs says: The NSControlTextEditingDelegate protocol defines the optional methods implemented by delegates of objects that are subclasses of NSControl. so I guess NSTableView should call this methods .. but it isn't shall I add something else than setting the delegate? G. On Jun 2

Re: Getting notification when NSTextFieldCell end editing in a table view

2010-06-21 Thread Gustavo Pizano
Sorry.. go it, I was missing something. declare my Controller that implements that protocol :S G. On Jun 21, 2010, at 3:17 PM, Graham Cox wrote: > > On 21/06/2010, at 11:10 PM, Gustavo Pizano wrote: > >> I can't assign any delegate to the cell but to its view, so :S Im kinda >> lost he

Re: Threaded DOM operations

2010-06-21 Thread Mike Abdullah
In my experience, editing the DOM is very fast. If you are seeing slowness it's probably from doing huge numbers of these operations at once. So my advice would be to perform a handful of operations at a time, giving the main event loop time to run in between. Mike. On 21 Jun 2010, at 11:50, M

Mousedown for double click event.

2010-06-21 Thread Nikhil Khandelwal
Hi, In my application I have -(void)mouseDown: (NSEvent*)theEvent method implemented. When I double click on my view it calls the mouseDown event for two times with 1 and 2 click count respectively. So it gives a single click and a double click instead of, I just double clicked on my view. I wa

Problem controlling a NSScrollView

2010-06-21 Thread Anders Sommer Lassen
Hi, I have problem controlling a NSScrollView. As usual, a custom view is embedded in the scroll view. >From the user interface, subviews can be added or deleted to the custom view, >making it larger or smaller - in height only. When a subview is added or deleted, the scroll view then decides

Memory management on returning nil in init

2010-06-21 Thread Eiko Bleicher
One of my initializers can fail and thus it should return nil. Consider the following example: -(id) initWithBool:(BOOL)ok { if (self = [super init]) { if (!ok) { return nil; // Point of interest } } return self; } Does this code leak? I am inclined to think I ne

Re: NSAllocateCollectable memory allocation problem

2010-06-21 Thread Michael Babin
On Jun 21, 2010, at 7:06 AM, julius wrote: > Inside MyControl define three pointers of type CGFloat , e.g CGFloat * mem1, > mem2, mem3; > and declare them as @property GFloat * mem1; etc with corresponding > @synthesize statements. > Declare a MyControl method that allocates memory to mem1 etc

Re: Memory management on returning nil in init

2010-06-21 Thread vincent habchi
Le 21 juin 2010 à 16:43, Eiko Bleicher a écrit : > One of my initializers can fail and thus it should return nil. Consider the > following example: > > -(id) initWithBool:(BOOL)ok > { > if (self = [super init]) > { > if (!ok) { > return nil; // Point of interest > } > }

Re: Memory management on returning nil in init

2010-06-21 Thread Ken Thomases
On Jun 21, 2010, at 9:43 AM, Eiko Bleicher wrote: > One of my initializers can fail and thus it should return nil. Consider the > following example: > Does this code leak? I am inclined to think I need to call [self release] > before returning nil Yes, you need to release self. This is docume

Re: Memory management on returning nil in init

2010-06-21 Thread Bryan Henry
Yes, you would want to call [self release]; before returning nil in your initializer. That's the common pattern. Otherwise you do leak the allocated (but improperly initialized) object. - Bryan Sent from my iPhone On Jun 21, 2010, at 10:43 AM, Eiko Bleicher wrote: > One of my initializers ca

Re: Memory management on returning nil in init

2010-06-21 Thread Markus Hanauska
On Monday, 2010-06-21, at 16:43, Eiko Bleicher wrote: > -(id) initWithBool:(BOOL)ok > { > if (self = [super init]) > { > if (!ok) { > return nil; // Point of interest > } > } > return self; > } > > Does this code leak? According to my understanding of Cocoa, it does le

Re: Memory management on returning nil in init

2010-06-21 Thread Eiko Bleicher
Thank you all, this gives me confidence in my code. I was just hesistant because I didn't call alloc in the initializer - but that's probably one of the reasons why you always use alloc/init together when calling. :-) Thanks to everyone who responded. Eiko Am 21.06.2010 um 16:51 schrieb Marku

Re: NSAllocateCollectable memory allocation problem

2010-06-21 Thread julius
On 21 Jun 2010, at 15:47, Michael Babin wrote: > > On Jun 21, 2010, at 7:06 AM, julius wrote: > >> Inside MyControl define three pointers of type CGFloat , e.g CGFloat * >> mem1, mem2, mem3; >> and declare them as @property GFloat * mem1; etc with corresponding >> @synthesize statements. >> D

Re: Mousedown for double click event.

2010-06-21 Thread Graham Cox
On 22/06/2010, at 12:34 AM, Nikhil Khandelwal wrote: > In my application I have -(void)mouseDown: (NSEvent*)theEvent method > implemented. When I double click on my view it calls the mouseDown event for > two times with 1 and 2 click count respectively. So it gives a single click > and a doubl

Re: AppleScript in a Co

2010-06-21 Thread Matt Neuburg
On Mon, 21 Jun 2010 13:53:31 +0800 (HKT), Angelo Chen said: >Hi, >I need to create an AppleScript and run it inside the app to activate another program, the applescript should call 'add' function the the other program with different file names, any idea how to achieve this? Thanks, I believe your

Re: Getting Computer Name

2010-06-21 Thread Kyle Sluder
On Jun 21, 2010, at 1:33 AM, Steve Steinitz wrote: > Hi Kyle, > > On 20/6/10, Kyle Sluder wrote: > >> Be aware that as of 10.6, this is an officially unsupported >> configuration, prone to breaking in point releases as happened in >> 10.6.2. > > Yes, we are more careful with Mac OS X updates n

Re: AppleScript in a Co

2010-06-21 Thread John Joyce
On Jun 21, 2010, at 10:16 AM, Matt Neuburg wrote: > On Mon, 21 Jun 2010 13:53:31 +0800 (HKT), Angelo Chen > said: >> Hi, >> I need to create an AppleScript and run it inside the app to activate another > program, the applescript should call 'add' function the the other program with > different f

objc_msgSend

2010-06-21 Thread koko
I understand that a crash in objc_msgSend is related calling a method on a released / nil object. The linked Crash Report , from a customer, seems strange to me as it shows this being called 512 times and I can see no reference to my code as to what I was doing to create this problem. App

Re: objc_msgSend

2010-06-21 Thread koko
the crash report is here http://highrolls.net/objc_msgSend On Jun 21, 2010, at 9:27 AM, k...@highrolls.net wrote: I understand that a crash in objc_msgSend is related calling a method on a released / nil object. The linked Crash Report , from a customer, seems strange to me as it shows t

Re: objc_msgSend

2010-06-21 Thread Ken Thomases
First, see the documentation for +[NSObject initialize] (a class method) to learn what that method is and does. Second, the crash report indicates infinite recursion and eventual exhaustion of the stack or heap. Third, when something like this only happens to one customer out of hundreds, I of

Re: Memory management on returning nil in init

2010-06-21 Thread Phil Hystad
Does this mean we don't get to find out what the ok variable is all about? If the ok variable has meaning then the code would be much better written as something like: -(id) initWithBool:(BOOL)ok { if ( !ok ) return nil; ...rest of code... } On Jun 21, 2010, at 7:55 AM, Eiko Bleicher

Re: Memory management on returning nil in init

2010-06-21 Thread Eiko Bleicher
That would leak. Shouldn't this instance be released? Alloc already did its job if we get into init. On the other hand, we shouldn't call release, because super wasn't initialized. So as of my (maybe limited) understanding by now, doing the code after [super init] is the way to go. Am 21.06.20

Re: Problem controlling a NSScrollView

2010-06-21 Thread Jerry Krinock
On 2010 Jun 21, at 07:42, Anders Sommer Lassen wrote: > How can I get the custom view to known about the change in size due to the > newly added scrollbar? The scroll view's content view should have its autoresizesSubviews set to YES. Thus, when this content view is resized to accommodate the

Re: Memory management on returning nil in init

2010-06-21 Thread Phil Hystad
I do not understand your argument -- apparently the ok variable is input to this initWithBool method and this method DOES NOT alter the ok variable in any way. Therefore, when you test the ok variable, you are testing a condition that is totally independent of anything that initWithBool might d

Re: Memory management on returning nil in init

2010-06-21 Thread Scott Anguish
aside from what others have mentioned, one other comment the new suggested format for calling super is self = [super init]; if (self) { etc... On Jun 21, 2010, at 10:43 AM, Eiko Bleicher wrote: > One of my initializers can fail and thus it should return nil. Consider the > following example:

Re: Memory management on returning nil in init

2010-06-21 Thread Eiko Bleicher
If the boolean value is distracting, here it is without: -(id) init { if (self = [super init]) { BOOL noValidObject = doSomeMagicConditionalChecking(); if (noValidObject) { [self release]; [return nil]; } // Normal initialization here } r

NSView background color

2010-06-21 Thread Richard Langly
I have an NSView in a *.nib file. I'm trying to change the background color in it to match the unified toolbar metal color (not exactly sure what the name of that color is either). My controller to this view calls initWithNibName:, but other than that, I don't see where or how I can change the col

scaling plot to nsview size

2010-06-21 Thread Richard Langly
Hi, I have a few hundred points which I'm trying to draw as a scatter plot. The origin of my plot (0,0) is in the center of my canvas where my crosshairs are. My values in this case are no larger than 0.998 and no less than -0.932. Though the values can always change so I'm trying to scale my grap

Core data and NSTextView: get the attributed string?

2010-06-21 Thread Bernard Knaepen
Hello, I have started playing with core data and I am having trouble to get the attributed string from an NSTextView into my program. In the project, the .xcdatamodel contains an Entity called 'signatures' which has a property named 'sigText'. I have set the type of sigText to Binary Data. In

CoreData and memory leaks

2010-06-21 Thread unixo
In my coredata application, I noticed a weird behavior when closing document windows; to be sure this was not related with some memory leaks introduced by me, I created a new document-based coredata project, without adding any kind of customization. I did the following test, even if it's not a

Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)

2010-06-21 Thread John Heitmann
On Feb 9, 2010, at 3:01 PM, Keith Duncan wrote: > ...you should create a 'concurrent' NSOperation as described in the > documentation, and schedule your NSURLConnection on +[NSRunLoop mainRunLoop]. > This will allow your NSOperation -start method to exit immediately and the > thread to return

Re: NSView background color

2010-06-21 Thread Kyle Sluder
On Sat, Jun 19, 2010 at 6:06 PM, Richard Langly wrote: > I have an NSView in a *.nib file. I'm trying to change the background > color in it to match the unified toolbar metal color (not exactly sure > what the name of that color is either). > > My controller to this view calls initWithNibName:, b

Re: CoreData and memory leaks

2010-06-21 Thread Nick Zitzmann
On Jun 20, 2010, at 7:42 AM, unixo wrote: > In my coredata application, I noticed a weird behavior when closing document > windows; to be sure this was not related with some memory leaks introduced by > me, I created a new document-based coredata project, without adding any kind > of customiza

docs, KVO and NSUserDefaults etc.

2010-06-21 Thread Matt Neuburg
On the one hand, Apple seems to warn in some documents that one should not assume KVO-compliance unless explicitly asserted. On the other, KVO is far more widely implemented in the built-in classes than is explicitly asserted. Experimentation shows that NSUserDefaults is KVO-compliant, and so are l

Re: Memory management on returning nil in init

2010-06-21 Thread Matt Neuburg
On Mon, 21 Jun 2010 12:59:14 -0400, Scott Anguish said: > >the new suggested format for calling super is > >self = [super init]; >if (self) { Then Apple should change the model code in the "Allocating and Initializing Objects" section of The Objective-C Programming Language. That is where most us

Re: NSView background color

2010-06-21 Thread Mike Abdullah
On 21 Jun 2010, at 18:18, Kyle Sluder wrote: > On Sat, Jun 19, 2010 at 6:06 PM, Richard Langly > wrote: >> I have an NSView in a *.nib file. I'm trying to change the background >> color in it to match the unified toolbar metal color (not exactly sure >> what the name of that color is either). >>

Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)

2010-06-21 Thread Kevin Wojniak
NSURLConnection already does its work asynchronously, there is no need to run it on a separate thread. However if you still want to, you should use [NSRunLoop currentRunLoop], which returns the run loop associated with that thread. In your code you are not creating your objects properly. You sh

Re: Memory management on returning nil in init

2010-06-21 Thread Scott Anguish
And that does need to be updated. Nonetheless, that _is_ the new suggested initialization model. On Jun 21, 2010, at 1:28 PM, Matt Neuburg wrote: > On Mon, 21 Jun 2010 12:59:14 -0400, Scott Anguish said: >> >> the new suggested format for calling super is >> >> self = [super init]; >> if (s

Re: CoreData and memory leaks

2010-06-21 Thread unixo
> Maybe. Remember that I'm using a brand new application, without any custom code. Maybe? What can it depend on? > Did you try running it in Instruments using the object alloc & leaks > instruments? For various reasons, Activity Monitor is a poor memory debugging > tool. Instruments, OTOH, will

Re: Memory management on returning nil in init

2010-06-21 Thread Scott Anguish
The old style > if (self = [super init]) will cause a warnings with certain settings now and in the future. On Jun 21, 2010, at 2:24 PM, vincent habchi wrote: > Hi, > > Le 21 juin 2010 à 20:07, Scott Anguish a écrit : > >> And that does need to be updated. >> >> Nonetheless, that _is_ the n

Re: Memory management on returning nil in init

2010-06-21 Thread Sean McBride
On Mon, 21 Jun 2010 16:43:46 +0200, Eiko Bleicher said: >One of my initializers can fail and thus it should return nil. Consider >the following example: > >-(id) initWithBool:(BOOL)ok >{ > if (self = [super init]) > { > if (!ok) { > return nil; // Point of interest > } > }

Re: docs, KVO and NSUserDefaults etc.

2010-06-21 Thread Sean McBride
On Mon, 21 Jun 2010 10:28:10 -0700, Matt Neuburg said: >On the one hand, Apple seems to warn in some documents that one should not >assume KVO-compliance unless explicitly asserted. On the other, KVO is far >more widely implemented in the built-in classes than is explicitly asserted. >Experimentat

Re: docs, KVO and NSUserDefaults etc.

2010-06-21 Thread Ken Thomases
On Jun 21, 2010, at 12:28 PM, Matt Neuburg wrote: > On the one hand, Apple seems to warn in some documents that one should not > assume KVO-compliance unless explicitly asserted. On the other, KVO is far > more widely implemented in the built-in classes than is explicitly asserted. Those two stat

Re: CoreData and memory leaks

2010-06-21 Thread Nick Zitzmann
On Jun 21, 2010, at 12:40 PM, unixo wrote: > Yes, I did, no leaks were detected. Then you're probably fine. CoreData is a memory hog, and I have some bugs filed on specific issues, but if memory use looks good in Instruments, then don't worry about it. Nick Zitzmann

Re: docs, KVO and NSUserDefaults etc.

2010-06-21 Thread jonat...@mugginsoft.com
On 21 Jun 2010, at 18:28, Matt Neuburg wrote: > On the one hand, Apple seems to warn in some documents that one should not > assume KVO-compliance unless explicitly asserted. On the other, KVO is far > more widely implemented in the built-in classes than is explicitly asserted. > Experimentation

Re: Core data and NSTextView: get the attributed string?

2010-06-21 Thread Michael Babin
On Jun 20, 2010, at 8:11 AM, Bernard Knaepen wrote: > The trouble I have is to access the attributed string within my code to later > draw in a custom view. I am trying something like this: > > NSManagedObjectContext *context = [self managedObjectContext]; > NSManagedObjectModel *model= [

Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)

2010-06-21 Thread John Heitmann
Thanks for the response. There is definitely a lot of goofiness in that code. I started from the apple xml performance demo, which had run-loop code that led me to believe that I had to run the NSURLConnection run loop in a thread. It's great that that's not the case (I re-read the example[1] an

Re: Memory management on returning nil in init

2010-06-21 Thread Eiko Bleicher
Thanks, this really gave some new twists. Different from Apple's documentation but safer. Eiko > As others have said: yes, you leak. But the solution is not to call > [self release], what you should do is call [super dealloc]. See here > for a previous discussion of this topic: > >

Re: Threaded DOM operations

2010-06-21 Thread Jens Alfke
On Jun 21, 2010, at 3:50 AM, Matej Bukovinski wrote: > I'm using WebKit to download a bunch of websites. On those sites I need to > perform some basic DOM tree operations (e.g., removing some DOM nodes). > WebKit makes this very straightforward by using elements such as DOMNodes to > represent

chaining animations

2010-06-21 Thread Alejandro Marcos Aragón
Hi everyone, Can someone point out what is the standard way to chain animations? I'm trying to animate several UIViews (one after the other) that are container into an NSMutableArray, and at this point I'm just doing something like the following: - (void) insert { if ([array co

Problem with stopModalWithCode on a different thread

2010-06-21 Thread Bill Appleton
Hi All, In 64 bit Safari our NPAPI plugin needs to use a few system dialogs for opening files, printing, etc. These system dialogs call stopModalWithCode to deliver the result of the dialog interaction back to the runModalForWindow function But the stopModalWithCode function does not work on ano

Re: docs, KVO and NSUserDefaults etc.

2010-06-21 Thread Scott Anguish
If it isn’t documented as being KVO compliant it is best not to assume it is guaranteed to be in the future. On Jun 21, 2010, at 1:28 PM, Matt Neuburg wrote: > But how is the user supposed to know this? Or is the user who discovers this > supposed to ignore it?

Re: docs, KVO and NSUserDefaults etc.

2010-06-21 Thread Scott Anguish
On Jun 21, 2010, at 2:52 PM, Sean McBride wrote: > On Mon, 21 Jun 2010 10:28:10 -0700, Matt Neuburg said: > >> On the one hand, Apple seems to warn in some documents that one should not >> assume KVO-compliance unless explicitly asserted. On the other, KVO is far >> more widely implemented in th

Re: Problem with stopModalWithCode on a different thread

2010-06-21 Thread Jens Alfke
On Jun 21, 2010, at 11:09 AM, Bill Appleton wrote: > In 64 bit Safari our NPAPI plugin needs to use a few system dialogs for > opening files, printing, etc. > > These system dialogs call stopModalWithCode to deliver the result of the > dialog interaction back to the runModalForWindow function >

NSView Docs. Was: Binding -- or not -- a button created in code

2010-06-21 Thread Jerry Krinock
On 2010 Jun 21, at 00:35, Kyle Sluder wrote: > On Mon, Jun 21, 2010 at 12:14 AM, Jerry Krinock wrote: >> In a home-made "collection view", each item contains a checkbox, whose value >> should represent an attribute in the data model. > > So, you are going to have multiple checkbox-style NSButt

Re: Problem with stopModalWithCode on a different thread

2010-06-21 Thread Charles Srstka
On Jun 21, 2010, at 7:33 PM, Jens Alfke wrote: > In general, if you have some kind of background activity that needs to call > some AppKit method like this, use -performSelectorOnMainThread:. If you’re requiring 10.6 or greater, you can use one of these methods as well: [[NSOperationQueue mainQ