release static pointers

2009-01-26 Thread Christian Giordano
Hi guys, I'm using sqlite3 library and a common technique is to cache
the statement. In some examples I found the statement is set as static
in the model which gets instantiated lazily. I'm wondering if and how
the pointer to the statement will be released. In the code samples I
saw there is no trace of the releasing (in this case,
sqlite3_finalize(statement)).

This is the example:

http://icodeblog.com/wp-content/uploads/2008/08/9-todom.png


I'm new to objective-c and sometimes I wonder if when to use static
pointers or singletons.


Thanks, chr
___

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


Location of the standard Apple icons in IB

2009-01-26 Thread Florian Soenens

Hi list,

i'm working on a 10.4+ app and i use some icon templates like  
NSPreferencesGeneral, NSUser, etc...
The problem is that something like [toolbarItem setImage:[NSImage  
imageNamed:@NSPreferencesGeneral]] only works on 10.5+


My question is, does anyone know the location these icons on then  
system so i can take them and build them with my project instead of  
relying on the runtime based approach.


I looked in System - CoreServices but there not all there.

Thanks in advance,
Florian.

Looking for Web-to-Print Solutions?
Visit our website :   http://www.vit2print.com


This e-mail, and any attachments thereto, is intended only for use by the 
addressee(s) named herein and may contain legally privileged and/or 
confidential information and/or information protected by intellectual property 
rights.
If you are not the intended recipient, please note that any review, 
dissemination, disclosure, alteration, printing, copying or transmission of 
this e-mail and/or any file transmitted with it, is strictly prohibited and may 
be unlawful.
If you have received this e-mail by mistake, please immediately notify the 
sender and permanently delete the original as well as any copy of any e-mail 
and any printout thereof.
We may monitor e-mail to and from our network.

NSS nv Tieltstraat 167 8740 Pittem Belgium 
___


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: Location of the standard Apple icons in IB

2009-01-26 Thread Florian Soenens

You're right!

Don't know why i didn't think about that myself... ;-)

Txs.

On 26 Jan 2009, at 11:37, Jean-Daniel Dupas wrote:



Le 26 janv. 09 à 11:29, Florian Soenens a écrit :


Hi list,

i'm working on a 10.4+ app and i use some icon templates like  
NSPreferencesGeneral, NSUser, etc...
The problem is that something like [toolbarItem setImage:[NSImage  
imageNamed:@NSPreferencesGeneral]] only works on 10.5+


My question is, does anyone know the location these icons on then  
system so i can take them and build them with my project instead of  
relying on the runtime based approach.


I looked in System - CoreServices but there not all there.

Thanks in advance,
Florian.

Looking for Web-to-Print Solutions?
Visit our website :   http://www.vit2print.com



What about retreiving them on 10.5 using NSImage functions ?

[[[NSImage imageNamed:@NSPreferencesGeneral]  
TIFFRepresentationUsingCompression:NSTIFFCompressionLZW]  
writeToFile:@NSPreferencesGeneral.tiff atomically:NO];







Looking for Web-to-Print Solutions?
Visit our website :   http://www.vit2print.com


This e-mail, and any attachments thereto, is intended only for use by the 
addressee(s) named herein and may contain legally privileged and/or 
confidential information and/or information protected by intellectual property 
rights.
If you are not the intended recipient, please note that any review, 
dissemination, disclosure, alteration, printing, copying or transmission of 
this e-mail and/or any file transmitted with it, is strictly prohibited and may 
be unlawful.
If you have received this e-mail by mistake, please immediately notify the 
sender and permanently delete the original as well as any copy of any e-mail 
and any printout thereof.
We may monitor e-mail to and from our network.

NSS nv Tieltstraat 167 8740 Pittem Belgium 
___


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: Getting iPod icon, was Getting the network Machine Icon

2009-01-26 Thread Dave
Opps! I sent this by mistake, I already found the solution this  
weekend, I just changed the BitmapInfo to  
kCGImageAlphaPremulitipledFirst and all is well!


Thanks a lot for your help, it's almost all working now.

All the Best
Dave

Hi Jean,

Thanks, I added the code you suggested and it basically works! I have  
one small problem left in that the colors are shifted, I think the  
routine I am returning the buffer to expects ARGB or BGRA and I am  
returning the opposite! Typical!


Is there an easy way to get the pixels in the reverse order or do I  
need to swap the bytes myself?


Thanks in Advance
All the Best
Dave


On 23 Jan 2009, at 19:27, Jean-Daniel Dupas wrote:


The requirement of the function I am writing has now changed  
because I found a different way of doing it that requires much  
less changes to the rest of the application. Basically there is a  
framework of sorts that calls my function (GetIconImage), all I  
have to do is to render the Icon into a BitMap/PixMap and then  
return a pointer to it from my function, e.g. the function that  
calls my function need to return a buffer that is width * height *  
4 in size that contains the pixels and everything else will be  
taken care of!


So, I if change the bit that computes the Row Bytes value so it is  
(width * 4) and change the malloc to malloc(width * height * 4)  
then just return myImageBufferPtr, this should be ok?


Yes. You should release the CGContext too. If you provide a buffer  
when you create it (this is what you do), your are responsible to  
free it, and so, releasing the bitmap context will not affect it.





Also, how to I free the memory allocated by myBitMapContextRef,  
myIconRef and myIconFamily Icon? I can't seem to find dispose/ 
release functions for these objects.


All CG type are CoreFoundation objects. So you can use CFRelease to  
free the bitmap context. There is also a CGContextRelease function  
but the doc says that this function is equivalent to CFRelease,  
except that it does not cause an error if the context parameter is  
NULL.


For the IconRef, the function is ReleaseIconRef().

And the icon family is an handle, and should be freed using  
DisposeHandl


___

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/dave% 
40looktowindward.com


This email sent to d...@looktowindward.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


How to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Oleg Krupnov
For the beta-testing purposes, I'd like my app to handle the situation
when the EXC_BAD_ACCESS exception occurs, and treat it gracefully -
i.e. send a crash report and perhaps terminate.

Currently, the app just hangs and needs the user to send Force Quit to
terminate the app.

I tried to wrap the problematic code with @try/@catch, but
EXC_BAD_ACCESS seems to be a special kind of exception that is not
trapped this way.

Any advice is welcome!
___

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 to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread jonat...@mugginsoft.com


On 26 Jan 2009, at 11:33, Oleg Krupnov wrote:


For the beta-testing purposes, I'd like my app to handle the situation
when the EXC_BAD_ACCESS exception occurs, and treat it gracefully -
i.e. send a crash report and perhaps terminate.

Currently, the app just hangs and needs the user to send Force Quit to
terminate the app.

I tried to wrap the problematic code with @try/@catch, but
EXC_BAD_ACCESS seems to be a special kind of exception that is not
trapped this way.


EXC_BAD_ACCESS is not an application exception it is a Unix signal.
Signals are a BIG topic.

You can handle them in Cocoa. See this recent post.

http://www.cocoabuilder.com/archive/message/cocoa/2008/12/17/225634

Whether this is a wise course of action might be another matter.




Any advice is welcome!
___

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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.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: Creating a managed object without adding it to the context?

2009-01-26 Thread Ulai Beekam

 My problem is that when I add directly to the managed object
 context, the item is not getting selected automatically in the array
 controller (by the way, I see the selection visually by means of the
 table view bound to the array controller) even if I have checked the
 select on insert checkbox on the array controller in Interface
 Builder.

 IIRC that happens when you insert the object directly into the managed
 object context without going through the array controller.

 I.e. by using NSManagedObject's

 -initWithEntity:insertIntoManagedObjectContext:

 instead of NSArrayController's

 -addObject:

This is actually what I'm most interested about, and the reason why I asked my 
question in the first place. Can someone else here confirm this? Let me repeat 
what is to be confirmed: When a new managed object is added to the managed 
object context (NB: Directly going through to the context and NOT using 
arrayController's add: methods), is it true that the arrayController will not 
select that particular object?

If this is true, it seems strange to me, as this new object will get propagated 
to the arrayController and hence the arrayController should detect that it is a 
newly added object and therefore select it automatically, right?

Remember that throughout this discussion we assume that the select on insert 
checkbox is checked for the arrayController.


_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/___

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


Full screen on a display other than the main display

2009-01-26 Thread Matias Piipari
I tried making my application work in full screen with the method I've
attached below. This however only works correctly on the main display -- if
I try triggering this when the main window is any other screen I get just
black on that screen. What am I doing wrong?

- (IBAction) toggleFullScreenMode:(id) sender {
if (fullScreenMainWindow != nil) {
[self goAwayFromFullScreenMode: self];
return;
}

mainWindowBeforeGoingFullScreen = [[NSApplication sharedApplication]
mainWindow];
mainWindowBeforeGoingFullScreenRect =
mainWindowBeforeGoingFullScreen.frame;
mainWindowBeforeGoingFullScreenView =
mainWindowBeforeGoingFullScreen.contentView;

// Capture the screen that contains the window
displayID = [[[mainWindowBeforeGoingFullScreen.screen deviceDescription]
objectForKey:@NSScreenNumber] intValue];

if (CGDisplayCapture(displayID) != kCGErrorSuccess) {
NSLog(@WARNING!  could not capture the display!);
// Note: you'll probably want to display a proper error dialog here
}
// Get the shielding window level
int windowLevel = CGShieldingWindowLevel();

// Get the screen rect of our main display
NSRect screenRect = mainWindowBeforeGoingFullScreen.screen.frame;

// Put up a new window
fullScreenMainWindow = [[NSWindow alloc] initWithContentRect: screenRect
   styleMask:
NSBorderlessWindowMask
 backing:
NSBackingStoreBuffered
   defer: NO
  screen:
mainWindowBeforeGoingFullScreen.screen];
[fullScreenMainWindow setLevel:windowLevel];
[fullScreenMainWindow makeKeyAndOrderFront:nil];

[mainWindowBeforeGoingFullScreen setFrame:screenRect display:YES];
[fullScreenMainWindow
setContentView:mainWindowBeforeGoingFullScreen.contentView];
}
___

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: Opening Symbolic Links

2009-01-26 Thread René v Amerongen


On 26 jan 2009, at 07:07, Gerriet M. Denkmann wrote:


Am I doing something wrong?


nop



Does anybody seen this strange behaviour as well, or is it only me?


Not only you.
Wii have the same behaviour.

Even when you try to open it in textedit it doesn't work.
The links doesn't know what the org. doc's are.
But when it was still working well I dont remember.
A college should have filed a bug, but not sure if he really did.  
Maybe once more!


RvA
___

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


Configuring a Port-based Input Source -- Part 2

2009-01-26 Thread John Love

[continuation -- part 2]

Here is where my mainCtrl parm comes into play, because instead of  
Apple's:


Within my

do
{

 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode  
beforeDate:[NSDate distantFuture]];


} while (![mainCtrl shouldExit]);

where my – (BOOL) shouldExit is in my main Thread.

Am I still on the right track?  I definitely am off-base somewhere  
because there is no evidence that mainCtrl's –shouldExit is even  
called?  Anyway, I'm almost finished, so let me continue.


Further, I just use:[self sendCheckInMessage:distantPort];

and within Apple's – (void) sendCheckinMessage :(NSPort*)bgndPort,  
they have:


NSPort* myPort = [NSMachPort port];

Apple states: Create and configure the worker thread port.  Is  
myPort a local main Port for the worker thread port to send its  
message back to?  And if so, why is this required because doesn't  
Cocoa know about the main port that it presumably created when it  
called:


NSApplicationMain(argc, (const char **)argv);

at the very start within main.m?

One last basic question -- where exactly should my – 
doSomeSuperLongCalculation method go?  Should it be sandwiched somehow  
within –shouldExit,?  Is it inserted within the main thread's – 
handlePortMessage, or is it placed within the above do-while loop?


John Love
Touch the Future! Teach!

P.S. Hope I don't get bumped again for excessive length.

___

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: Accessing private members of another object of the same class

2009-01-26 Thread Horst Jäger





First of all: thank you. You solved my problem.


There's no real way to enforce privateness, either in Objective-C  
or C++.


Why not in C++?





Yes, these do the trick.




But another-mineAlone will.






-(int)yoursTooButWithAnother: (PrivateClass *)another {
return another-mineAlone % 3;
}







Also, be careful to keep two things separate in your mind.

-- The *variable* mineAlone, which can be referenced in the class's  
methods as 'mineAlone' or 'self-mineAlone'.


-- The *property* mineAlone, which can be referenced in the class's  
methods as '[self mineAlone]' or 'self.mineAlone'.


They only accidentally have the same name.


Yes.







Cheers Horst
___

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: release static pointers

2009-01-26 Thread Peter Blazejewicz

hi Christian,

On Jan 26, 2009, at 11:25 AM, Christian Giordano wrote:


I'm wondering if and how
the pointer to the statement will be released. In the code samples I
saw there is no trace of the releasing (in this case,
sqlite3_finalize(statement)).

This is the example:

http://icodeblog.com/wp-content/uploads/2008/08/9-todom.png
It looks like you started in wrong place. The sample code is certainly  
based on official Apple's sqlite integration sample:

http://developer.apple.com/iphone/library/samplecode/SQLiteBooks/
(go there, registration for online type of ADC account is free),
which is far more better place to start I think. To finalize  
statements there is dedicated class method defined in entity class  
that gets called when application is to be closed (in blog sample that  
could be implemented as:

@interface ...
+(void)finalizeStatements;

@implementation
+(void)finalizeStatements
{
if(stmt){
sqlite3_finalize(stmt);
stmt = NULL;
};
}

called as:

[Todo finalizeStatements]

from one of controllers.

regards,
Peter
___

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: Accessing private members of another object of the same class

2009-01-26 Thread Jeremy Pereira


On 26 Jan 2009, at 14:02, Horst Jäger wrote:






First of all: thank you. You solved my problem.


There's no real way to enforce privateness, either in Objective-C  
or C++.


Why not in C++?


#define private public

class Foo
{
private:
int privateVar;
} ;



___

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: Accessing private members of another object of the same class

2009-01-26 Thread Jean-Daniel Dupas


Le 26 janv. 09 à 15:02, Horst Jäger a écrit :






First of all: thank you. You solved my problem.


There's no real way to enforce privateness, either in Objective-C  
or C++.


Why not in C++?



And why not in Obj-C ? The new runtime (64 bits, non-fragile) declare  
a symbol for each ivar. Private ivars are not exported by default, so  
you cannot access them without running into a linker error.


That said, if you know the layout of a specific object (either in C++  
and Obj-C) you can cast it into a blob and access the memory directly.  
That's maybe why he said you cannot enforce privateness.



___

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: release static pointers

2009-01-26 Thread Christian Giordano
It looked like a good tutorial :)

Thanks, I'll check better the Apple way.


Cheers, chr


On Mon, Jan 26, 2009 at 1:59 PM, Peter Blazejewicz
peter.blazejew...@gmail.com wrote:
 hi Christian,

 On Jan 26, 2009, at 11:25 AM, Christian Giordano wrote:

 I'm wondering if and how
 the pointer to the statement will be released. In the code samples I
 saw there is no trace of the releasing (in this case,
 sqlite3_finalize(statement)).

 This is the example:

 http://icodeblog.com/wp-content/uploads/2008/08/9-todom.png

 It looks like you started in wrong place. The sample code is certainly based
 on official Apple's sqlite integration sample:
 http://developer.apple.com/iphone/library/samplecode/SQLiteBooks/
 (go there, registration for online type of ADC account is free),
 which is far more better place to start I think. To finalize statements
 there is dedicated class method defined in entity class that gets called
 when application is to be closed (in blog sample that could be implemented
 as:
 @interface ...
 +(void)finalizeStatements;

 @implementation
 +(void)finalizeStatements
 {
if(stmt){
sqlite3_finalize(stmt);
stmt = NULL;
};
 }

 called as:

 [Todo finalizeStatements]

 from one of controllers.

 regards,
 Peter

___

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


Configuring a Port-based Input Source -- Part 1

2009-01-26 Thread John Love
I have this request for help in two parts, because I've been bumped  
due to length:


Reference: Configuring a Port-Based Input Source of
http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ 
/apple_ref/doc/uid/1057i-CH16-SW7


My challenge is to try to understand this part of Chapter 5 of Apple's  
multithreading.pdf.  My single question is Is my understanding  
correct? .. and the best way I can approach this is to go almost line- 
by-line of the code presented.


First and foremost, I understand that a NSMachPort is a two way port:  
for the main thread, the remote port is the background port and for  
the background Thread, the remote port is the main port.  In short,  
the same port is used for two-way communication.


I have placed all the methods listed in this section of Ch. 5 are in a  
separate controller, ThreadController, from here on called TC.  So,  
when I call any of these methods from the main thread, I use:


[iboTC somePortMethod];

My principal variation to Apple's code involves calling –launchThread  
with a passed parm, i.e.:


[iboTC launchThread:self];

Within my TC's – (void) launchThread:(id)theMainCtrl, I assign the  
passed parm to my TC instance variable = mainCtrl (for use later, as  
you will see).


So, going almost line-by-line:

Within Apple's –launchThread, they have:

NSPort* myPort = [NSMachPort port];

This appears to be a new background Port.  Is it, or is it a new local  
main Port?  I think it is a background Port because Apple continues by  
calling – detachNewThreadSelector with an object equal to this Port.


Within the selector passed to –detachNewThreadSelecctor:

+(void)LaunchThreadWithPort:(id)inData
(actually, I convert it to an instance method - don't know why Apple  
uses a class method here

?)

the passed inData is immediately converted:

NSPort* distantPort = (NSPort*)inData;

Where their distantPort, or remote Port, is the remote Port for the  
main Thread, thus making the passed Port the background Port.


Am I good so far and if not, why not?

[continued in Part II]

___

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


Binding Buttons and Popup Menus to NSDictionary made from a prefs plist?

2009-01-26 Thread Robert Monaghan

Hi Everyone,

I am trying to wrap my head around using a plist.
Everything that I have seen on the mailing list so far, involves using  
an NSTableView to work with NSDictionaries. Here is what I have set up.
I have several NSButtons and pre-populated NSPopup Buttons, where the  
index values or states are stored as NSNumbers inside a plist file.  
Fairly easy to figure out. You just specify a key, and you get an  
NSNumber Object.


I am now trying use several of these plists. I have a list of projects  
in an NSTextColum, each with its own plist. I want to select one of  
the projects in the tableview, and have the controls changed to  
reflect the states from the appropriate plist. Again, in theory,  
plists should work well, here.


So far, I have an NSArrayController working well, with a list of  
projects/plists. However, I can't seem to get the bindings to work for  
the various controls. I am attempting to bind the buttons and popup  
menus to *something that that can drive them. I not only want the  
controls to be updated with each project that is selected, but have  
the NSDictionary that is holding the plist, to be updated when the  
user changes the controls.


You would think that this is straight forward.

Here is what I have tried:
NSDictionaryController.
I have an observeValueForKeyPath set up, to watch my  
NSArrayController, with a list of projects.
Once I have a project selected, it then binds an NSMutableDictionary  
to the NSDictionaryController
Something like this: [seqPrefsCtlr bind:NSContentDictionaryBinding  
toObject:self withKeyPath:@prefsDict options:nil];


No problem there.. But then I can't seem to figure out what to bind  
the assorted NSButtons and NSPopup menus to.


My other idea was to subclass NSArrayController, and override  
selectedObjects.
With this, I wanted to bind each control to the NSMutableDictionary in  
File's owner (somehow), and have each control observe a key in the  
dictionary. This seems to be a one way street, however. I can get the  
keys in the dictionary to initially set the buttons/popups, but  
nothing else.


Is there any sort of example that shows how an NSDictionary can drive  
a pile of controls with bindings? Or should I just brute-force this,  
and write other code?


bob.



Robert Monaghan
Glue Tools LLC
629 State St. Suite 220
Santa Barbara, CA, 93101
United States

tel: +1 805 456 7997
fax: +1 805 456 7998

www.gluetools.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: Accessing private members of another object of the same class

2009-01-26 Thread glenn andreas


On Jan 26, 2009, at 8:14 AM, Jean-Daniel Dupas wrote:
There's no real way to enforce privateness, either in Objective-C  
or C++.


Why not in C++?



And why not in Obj-C ? The new runtime (64 bits, non-fragile)  
declare a symbol for each ivar. Private ivars are not exported by  
default, so you cannot access them without running into a linker  
error.




But you can use valueForKey:.

That said, if you know the layout of a specific object (either in C+ 
+ and Obj-C) you can cast it into a blob and access the memory  
directly. That's maybe why he said you cannot enforce privateness.




The layout for 64 bit new runtime objects is not defined (and due to  
the non-fragile part, isn't even fixed at compile or link time, so  
you'd have to munge your way through  undocumented data structures -  
better off just using KVC).



Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next  
generation of fractal art




___

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: Targeting Tiger

2009-01-26 Thread David Springer
Hi John,
Also worth noting: you can build on Leopard with Xcode 3.x, using the 10.4
SDK, and your app might run fine on a Leopard box.  BUT, you still need to
test on a native Tiger platform because the systems dylibs are different
(and yes, the 10.4 API behaves differently between Tiger and Leopard).  Even
though you link against the 10.4 SDK, you still run against the system
dylibs shipped on the target computer.  Which is why you need to run on a
native Tiger system for complete testing.
Around here we figure that we need to keep a Tiger computer around for as
long as we support Tiger.

Another note: be sure that you target 10.4 in your build environment.  In
particular, be sure that -mmacos-version-min=10.4 and
-isysroot /Developer/SDKs/MacOSX10.4u.sdk are set as gcc build flags in case
you are using makefiles.  This will ensure that the generic (G3-friendly)
ppc arch is built, and not the later ppc7400 arch (not supported on Tiger
and some early Leopards).

- Dave.S

On Sun, Jan 25, 2009 at 1:01 PM, John Joyce 
dangerwillrobinsondan...@gmail.com wrote:


 On Jan 24, 2009, at 8:31 PM, cocoa-dev-requ...@lists.apple.com wrote:

  Not sure what you mean by capable of running tiger. If you have a
 machine
 capable of running Leopard, it should be able to run tiger.


 Not true. In general, any Mac requires the latest OS available at the
 time it was released. So machines released after the release of
 Leopard usually require Leopard.



 Not in general. No Mac is supported to run any version of the Mac OS
 earlier than the version it officially shipped with.
 If your Mac officially shipped with 10.5.4 it is unsupported to run 10.5.3
 or earlier. Period.
 If you do not know, and you may not, call AppleCare, provide the serial
 number of the Mac, they can tell you precisely which version it originally
 shipped with and that will be the earliest version you can reliably run on
 that computer.
 Although in some cases you may successfully boot and run some earlier
 version, it is unsupported, meaning it would not be a good test
  environment.

 Any Mac that runs Tiger well, will be more than adequate for most Tiger
 development. (exceptions would be targeting higher or lower end hardware)
 ___

 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/dspringer%40google.com

 This email sent to dsprin...@google.com




-- 
http://go/OnlyCheckEmailTwiceADay - join the movement
___

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: Accessing private members of another object of the same class

2009-01-26 Thread Bill Bumgarner

On Jan 26, 2009, at 7:24 AM, glenn andreas wrote:
The layout for 64 bit new runtime objects is not defined (and due to  
the non-fragile part, isn't even fixed at compile or link time, so  
you'd have to munge your way through  undocumented data structures -  
better off just using KVC).


Or the API

OBJC_EXPORT Ivar class_getInstanceVariable(Class cls, const char *name);


___

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: Knowing when a NSArrayController is ready

2009-01-26 Thread Ashley Clark

On Jan 26, 2009, at 10:58 AM, Sean McBride wrote:


On 1/24/09 11:05 PM, jonat...@mugginsoft.com said:


I changed my store type to SQLite and noted an immediate improvement
in load times.


Your app isn't garbage collected is it?  Because if so, note that the
SQL store is incompatible with GC apps. :(


What's this supposed incompatibility? According to everything I've  
read CoreData is fully GC compliant. I would assume that includes all  
of the store types.



Ashley

 [1]: http://developer.apple.com/releasenotes/Cocoa/CoreDataReleaseNotes/index.html#/ 
/apple_ref/doc/uid/TP40006503-SW5

smime.p7s
Description: S/MIME cryptographic signature
___

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 to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Scott Ribe
 Currently, the app just hangs and needs the user to send Force Quit to
 terminate the app.

You sure about that? It can take a while to prepare the crash report, and
during that time your app is certainly non-responsive. But that signal
causes the system to terminate your application, and I have ***NEVER*** seen
that termination fail, not under any circumstances. In fact, if the system
can't terminate the app after EXC_BAD_ACCESS, there would be no reason to
expect the user to be able to force quit it either...

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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


autorelease problem

2009-01-26 Thread Nick Rogers

Hi,

My program is crashing when releasing the NSAutoreleasePool.
I have in my code:

- (void)MyFunction
{
while (count)
{
NSAutoreleasePool *innerloop = [[NSAutoreleasePool alloc] init];
HDIR *dir = [someArray objectAtIndex:count];
		NSString *fileNameNew = [self suggestedRepeatFileName:[dir fileName]  
inDir:someDir];

[dir setFileName:fileNameNew];
[innerloop release];//crashing here
count--;
}
}

- (NSString*)suggestedRepeatFileName:(NSString *)fileName inDir:(HDIR  
*)dir

{
// some code here
	NSString *fileNameReturned = [NSString stringWithFormat:@%@,  
someString];

return fileNameReturned;
}

Is there any problem with the code here?
Please help.

Wishes,
Nick

___

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 to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Kyle Sluder
On Mon, Jan 26, 2009 at 7:16 AM, jonat...@mugginsoft.com
jonat...@mugginsoft.com wrote:
 EXC_BAD_ACCESS is not an application exception it is a Unix signal.
 Signals are a BIG topic.

EXC_BAD_ACCESS is not a UNIX signal, it is a Mach exception.  In
response to this exception, the UNIX layer will send your process
SIGBUS.

--Kyle Sluder
___

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: Knowing when a NSArrayController is ready

2009-01-26 Thread Sean McBride
On 1/26/09 11:06 AM, Ashley Clark said:

 Your app isn't garbage collected is it?  Because if so, note that the
 SQL store is incompatible with GC apps. :(

What's this supposed incompatibility? According to everything I've
read CoreData is fully GC compliant. I would assume that includes all
of the store types.

You assume incorrectly:
http://www.cocoabuilder.com/archive/message/cocoa/2008/2/28/200078

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: autorelease problem

2009-01-26 Thread Matt Gough


On 26 Jan 2009, at 18:12, Nick Rogers wrote:

- (NSString*)suggestedRepeatFileName:(NSString *)fileName inDir: 
(HDIR *)dir

{
// some code here
	NSString *fileNameReturned = [NSString stringWithFormat:@%@,  
someString];

return fileNameReturned;
}

Is there any problem with the code here?



Hard to tell without knowing where someDir or someString came from, or  
what -[HDIR setFileName] is up to.


Does it crash the first time though the loop or later?

Matt
___

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: Knowing when a NSArrayController is ready

2009-01-26 Thread Nick Zitzmann


On Jan 26, 2009, at 12:18 PM, Sean McBride wrote:


You assume incorrectly:
http://www.cocoabuilder.com/archive/message/cocoa/2008/2/28/200078



That's only if the program is using the NSPersistentDocument API. I've  
been using a CoreData sqlite app that doesn't use NSPersistentDocument  
and uses GC, and it works just fine.


Nick Zitzmann
http://www.chronosnet.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: autorelease problem

2009-01-26 Thread Nick Rogers

hi,
thanks for the reply.
someString in the method suggestedRepeat... is an NSMutableString  
allocated and initialized within that method.


-[HDIR setFileName] is as follows:
- (void)setFileName:(NSString *)name
{
name = [name copy];
[fileName release];
fileName = name;
}

Also the [innerloop release]; is crashing the first time through the  
loop.


Regards,
Nick

On 26-Jan-09, at 10:53 PM, Matt Gough wrote:



On 26 Jan 2009, at 18:12, Nick Rogers wrote:

- (NSString*)suggestedRepeatFileName:(NSString *)fileName inDir: 
(HDIR *)dir

{
// some code here
	NSString *fileNameReturned = [NSString stringWithFormat:@%@,  
someString];

return fileNameReturned;
}

Is there any problem with the code here?



Hard to tell without knowing where someDir or someString came from,  
or what -[HDIR setFileName] is up to.


Does it crash the first time though the loop or later?

Matt


___

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: autorelease problem

2009-01-26 Thread Shawn Erickson
On Mon, Jan 26, 2009 at 9:40 AM, Nick Rogers roger...@mac.com wrote:
 hi,
 thanks for the reply.
 someString in the method suggestedRepeat... is an NSMutableString
 allocated and initialized within that method.

How is it allocated? Please show that code. What about someDir?

- (NSString*)suggestedRepeatFileName:(NSString *)fileName inDir:(HDIR *)dir
{
   // some code here

Please show the code.

 - (void)setFileName:(NSString *)name
 {
name = [name copy];
[fileName release];
fileName = name;
 }

Looks OK.

Try using NSZombie since it sounds like you are over releasing something.

-Shawn
___

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


NSTextField line breaking

2009-01-26 Thread John Nairn
In a nib file I can set line breaking mode of an NSTextField (e.g.,  
clip, truncate front, middle, end, etc.).


But, I cannot find and way to make that setting in a programmatically  
created NSTextField. I looked through NSTextField, NSTextFieldCell,  
and NSControl.



John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

___

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: NSTextField line breaking

2009-01-26 Thread John Nairn
In a nib file I can set line breaking mode of an NSTextField (e.g.,  
clip, truncate front, middle, end, etc.).


But, I cannot find and way to make that setting in a  
programmatically created NSTextField. I looked through NSTextField,  
NSTextFieldCell, and NSControl.


I just found it in NSCell methods as setLineBreakMode:


John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

___

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: NSTextField line breaking

2009-01-26 Thread Jonathan Hess

Hey John -

Here are the methods you're looking for:

- (void)setWraps:(BOOL)flag;
- (void)setScrollable:(BOOL)flag;
- (void)setScrollable:(BOOL)flag;

They're from NSCell.

Good Luck -
Jon Hess

On Jan 26, 2009, at 9:53 AM, John Nairn wrote:

In a nib file I can set line breaking mode of an NSTextField (e.g.,  
clip, truncate front, middle, end, etc.).


But, I cannot find and way to make that setting in a  
programmatically created NSTextField. I looked through NSTextField,  
NSTextFieldCell, and NSControl.



John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

___

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/jhess%40apple.com

This email sent to jh...@apple.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: Knowing when a NSArrayController is ready

2009-01-26 Thread Sean McBride
On 1/26/09 10:29 AM, Nick Zitzmann said:

 http://www.cocoabuilder.com/archive/message/cocoa/2008/2/28/200078

That's only if the program is using the NSPersistentDocument API. I've
been using a CoreData sqlite app that doesn't use NSPersistentDocument
and uses GC, and it works just fine.

True that the OP did not mention if he is using NSPersistentDocument,
but I think it more likely than not.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: Creating a managed object without adding it to the context?

2009-01-26 Thread Sean McBride
On 1/26/09 12:21 PM, Ulai Beekam said:

 IIRC that happens when you insert the object directly into the managed
 object context without going through the array controller.

 I.e. by using NSManagedObject's

 -initWithEntity:insertIntoManagedObjectContext:

 instead of NSArrayController's

 -addObject:

This is actually what I'm most interested about, and the reason why I
asked my question in the first place. Can someone else here confirm
this? Let me repeat what is to be confirmed: When a new managed object
is added to the managed object context (NB: Directly going through to
the context and NOT using arrayController's add: methods), is it true
that the arrayController will not select that particular object?

If this is true, it seems strange to me, as this new object will get
propagated to the arrayController and hence the arrayController should
detect that it is a newly added object and therefore select it
automatically, right?

Remember that throughout this discussion we assume that the select on
insert checkbox is checked for the arrayController.

I know what you're talking about.  You want to create a new object, you
want it to appear in the table, you want it to be selected, and you also
need to set some attributes/relationships that you cannot in awakeFromInsert.

The problem is that NSArrayController's -addObject: does not return to
you the pointer to the new managedobject, and so you cannot customise
it.  OTOH, if you use -initWithEntity:insertIntoManagedObjectContext:,
then it won't be selected in the arraycontroller/table.

I have been looking for the best solution for some time now.

Here's something I read recently on the topic:
http://boredzo.org/blog/archives/2008-11-26/how-to-work-with-a-bound-to-
array

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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


get the drawing text height

2009-01-26 Thread David Alter
I'm drawing a string to screen and I want to get the height if I specify a
specific width. I'm drawing the string by using the NSString drawInRect:
withAttributes:. I do not see how I can get the height after the text has
wrapped. I have looked at  NSString sizeWithAttributes, but there does not
appear to be away to set the width so I can compute the height the text will
take up.
Any ideas?

thanks
-dave
___

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: Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-26 Thread jonathan

On 25 Jan 2009, at 21:30, Ben Trumbull wrote:



The results for a default fetch on a data set of 1500 very simple
objects are:

XML - usesLazyFetching = NO  38.00 sec load
XML - usesLazyFetching = YES  4.78 sec load

SQLite - usesLazyFetching = NO  35.25 sec load
SQLite - usesLazyFetching = YES  2.07 sec load



These numbers are astronomically wrong.  On a modern intel machine,  
those numbers are off by between three and four orders of  
magnitude.  A 500Mhz ppc G4 with 256MB RAM can fetch 10,000 rows  
over 20x faster than that.


Thanks for posting a reply, It put me on the right track.

I think the numbers show that it is trivial to get your Core Data  
configuration astronomically wrong, especially if you are using  
bindings.




Timings are Cro-magnon.


Why ?  Put Shark in Time Sample (All Threads State).  You'll get  
close to wall clock time with a sampling accuracy of microseconds.


36000 years later...

Instruments reports:

1500 item data set fetch time .028s. So it's not the fetching that  
takes time!
My simple timings included a LOT of KVO notifications, not just the  
raw fetch.




Or just use the user default -com.apple.CoreData.SQLDebug 1 and  
we'll log all the SQL, plus annotations for timings of fetching.  It  
even comes in color -com.apple.CoreData.SyntaxColoredLogging 1

Everyone needs to have this on.



What does Instruments say ?  Select the Core Data template in the  
new document window.  That will configure all the most interesting  
Core Data instruments together.


Typically, with the SQLite store the most common error is failing to  
use prefetching when appropriate and faulting in lots of  
relationships.

My model is very simple with only a single to-many relationship.
With usesLazyFetching = NO things go haywire.
I get 1500 faults each of which throws up a storm of KVO calls.

The docs do state (Core Data Guide - Faults and KVO Notifications)  
that KVO notifications do occur as faults are realised, even if the  
faulted relationship is already in the moc (is this last assumption  
correct?)


I have a few bindings attached to the array controller which probably  
accounts for the storm.
usesLazyFetching = YES seems to batch up the faulting so that the  
notification storm doesn't get too out of hand.


However the best solution, in this simple case, is just to use  
[request setReturnsObjectsAsFaults:NO].




The XML store takes a long time to parse and add to the coordinator,  
but doesn't have that problem because it caches everything in  
memory.  So the fact you've managed to make the two perform about  
the same implies something else is going on.


I am using NSPersistentDocument + GC therefore it would seem that I  
have to revert to XML as per http://www.cocoabuilder.com/archive/message/cocoa/2008/2/28/200078


What are you doing in -awakeFromFetch for example ?  What kind of  
machine were these numbers taken on, and did you do so after a fresh  
restart with no other apps running ?
-awakeFromFetch extracts strings reps of an RTFD data binary and  
NSDate - so it does contribute to the load time.




Do you get the same performance without putting the objects in the  
array controller ?  Just set up the stack and do the fetch and toss  
the results.  Misconfigured array controllers can sometimes generate  
notification storms if you add observers that make changes while  
receiving notifications from the controller that something is  
changing.




The com.apple.CoreData.SQLDebug user default above is handy for that  
as what should be one or two fetches with a half page of log will  
instead by a fire-hose of logging that makes you want to quit  
Terminal.


- Ben



Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.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: get the drawing text height

2009-01-26 Thread Nick Zitzmann


On Jan 26, 2009, at 11:45 AM, David Alter wrote:

I'm drawing a string to screen and I want to get the height if I  
specify a
specific width. I'm drawing the string by using the NSString  
drawInRect:
withAttributes:. I do not see how I can get the height after the  
text has
wrapped. I have looked at  NSString sizeWithAttributes, but there  
does not
appear to be away to set the width so I can compute the height the  
text will

take up.
Any ideas?



http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html#//apple_ref/doc/uid/20001809 



Nick Zitzmann
http://www.chronosnet.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


Safari-like tabs in my own app?

2009-01-26 Thread Ulai Beekam

Where can I get Safari-like tabs in my own app? Actually, drag and drop is not 
necessary for me, but I need tabs that merge themselves into the toolbar.


For instance, judging from this image:  http://www.xtorrentp2p.com/1.png   does 
he use some known tab implementation? Let's just say I want tabs just like 
these: ones that merge to the toolbar, support small icons in them, but are not 
draggable. Where could I get something like this?


Someone has some code I can use or will I need to do this myself? In case I 
need to do this myself, what way can I use to merge a view to the toolbar?


Thanks, U
_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/photos.aspx___

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: Accessing private members of another object of the same class

2009-01-26 Thread Scott Ribe
 Why not in C++?

Same as Objective-C, another instance of the same class can access them (as
can static methods of the class)...


-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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


Adding rows in NSPredicateEditor

2009-01-26 Thread Tom

Hi everyone,

I'm wondering if there is a way I can control which row template gets  
added when the user clicks the '+' button on an NSPredicateEditor. The  
template chosen seems to be random, but I want it to be a specific one  
for user convenience.


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


Managing user focus

2009-01-26 Thread Sergey Uspensky
Hello!

Im porting an application to Leopard written in Qt - kinda onscreen
keyboard.

The thing is I need to make MainWindow of the application not accepting
keyboard focus (user focus) when user clicks on it choosing possible letters
(keep it always inactivated). So when user has chosen the letter it could be
pasted in other system-wide applications with keyboard focus.

I have already tried these:

in Qt

   setWindowFlags(Qt::Tool|Qt::FramelessWindowHint);

   setFocusPolicy(Qt::NoFocus);

- the window stops getting focusEvents but still grabs keyboard focus

since Qt 4.4 utilizes Carbon I've tried setting kHIWindowBitNoActivates or
kWindowNoActivatesAttribute for this WindowRef

Both variants didn't work.

Are there any workarounds in Cocoa ?  I can try Qt 4.5 beta if they make it
based on Cocoa

Afterwards when the window is off-focus I need to send the key to other
application which currently has user focus.

How can be that implemented (NSPasteboard ?) ?

In linux version disabling focus made through Xorg calling XFree() for XAtom
 WM_TAKE_FOCUS. Can that be used on Mac (I have read it has X11 port)?

Any help will be appreciated!

TIA,
Sergey
___

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: Safari-like tabs in my own app?

2009-01-26 Thread Dave DeLong

Check out PSMTabBarControl over on googlecode:

http://code.google.com/p/maccode/wiki/WhatIsMacCode

Dave

On Jan 26, 2009, at 12:50 PM, Ulai Beekam wrote:



Where can I get Safari-like tabs in my own app? Actually, drag and  
drop is not necessary for me, but I need tabs that merge  
themselves into the toolbar.



For instance, judging from this image:  http://www.xtorrentp2p.com/1.png 
   does he use some known tab implementation? Let's just say I want  
tabs just like these: ones that merge to the toolbar, support small  
icons in them, but are not draggable. Where could I get something  
like this?



Someone has some code I can use or will I need to do this myself? In  
case I need to do this myself, what way can I use to merge a view  
to the toolbar?



Thanks, U

___

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: get the drawing text height

2009-01-26 Thread James Walker

David Alter wrote:

I'm drawing a string to screen and I want to get the height if I specify a
specific width. I'm drawing the string by using the NSString drawInRect:
withAttributes:. I do not see how I can get the height after the text has
wrapped. I have looked at  NSString sizeWithAttributes, but there does not
appear to be away to set the width so I can compute the height the text will
take up.
Any ideas?


Try this:

NSRect  mySize = NSMakeSize( myWidth, 0.0 );
NSRect bounds = [myString boundingRectWithSize: mySize
options: NSStringDrawingUsesLineFragmentOrigin
attributes: myAtts];
float   theHeight = NSHeight( bounds );

(Typed into e-mail)
--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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: Adding rows in NSPredicateEditor

2009-01-26 Thread Peter Ammon


On Jan 25, 2009, at 3:25 AM, Tom wrote:


Hi everyone,

I'm wondering if there is a way I can control which row template  
gets added when the user clicks the '+' button on an  
NSPredicateEditor. The template chosen seems to be random, but I  
want it to be a specific one for user convenience.


Kind regards,


Tom


Hi Tom,

Unfortunately there's no easy way to control this yet.  Please file an  
enhancement request.  Thanks!


Note that the current algorithm is not random: it picks the first  
unused rule in a breadth-first search.


-Peter


___

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: Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-26 Thread Ben Trumbull


On Jan 26, 2009, at 11:47 AM, jonat...@mugginsoft.com wrote:

Why ?  Put Shark in Time Sample (All Threads State).  You'll get  
close to wall clock time with a sampling accuracy of microseconds.


36000 years later...


I'm not that old.  For short events like launch time, I've found Shark  
to provide much better accuracy than a lot of alternatives, plus free  
samples as a bonus.


Typically, with the SQLite store the most common error is failing  
to use prefetching when appropriate and faulting in lots of  
relationships.

My model is very simple with only a single to-many relationship.
With usesLazyFetching = NO things go haywire.
I get 1500 faults each of which throws up a storm of KVO calls.


Hrm.  I suspect you have some custom observer code that's triggering  
yet more work.  Or it may be your custom -awakeFromFetch


The docs do state (Core Data Guide - Faults and KVO Notifications)  
that KVO notifications do occur as faults are realised, even if the  
faulted relationship is already in the moc (is this last assumption  
correct?)


I'm not sure what you mean by that last part.  But if you have a to- 
many relationship, and you need its contents at launch time, you  
definitely want to use prefetching.


I have a few bindings attached to the array controller which  
probably accounts for the storm.
usesLazyFetching = YES seems to batch up the faulting so that the  
notification storm doesn't get too out of hand.


However the best solution, in this simple case, is just to use  
[request setReturnsObjectsAsFaults:NO].


You can use both.  Plus, you'll probably want to prefetch the  
relationship or not use it at launch time.


What are you doing in -awakeFromFetch for example ?  What kind of  
machine were these numbers taken on, and did you do so after a  
fresh restart with no other apps running ?
-awakeFromFetch extracts strings reps of an RTFD data binary and  
NSDate - so it does contribute to the load time.



How are you setting the results for these string reps ?  I assume upon  
transient attributes, yes ?  If the array controller is bound to those  
transients, this may be what it is observing.  You could also try  
using -setPrimitiveXYZ: instead of -setXYZ: during awakeFromFetch


If you need these for launch time, have you considered making them  
persistent ?  Unless the RTFD data changes frequently, you may be  
better off caching the extracted strings in the db.


- Ben



___

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


Setting data cell type for a specific row

2009-01-26 Thread kentozier
Hi 


I have a table where I want a button field in the last row of a column to 
contain a different button cell than all the other rows. All rows before the 
last contain a delete button, but in the last row, I want to change that to an 
add button. I create the add button when my class in initialized so how would 
I get a reference to the last button cell and change it's to my saved button 
cell? 


Thanks for any help 
___

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


[MEET] Sydney (Australia) - CocoaHeads February 5th

2009-01-26 Thread Mark Aufflick
Sydney CocoaHeads meets on the FIRST Thursday of each month and is
meeting next Thursday, February 5th.

We will be meeting at UTS Broadway, in room CB02.03.17 which means
building 2, level 3, room 17 :

Map: http://www.uts.edu.au/about/mapsdirections/bway.html

If you get lost, I will try to be there a little early and you can
call my mobile : 0438 700  647

Pending last minute changes to his travel schedule, André Pang is our
confirmed speaker for February. Of Realmac software fame (Rapid Weaver
and Little Snapper), André is a great speaker and has spoken at
international conferences, corporate clients and special interest
groups just like ours. André is knowledgeable on a wide range of Mac
related programming topics so
it's sure to be interesting for all.

I have updated the calendar linked from the Google Groups page (
http://groups.google.com/group/sydney-cocoaheads ). The cocoaheads.org
is not yet up to date while I wait for edit rights to the admin
system.

Please RSVP via the form linked below if you plan to attend CocoaHeads
Sydney on February 5th, 2009. No problem if you end up not making it,
but it's good to be able to plan for numbers etc.

https://spreadsheets.google.com/viewform?key=pSro-pQGhJ38Fd8Z0bbzoLw

Cheers,
Mark.

-- 
Mark Aufflick
  contact info at http://mark.aufflick.com/about/contact
___

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: Setting data cell type for a specific row

2009-01-26 Thread I. Savant
On Mon, Jan 26, 2009 at 4:41 PM,  kentoz...@comcast.net wrote:

 I have a table where I want a button field in the last row of a column to 
 contain a different button cell than all the other rows. All rows before the 
 last contain a delete button, but in the last row, I want to change that to 
 an add button. I create the add button when my class in initialized so how 
 would I get a reference to the last button cell and change it's to my saved 
 button cell?

  You don't get a reference to a cell. You tell the table view (via a
delegate method) what prototype cell to use for the requested col/row.
See:

 -[NSTableView tableView:dataCellForTableColumn:row:]

  ... and ...

Table View Programming Guide
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/TableView.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: CALayer autoresizing behaviour

2009-01-26 Thread Michael A. Crawford
Joe, I don't see you setting the needDisplayOnBoundsChange property,  
thus:


layer.needDisplayOnBoundsChange = YES;

The default value for this property is NO.

-Michael
--
We know as much about software quality problems as they knew about the  
Black Plague in the 1600s.  We've seen the victims' agonies and helped  
burn the corpses.  We don't know what causes it; we don't really know  
if there is only one disease.  We just suffer - and keep pouring our  
sewage into our water supply.


-- Unknown

On Jan 21, 2009, at 5:10 AM, Joe Wildish wrote:


All,

I'm having trouble getting a CALayer to resize automatically to fill  
its superlayer. I have the following code snippet:


   layer = [CALayer layer];
   layer.layoutManager  = [CAConstraintLayoutManager layoutManager];
   layer.autoresizingMask = kCALayerWidthSizable |  
kCALayerHeightSizable;


   object.frame = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f);
   [object addSublayer:layer];

   NSLog(@object.frame=%@,\nlayer.frame=%@,
   NSStringFromRect(NSRectFromCGRect(object.frame)),
   NSStringFromRect(NSRectFromCGRect(layer.frame)));

(NB: object is an instance of a CALayer).

It was my understanding that with the options that I've used for the  
autoresizing mask on layer, it should be resized to be the same  
size as its super-layer. However, the output on the console  
indicates otherwise:


2009-01-21 13:03:31.538 TheAppName[37894:10b] object.frame={{0, 0},  
{100, 100}},

layer.frame={{0, 0}, {0, 0}}

I thought that it might be that the change was in a state of  
animation at the point of the NSLog, but the actual visual output  
I'd expect from my app also indicates that the resize hasn't occurred.


Is anyone able to point out what I'm doing wrong?

Many thanks,
-Joe
___

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/michaelacrawford%40mac.com

This email sent to michaelacrawf...@mac.com




smime.p7s
Description: S/MIME cryptographic signature
___

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: Safari-like tabs in my own app?

2009-01-26 Thread Ulai Beekam

 Check out PSMTabBarControl over on googlecode:

 http://code.google.com/p/maccode/wiki/WhatIsMacCode

 Dave

Hmm ok. I checked that out but the palette refused to appear in Interface 
Builder. I followed their directions and put PSMTabBarControl.palette folder 
into ~/Library/Palettes/ folder but no palettes appears in Inteface Builder 
even after restarting IB. Any ideas?


Anyway, assuming if I want to make my own tab implementation, what mechanism do 
I use to merge my custom view into the toolbar, meaning that the bottom 
border of the toolbar disappears in areas where my custom view is directly 
below the toolbar (this may not necessarily be all the horizontal space due to 
source lists to the left etc.) Can a custom view affect its neighboring toolbar 
like that in some way?


About PSMTabBarControl, anyone here has any experience with it? Does it merge 
in the toolbar like it should?


And again about that Xtorrent image I posted earlier 
(http://www.xtorrentp2p.com/1.png), what do you reckon he uses for tabs? You 
think he's using PSMTabBarControl?
_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx___

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: Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-26 Thread Ben Trumbull


On Jan 26, 2009, at 2:09 PM, jonat...@mugginsoft.com wrote:

The docs do state (Core Data Guide - Faults and KVO Notifications)  
that KVO notifications do occur as faults are realised, even if  
the faulted relationship is already in the moc (is this last  
assumption correct?)


I'm not sure what you mean by that last part.  But if you have a to- 
many relationship, and you need its contents at launch time, you  
definitely want to use prefetching.
What I mean is if a object has a to-many relationship (lots of  
children say faulting to one parent)  but the faulted object has  
already been retrieved from the store and is in the moc, will the in  
memory resolution of that fault still trigger the KVO machinery? Or  
is my head full of noodles this evening.




The answer is ... it depends.  It can demonstrate the behavior you are  
concerned about.


If you are fetching lots of children, and traversing their parent  
relationship, then you almost certainly will want to use prefetching  
(setRelationshipKeypathsForPrefetching) which will instruct the fetch  
request to resolve them all at once, with 1 additional I/O instead of  
resolving them lazily one at a time for each child and N additional I/ 
Os.


If you need these for launch time, have you considered making them  
persistent ?  Unless the RTFD data changes frequently, you may be  
better off caching the extracted strings in the db.


I was wondering about this - especially as I am occasionally getting  
a curious EXC_BAD_ACCESS when rebuilding my NSAttributed string (but  
that's another post).

To me appear that there are 3 ways to do this:

1. make the string rep after the fetch.
2. cache it in the db as you say.
3. use an NSValueTransformer in the binding.


Also, don't underestimate the power of writing your own custom  
NSValueTransformer.  The default one used by transformable attributes  
is NSKeyedArchiver, but while flexible and powerful, it can be a bit  
slow for very small items.


The RTFD is more or less static so maybe caching it in the db is the  
simplest and has the same memory footprint as the build on fetch  
approach.



Caching in the db will provide a much better in memory footprint, at  
the expense of more disk use, and potentially slower saves.


- Ben

___

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: Safari-like tabs in my own app?

2009-01-26 Thread Nick Zitzmann


On Jan 26, 2009, at 3:17 PM, Ulai Beekam wrote:

Hmm ok. I checked that out but the palette refused to appear in  
Interface Builder. I followed their directions and put  
PSMTabBarControl.palette folder into ~/Library/Palettes/ folder but  
no palettes appears in Inteface Builder even after restarting IB.  
Any ideas?



IB 3  later won't load IB 2 palettes. If you've got an IB palette,  
then you'll need to install Xcode 2.5 and run IB 2 to use it.


Nick Zitzmann
http://www.chronosnet.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: Properties and memory management with overrides.

2009-01-26 Thread Sean McBride
On 1/18/09 4:29 PM, Ben Trumbull said:

 I mention this because (I'm embarrassed to admit) I never really
 thought about this till yesterday. I *think* other design decisions
 have made the atomic-ness irrelevant to any of the code I've written,
 but now I need to go back and check, especially where Core Data is
 involved.

Core Data @dynamic properties are always nonatomic, irrespective of
the property declaration.

Core Data explicitly, intentionally, and states in the documentation,
that you can have any property atomicity you want so long as it's
nonatomic.

Interesting.  I never thought about this either, and was happy to see
this come up.

Ben, does this mean that the examples given here:
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdAccessorMethods.html#//apple_ref/doc/uid/TP40002154-SW9

should be:

@property(retain, nonatomic) NSString* firstName, lastName;

instead of:

@property(retain) NSString* firstName, lastName;

(I understand that it makes no difference at runtime.)

Likewise, shouldn't Xcode's 'Design  Data Model  Copy Obj-C 2.0 Method
Declarations to Clipboard' feature specify nonatomic?

Or am I confused again? :)

Cheers,

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: Safari-like tabs in my own app?

2009-01-26 Thread john
Hi Ulai-

All of the palette instructions are for Interface Builder 2 - the new IB3
has a different plug-in architecture.  You will have to use the framework
and a custom view in IB with the more modern tools (until someone crafts up
an IB3 plugin :-)

It does have the merge behavior you seek, depending on which tab style
you assign to the control.  There are a number of apps using the control to
that effect.  Adium is probably the most notable of the group, and it is
their people who maintain the latest version at googlecode.

I was the original author of the control, and you can see it in action
(merged and all) in Pandora:
http://www.positivespinmedia.com/shareware/Pandora/

It has since been much improved, and I'm a little out of touch with it -
sorry I can't be of more help!

John



On Mon, 26 Jan 2009 22:17:21 +, Ulai Beekam ulaibee...@hotmail.com
wrote:
 Check out PSMTabBarControl over on googlecode:

 http://code.google.com/p/maccode/wiki/WhatIsMacCode

 Dave
 
 Hmm ok. I checked that out but the palette refused to appear in Interface
 Builder. I followed their directions and put PSMTabBarControl.palette
 folder into ~/Library/Palettes/ folder but no palettes appears in
Inteface
 Builder even after restarting IB. Any ideas?
 
 
 Anyway, assuming if I want to make my own tab implementation, what
 mechanism do I use to merge my custom view into the toolbar, meaning
that
 the bottom border of the toolbar disappears in areas where my custom view
 is directly below the toolbar (this may not necessarily be all the
 horizontal space due to source lists to the left etc.) Can a custom view
 affect its neighboring toolbar like that in some way?
 
 
 About PSMTabBarControl, anyone here has any experience with it? Does it
 merge in the toolbar like it should?
 
 
 And again about that Xtorrent image I posted earlier
 (http://www.xtorrentp2p.com/1.png), what do you reckon he uses for tabs?
 You think he's using PSMTabBarControl?
 _
 News, entertainment and everything you care about at Live.com. Get it
now!

http://www.live.com/getstarted.aspx___
 
 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/john%40positivespinmedia.com
 
 This email sent to j...@positivespinmedia.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


A question about key equivalents for menu items

2009-01-26 Thread Slava Pestov
Hi all,

Is there a nice way to get a Unicode string from a keyboard shortcut,
that looks like the key equivalents in NSMenuItems, for rendering
elsewhere in a GUI?

Slava
___

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: Cocoa-dev Digest, Vol 6, Issue 154

2009-01-26 Thread Michael Robinson

Greetings List,

A month ago my main hard disk failed, and I lost some development files 
that were not backed up.  Yes I know I am stupid.


Unfortunately the disk is too damaged for any recovery.

I have the latest version of the project I was working on, but it is in 
a compiled, releasable form.


I would like to know if any of you are aware of a way to decompile a 
compiled ObjectiveC project, to recover source files.


Even partial source would be a boon, I can't face re-doing the work.

Thanks for any advice,

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: A question about key equivalents for menu items

2009-01-26 Thread Peter Ammon


On Jan 26, 2009, at 2:57 PM, Slava Pestov wrote:


Hi all,

Is there a nice way to get a Unicode string from a keyboard shortcut,
that looks like the key equivalents in NSMenuItems, for rendering
elsewhere in a GUI?

Slava


Hey Slava,

No such function, unfortunately.  You can roll your own with the  
Unicode characters for the modifier keys (0x2303, 0x2325, 0x21E7,  
0x2318 for control, option, shift, and command), though there's still  
some special cased glyphs, like space.  This would be worth an  
enhancement request.


-Peter

PS: Keep up the good work on Factor, it's way cool!

___

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: A question about key equivalents for menu items

2009-01-26 Thread I. Savant

On Jan 26, 2009, at 6:19 PM, Peter Ammon wrote:

No such function, unfortunately.  You can roll your own with the  
Unicode characters for the modifier keys (0x2303, 0x2325, 0x21E7,  
0x2318 for control, option, shift, and command), though there's  
still some special cased glyphs, like space.  This would be worth an  
enhancement request.


  ... although you might check out the ShortcutRecorder project on  
Google Code. It's a great example (and is free code) for this very  
thing.


--
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: Properties and memory management with overrides.

2009-01-26 Thread Quincey Morris

On Jan 26, 2009, at 14:45, Sean McBride wrote:


On 1/18/09 4:29 PM, Ben Trumbull said:


I mention this because (I'm embarrassed to admit) I never really
thought about this till yesterday. I *think* other design decisions
have made the atomic-ness irrelevant to any of the code I've  
written,

but now I need to go back and check, especially where Core Data is
involved.


Core Data @dynamic properties are always nonatomic, irrespective of
the property declaration.

Core Data explicitly, intentionally, and states in the documentation,
that you can have any property atomicity you want so long as it's
nonatomic.


Interesting.  I never thought about this either, and was happy to see
this come up.


BTW, continuing the theme of things I didn't think about ...

Although the rationale for non-atomicity runs under the general thread- 
safety discussion umbrella, there are actually two separate issues to  
consider.


Generally, discussion about thread-safety of data like Core Data  
properties centers around the possibility of conflicting changes from  
multiple threads. Atomicity at the property level doesn't really help  
with that (as stated), and the problem must be solved at a higher level.


However, even if only one thread can be changing the data, atomicity  
still matters. If the accessors aren't atomic, multiple read-only  
users of the data (in different threads) might get completely bogus  
results. This problem *can* be solved by atomicity at the property  
level, if you're prepared to take the potential performance hit from  
implementing it.


I have to keep reminding myself that serializing changes through a  
single thread does *not* provide thread safety unless there is  
atomicity too.



___

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: Setting data cell type for a specific row

2009-01-26 Thread kentozier

I. Savant: 
 You don't get a reference to a cell. You tell the table view (via a 
 delegate method) what prototype cell to use for the requested col/row. 
 See: 
  -[NSTableView tableView:dataCellForTableColumn:row:] 


I took a look at that but it really seems to complicate things. Basically, I 
create the table and bind it to it's data source programatically. Once the 
table is bound and added to a view, the row count is known, so all I need to do 
is set that one cell.  


I got part way there by doing: 


// create an array controller 




NSArrayController *controller = [[NSArrayController alloc] init]; 




[controller bind: @contentArray toObject: model withKeyPath: @sites 
options: nil ]; 





// create the table and bind the columns 





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


// get reference to the last cell in the desired column 




int  rowIndex = [[controller arrangedObjects] count] - 1 ; 

id  cell = [[table tableColumnWithIdentifier: @delete ] dataCellForRow: 
rowIndex]; 




[cell setImage: [PMImages addButtonOrange]]; 

[cell setAlternateImage: [PMImages addButtonWhite]]; 

[cell setAction: @selector (handleAdd:)]; 




Which works, only problem is, it changes the image and target for every cell in 
the column. 



Is there no other way to do this other than ditching my table creation code 
completely and using a delegate? As above two lines indicate, this kind of 
thing should be trivial to do directly, provided there is some way to set the 
data cell. 



___

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: Properties and memory management with overrides.

2009-01-26 Thread Bill Bumgarner

On Jan 26, 2009, at 4:00 PM, Quincey Morris wrote:
Although the rationale for non-atomicity runs under the general  
thread-safety discussion umbrella, there are actually two separate  
issues to consider.


It helps to explicitly *not* think about atomicity under the same  
umbrella as thread safety for all the reasons you mention below.


To restate:

Atomicity has very little to do with thread-safety.

All atomicity guarantees is that you'll get and/or set a consistent  
value, regardless of who or what is beating upon the method (there are  
even ways -- perverse and wrong ways -- of writing nonatomic code that  
gives the wrong value in a single thread).


What atomicity does *not* guarantee is that you'll get/set the right  
value.


Generally, discussion about thread-safety of data like Core Data  
properties centers around the possibility of conflicting changes  
from multiple threads. Atomicity at the property level doesn't  
really help with that (as stated), and the problem must be solved at  
a higher level.


Exactly.

However, even if only one thread can be changing the data, atomicity  
still matters. If the accessors aren't atomic, multiple read-only  
users of the data (in different threads) might get completely bogus  
results. This problem *can* be solved by atomicity at the property  
level, if you're prepared to take the potential performance hit from  
implementing it.


Actually, it really can't be solved at the property level.  Individual  
properties can generally never carry enough information about  
themselves to know what the right behavior is in the face of threads.


Example:

@property(...) ... firstName;
@property(...) ... lastName;
@property(...) ... firstAndLastNameForDisplay;

If thread A is changing firstName while thread B is calling  
firstAndLastNameForDisplay, atomicity can only guarantee that - 
firstAndLastNameForDisplay won't crash.


What it can't do is guarantee that you'll get the correct value from - 
firstAndLastNameForDisplay.   For that to work, your model object has  
to know all about the dependencies between the three properties.


Looks simple, but it isn't.

Example question:  Does changing firstName mean that  
firstAndLastNameForDisplay returns nothing until lastName has also  
been changed?   ... what about the same lastName?   I could go on.


b.bum
___

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: Setting data cell type for a specific row

2009-01-26 Thread I. Savant

On Jan 26, 2009, at 7:45 PM, I. Savant wrote:


 Well what did you expect it to do?

 Again ... you don't get a reference to an individual cell at a row/ 
column. Tables don't work that way in Cocoa. The cell for a column  
is a *prototype* cell that's reused (changed and re-rendered in the  
proper position per row). Changing the data cell changes the *one*  
prototype that's used.


  Just to clarify something that might not be so obvious, you need to  
respond with the preferred cell for *every* row. In other words, in  
your case, always answer with the usual cell until you get to the last  
row, then answer with the alternate cell.


--
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


ass/ssa support

2009-01-26 Thread Ariel Rodriguez
Does anybody knows if there are some cocoa library to parse ass/ssa  
files? I know libass, but as far as i can see, it have a few memory  
leaks (and since i am planning to work with Cocoa Touch, i am really  
concerned about memory leaks).

Thanks and best regards.
Ariel Rodriguez, 
___


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


CoreData silently failing to insert?

2009-01-26 Thread Nick Zitzmann

I've got another CoreData problem, and this one is quite strange.

In this case, I have an entity that subclasses an abstract entity, and  
for some very strange reason I cannot diagnose, it will only save  
managed objects in that entity if the properties have very specific  
values in them.


Now, I know what you're thinking, but yes, I am validating the objects  
before inserting them, and they pass the validation, and the object is  
returned by -insertedObjects prior to the save, and saving does not  
cause the NSManagedObjectContext to return an error. The save goes  
absolutely perfectly, except that the objects aren't actually saved.


The objects have zero constraints, except that all properties must be  
set (and they are; I checked).


I already tried:
* changing the backing store from SQLite to XML; the same thing happened
* setting and changing constraints on some of the properties; nothing  
changed, although setting one to be too narrow for its normal range  
did generate expected validation errors

* changing the property names; didn't make a difference
* running the app with or without GC; non
* running the app as either X86 or X86-64; not that either
* running the app with the command line option - 
com.apple.CoreData.SQLDebug 3, and sure enough, despite the records  
validating and the MOC returning no errors upon save, no INSERT INTO  
command is issued to sqlite except for the handful of records with  
very specific values in them


What do I do now? (And I'm hoping I get an are you sure it's plugged  
in?-type answer that turns out to be correct...)


Nick Zitzmann
http://www.chronosnet.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: Properties and memory management with overrides.

2009-01-26 Thread Quincey Morris

On Jan 26, 2009, at 16:26, Bill Bumgarner wrote:

However, even if only one thread can be changing the data,  
atomicity still matters. If the accessors aren't atomic, multiple  
read-only users of the data (in different threads) might get  
completely bogus results. This problem *can* be solved by atomicity  
at the property level, if you're prepared to take the potential  
performance hit from implementing it.


Actually, it really can't be solved at the property level.   
Individual properties can generally never carry enough information  
about themselves to know what the right behavior is in the face of  
threads.


Example:


Indeed. In general, accessing a property can have 3 possible outcomes:

1. The right value.

2. A wrong value.

3. Complete and utter garbage.

Atomicity can eliminate the last case only. In general, that doesn't  
solve any problems at all, but in practice it might.


Any notification-driven system (even single-threaded) can present an  
observer with a temporarily inconsistent data model (as in your  
firstName/lastName example). Therefore, observers should typically be  
coded defensively with regard to outcome #2 anyway. Coding defensively  
against outcome #3 is unlikely to practicable. *That's* the problem I  
meant can be solved by atomicity.


___

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: Not Resolving Aliases

2009-01-26 Thread Gerriet M. Denkmann


On 27 Jan 2009, at 07:39, Scott Ribe wrote:


What are you actually trying to do?


I was trying to send the path of a symbolic link (not the content of  
this link, which anyway might not exist) to another app.


This other app displays all sort of information or metadata about this  
path.


The sending app has an NSBrowser, which shows things which have been  
changed between TimeMachine updates. Among these are also symlinks.


I have given up on NSWorkspace, LaunchServices and now send the path  
via Distributed Objects.

Works perfectly.

But I had some problems of enabling the other app to load to documents  
(it is Cocoa Document based) representing two symbolic links with the  
same content.

And I still cannot drag a symlink to its dock icon.
File - Open or the Services Menu work though.

Kind regards,

Gerriet.

___

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


Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-26 Thread Adam Venturella
Here is what I am doing now.. I just feel like I have an extra step in
converting the buffer into NSData...malloc...free

uint sample = 0x04034b50;
uint8_t buffer[sizeof(uint)];

[inputStream open];
[inputStream read: buffer maxLength:sizeof(buffer)];

NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
uint * key = (uint *) malloc(sizeof(uint));
[d getBytes:key length:sizeof(uint)];

[inputStream close];

NSLog(@%u = %u, *key, sample);

free(key);
___

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: Not Resolving Aliases

2009-01-26 Thread Scott Ribe
 I have given up on NSWorkspace, LaunchServices and now send the path
 via Distributed Objects.

Hey, that surprises me ;-) Give what you said, my next attempt would have
been constructing an open Apple Event... (Don't know if it would work,
because I don't know when the normal resolution of symlinks  aliases
happens, but it's what I would have tried. Next up would have been fork/exec
the open command.)

It seems to me that this is a feature that you'll need to be proactive about
testing against new releases. Resolution of symlinks  aliases is normally
considered a feature, so unless it's explicitly documented that your
technique doesn't do this, you may be vulnerable to an OS update adding a
feature and breaking your stuff...

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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: CoreData silently failing to insert?

2009-01-26 Thread Jerry Krinock


On 2009 Jan 26, at 17:08, Nick Zitzmann wrote:

...saving does not cause the NSManagedObjectContext to return an  
error.



...MOC returning no errors upon save...



Make sure you're looking at the YES/NO return value of - 
[NSManagedObjectContext save:] and not just the non-nil-ness of the  
NSError returned by reference.


___

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


NSTextView.preferredPasteboardTypeFromArray

2009-01-26 Thread Chris Idou
I'm trying to make an NSTextView do something rational when someone drags a 
token from an NSTokenField. So I've got the NSTokenField producing a custom 
drag type I've called TokenPboardType.

I've inherited from NSTextView and redefined readablePasteboardTypes to be:

- (NSArray*)readablePasteboardTypes; {
NSMutableArray*rtn = [NSMutableArrayarrayWithObject:TokenPboardType];
[rtn addObjectsFromArray:[superreadablePasteboardTypes]];
returnrtn;
}

and I redefined - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard 
type:(NSString*)type;

to do what I want.

My trouble is that when I redefine - 
(NSString*)preferredPasteboardTypeFromArray:(NSArray*)availableTypes 
restrictedToTypesFromArray:(NSArray*)allowedTypes;

This method's list of allowedTypes when I do the drag doesn't include my 
TokenPboardType. Now if I return TokenPboardType anyway, it seems to work. my 
readSelectionFromPasteboard gets called with TokenPboardType and it all seems 
to work. But it feels like I'm doing the wrong thing somehow, since from the 
doco it sounds like you shouldn't return a type that is not in the allowedTypes.

Comments?


  Stay connected to the people that matter most with a smarter inbox. Take 
a look http://au.docs.yahoo.com/mail/smarterinbox
___

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 to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Michael Ash
On Mon, Jan 26, 2009 at 12:09 PM, Scott Ribe scott_r...@killerbytes.com wrote:
 Currently, the app just hangs and needs the user to send Force Quit to
 terminate the app.

 You sure about that? It can take a while to prepare the crash report, and
 during that time your app is certainly non-responsive. But that signal
 causes the system to terminate your application, and I have ***NEVER*** seen
 that termination fail, not under any circumstances. In fact, if the system
 can't terminate the app after EXC_BAD_ACCESS, there would be no reason to
 expect the user to be able to force quit it either...

Actually it's pretty easy to avoid exiting due to EXC_BAD_ACCESS, just
install a signal handler for SIGSEGV.

Of course, doing something rational in such a signal handler is ever
so slightly non-trivial.

An initial force-quit can be easily blocked as well, install a handler
for SIGINT. If you force quit a process a second time the system goes
for SIGKILL, though, and you can't stop that one.

However this sort of thing generally is not done, so if your app
doesn't quit when you get an EXC_BAD_ACCESS it's probably because
you're not actually getting an EXC_BAD_ACCESS to begin with.

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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-26 Thread Graham Cox


On 27 Jan 2009, at 2:09 pm, Adam Venturella wrote:


NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
uint * key = (uint *) malloc(sizeof(uint));
[d getBytes:key length:sizeof(uint)];



uint key;

[d getBytes:key length:sizeof(uint)];

but since you have merely wrapped buffer in NSData, you already have  
the buffer, so:


uint key = *(uint*)buffer;

is also exactly the same, you don't need the NSData at all (at least  
as far as this bit goes).


--Graham




___

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: Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-26 Thread Dave Fernandes
I don't mean to hijack this thread, but I have had a related (?)  
problem where a transient String attribute is derived from a  
persistent Binary attributed (an archived NSAttributedString). When  
my NSTableView sorts on this column, and I modify a managed object  
displayed in the table, I get an error in the console:


2009-01-26 23:31:53.039 MyApp[414] *** NSRunLoop ignoring exception  
'unresolved keypath: referenceString' that raised during posting of  
delayed perform with target 15f7e2e0 and selector 'invokeWithTarget:


The table view, however, *is* able to sort on this attribute when I  
click the column header. Is sorting on transient attributes not fully  
supported?


Dave


On Jan 26, 2009, at 5:19 PM, Ben Trumbull wrote:



On Jan 26, 2009, at 2:09 PM, jonat...@mugginsoft.com wrote:

I was wondering about this - especially as I am occasionally  
getting a curious EXC_BAD_ACCESS when rebuilding my NSAttributed  
string (but that's another post).

To me appear that there are 3 ways to do this:

1. make the string rep after the fetch.
2. cache it in the db as you say.
3. use an NSValueTransformer in the binding.


Also, don't underestimate the power of writing your own custom  
NSValueTransformer.  The default one used by transformable  
attributes is NSKeyedArchiver, but while flexible and powerful, it  
can be a bit slow for very small items.


The RTFD is more or less static so maybe caching it in the db is  
the simplest and has the same memory footprint as the build on  
fetch approach.



Caching in the db will provide a much better in memory footprint,  
at the expense of more disk use, and potentially slower saves.



___

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: CoreData silently failing to insert?

2009-01-26 Thread Nick Zitzmann


On Jan 26, 2009, at 9:34 PM, Jerry Krinock wrote:

Make sure you're looking at the YES/NO return value of - 
[NSManagedObjectContext save:] and not just the non-nil-ness of the  
NSError returned by reference.



I'm doing that, too. It still returns YES even though the records were  
not actually saved. :(


Nick Zitzmann
http://www.chronosnet.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: How to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Slava Pestov
On Mon, Jan 26, 2009 at 10:43 PM, Michael Ash michael@gmail.com wrote:
 Actually it's pretty easy to avoid exiting due to EXC_BAD_ACCESS, just
 install a signal handler for SIGSEGV.

In my experience, setting a handler for SIGSEGV is problematic because
the crash reporter still starts up, so its best to handle the Mach
exception directly instead of resorting to Unix signals (which seem to
be emulated under Mach, rather than a native feature).

The Crash Reporter is not always what you want, because illegal memory
access is not always a fatal error in all cases, for example some
language VMs use memory protection to implement funky GC algorithms.

Anyway, to answer Oleg's question, I have some BSD-licensed code which
demonstrates this. Once you figure out the somewhat-hairy Mach APIs,
it is pretty straightforward:

http://gitweb.factorcode.org/gitweb.cgi?p=factor/.git;a=blob_plain;f=vm/mach_signal.c;hb=HEAD

Slava
___

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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-26 Thread Adam Venturella
Thanks! I knew I was doing to many steps!

On Mon, Jan 26, 2009 at 8:44 PM, Graham Cox graham@bigpond.com wrote:

 On 27 Jan 2009, at 2:09 pm, Adam Venturella wrote:

 NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
 uint * key = (uint *) malloc(sizeof(uint));
 [d getBytes:key length:sizeof(uint)];


 uint key;

 [d getBytes:key length:sizeof(uint)];

 but since you have merely wrapped buffer in NSData, you already have the
 buffer, so:

 uint key = *(uint*)buffer;

 is also exactly the same, you don't need the NSData at all (at least as far
 as this bit goes).

 --Graham





___

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: Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-26 Thread Ben Trumbull

poor hijacked thread.

You cannot ask -executeFetchRequest: to either filter (by predicate)  
or sort (by sort descriptor) based on a transient or unmodeled property.


The table view and array controller can happily sort or filter in  
memory.  Performance on sorting large data sets in memory leaves much  
to be desired.  However, if you must, you can strip off the sort  
descriptor before the fetch by using a subclass of NSArrayController  
(the methods to override are in NSObjectController.h) and then use the  
NSArray methods to handle the sort descriptor in memory.


There are many derivations of that technique, frequently having both  
sort string and display string property.  There is an ADC sample  
project about string Unicode normalization so you can use a search  
with an index even against complex internationalized text.


http://developer.apple.com/samplecode/DerivedProperty/index.html

For simple stuff, just drop the predicate or sort descriptor and  
process the results in memory.  For larger data sets, use some  
persistent data as a bounding rect in a view clipping kinda way, so  
the final in memory processing only touches up the results instead of  
working with all of them.


- Ben

On Jan 26, 2009, at 8:53 PM, Dave Fernandes wrote:

I don't mean to hijack this thread, but I have had a related (?)  
problem where a transient String attribute is derived from a  
persistent Binary attributed (an archived NSAttributedString). When  
my NSTableView sorts on this column, and I modify a managed object  
displayed in the table, I get an error in the console:


2009-01-26 23:31:53.039 MyApp[414] *** NSRunLoop ignoring exception  
'unresolved keypath: referenceString' that raised during posting of  
delayed perform with target 15f7e2e0 and selector 'invokeWithTarget:


The table view, however, *is* able to sort on this attribute when I  
click the column header. Is sorting on transient attributes not  
fully supported?


Dave


On Jan 26, 2009, at 5:19 PM, Ben Trumbull wrote:



On Jan 26, 2009, at 2:09 PM, jonat...@mugginsoft.com wrote:

I was wondering about this - especially as I am occasionally  
getting a curious EXC_BAD_ACCESS when rebuilding my NSAttributed  
string (but that's another post).

To me appear that there are 3 ways to do this:

1. make the string rep after the fetch.
2. cache it in the db as you say.
3. use an NSValueTransformer in the binding.


Also, don't underestimate the power of writing your own custom  
NSValueTransformer.  The default one used by transformable  
attributes is NSKeyedArchiver, but while flexible and powerful, it  
can be a bit slow for very small items.


The RTFD is more or less static so maybe caching it in the db is  
the simplest and has the same memory footprint as the build on  
fetch approach.



Caching in the db will provide a much better in memory footprint,  
at the expense of more disk use, and potentially slower saves.




___

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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-26 Thread Graham Cox


On 27 Jan 2009, at 4:17 pm, Adam Venturella wrote:


Thanks! I knew I was doing to many steps!



uint key = *(uint*)buffer;



You will also need to consider byte-ordering if your app or the data  
could be used on different architectures. If for example your input  
data is known to be big-endian, you'll probably want to do this:


uint key = NSSwapBigIntToHost( *(uint*)buffer );

--Graham


___

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 to catch and log EXC_BAD_ACCESS?

2009-01-26 Thread Bill Bumgarner

On Jan 26, 2009, at 8:43 PM, Michael Ash wrote:

Actually it's pretty easy to avoid exiting due to EXC_BAD_ACCESS, just
install a signal handler for SIGSEGV.

Of course, doing something rational in such a signal handler is ever
so slightly non-trivial.


Hahahaha yeah.  That is an understatement.

Before anyone thinks that handling SIGSEGV and recovering from it is a  
good idea.


It isn't.  Don't do it unless you are prepared to invest a TON of time  
into doing so.


It isn't really even a good idea to try and *emergency save* the  
user's data.


SIGSEGV (like other such crashes) indicates that something has gone  
horribly wrong.  Most likely, memory corruption has occurred.   Thus,  
if you try to save anything, you will quite likely be saving corrupted  
data.   You better had have a 100% bulletproof means of validating the  
data post-crash to determine what can be salvaged!!


Of the various projects I have worked on that tried to go down the  
we'll detect crashes and recover! path, every one of them would have  
achieved a far higher return-on-engineering-investment by focusing on  
creating working software instead.


b.bum



___

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: Setting data cell type for a specific row

2009-01-26 Thread Ken Tozier


On Jan 26, 2009, at 7:45 PM, I. Savant wrote:


 ... sorry?

 How does implementing one delegate method that's directly targeted  
at the very problem you're trying to solve complicate things?


I was confused about what to return from the method if I just wanted  
the data cell preserved as is. It turned out to be really simple, but  
the solution didn't hit me on the first few passes.


- (NSCell *) tableView:(NSTableView *) tableView
dataCellForTableColumn:(NSTableColumn *) tableColumn
row:(NSInteger) row
{
if ([[tableColumn identifier] isEqualToString: @delete] 
(row == [[controller arrangedObjects] count] - 1))
return addCell;
else
return [tableColumn dataCellForRow: row];
}

Thanks for your help. It was in typing up a rebuttal, that I stumbled  
upon this solution. Simple, clean, elegant. I guess delegates DO have  
a purpose :)


Thanks again

- Ken
___

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: Not Resolving Aliases

2009-01-26 Thread Gerriet M. Denkmann


On 27 Jan 2009, at 11:05, Scott Ribe wrote:


I have given up on NSWorkspace, LaunchServices and now send the path
via Distributed Objects.


Hey, that surprises me ;-) Give what you said, my next attempt would  
have

been constructing an open Apple Event... (Don't know if it would work,
because I don't know when the normal resolution of symlinks  aliases
happens, but it's what I would have tried. Next up would have been  
fork/exec

the open command.)


I also do not know.
But I know that Distributed Objects does work (it just sends a string  
and doesn't care nor know what this string stands for), and I have  
rather little experience with creating Apple Events.


So DO was for me the easiest solution I could think of.

Kind regards,

Gerriet.

___

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