RE: Checking whether a file is a genuine PDF file

2009-10-05 Thread Squ Aire

 de3c77430910040812h42100ab9g39c9715bccb17...@mail.gmail.com
Content-Type: text/plain; charset=Windows-1252
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0


Thanks for the reply. However=2C of course a file can start with %PDF witho=
ut being a valid PDF file (and not openable by Preview).

I think I found an acceptable way of doing my thing. Just include the Quart=
z framework and do

PDFDocument *pdfDoc =3D [[PDFDocument alloc] initWithURL:fileURL]=3B

If pdfDoc is nil=2C we don't have a genuine PDF file. Otherwise=2C we do.


 Date: Sun=2C 4 Oct 2009 11:12:43 -0400
 Subject: Re: Checking whether a file is a genuine PDF file
 From: sherm.pend...@gmail.com
 To: squ...@live.com
 CC: cocoa-dev@lists.apple.com

 On Sun=2C Oct 4=2C 2009 at 8:07 AM=2C Squ Aire  wrote:

 I know that=2C in an open dialog for example=2C I can view all PDF files=
 by just filtering using the pdf file extension. But that isn't good enou=
gh really=2C because a file can have the pdf extension without being a true=
 PDF file.

 From /usr/share/file/magic :

 # pdf: file(1) magic for Portable Document Format
 #

 0 string %PDF- PDF document
5 byte x \b=2C version %c
7 byte x \b.%c

 So=2C a real PDF begins with %PDF-=2C then two bytes with the major
 and minor version numbers=2C respectively. See man magic for details.

 How can I check whether a file is indeed a true PDF file (that can be=2C=
 for example=2C opened in Preview)? Would I be able to filter true PDFs fil=
e in an open dialog=2C or would I just have to stick to filtering with only=
 the pdf extension in open dialogs=2C and later ignore the non-valid PDF fi=
les?

 I would take the second approach. First=2C it's going to perform better=
=3B
 to filter the list in an open dialog=2C you'd have to open and verify
 every .pdf file in the directory being shown. You'd also need to
 inform the user somehow why some supposedly-pdf files are not
 selectable. Also=2C note that Preview's open dialog will allow you to
 select any file with a .pdf extension=2C then alerts the user if the
 file's contents aren't actually PDF data.

 Do you have sample code that checks whether a given file is a genuine PD=
F file?

 Here's a simple command-line tool that checks a single file. Please
 keep in mind=2C this is just an example! In the Real World(tm)=2C you'd
 want more robust error checking of the number of arguments given=2C the
 size of the file before attempting to read the first 7 bytes=2C etc.

 #import=20

 int main (int argc=2C const char * argv[]) {
 NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]=3B

 NSString *filename =3D [[[NSProcessInfo processInfo] arguments] objectAtI=
ndex:1]=3B
 char buf[7]=3B

 [[NSData dataWithContentsOfMappedFile:filename] getBytes:(void*)buf lengt=
h:7]=3B

 if (strncmp(%PDF-=2C buf=2C 5) =3D=3D 0)
 NSLog(@%@ is a PDF file=2C version %c.%c=2C filename=2C buf[5]=2C buf[6=
])=3B
 else
 NSLog(@%@ is not a PDF file=2C filename)=3B

 [pool drain]=3B
 return 0=3B
 }

 sherm--

 --
 Cocoa programming in Perl: http://camelbones.sourceforge.net
  =0A=
_=0A=
Windows Live: Make it easier for your friends to see what you=92re up to on=
 Facebook.=0A=
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/so=
cial-network-basics.aspx?ocid=3DPID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092=
009=
___

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: rangeOfString UTF8 - SOLVED

2009-10-05 Thread Alastair Houghton

On 4 Oct 2009, at 22:45, Steve Cronin wrote:

I had managed to convince myself that there was something about the  
utf8 umlats and all that I wasn't understanding …


FWIW, NSString always acts as if the string is represented in UTF-16  
(even if the underlying representation is something else), so thinking  
about UTF-8 is only ever going to confuse you.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: ScreenSaverView gets instantiated several times

2009-10-05 Thread Gabriel Zachmann
When the user clicks 'Test' in System Preferences, it just  
creates a new instance of your subclass of ScreenSaverView!


Do you really find that fact to be shocking?


Yes, I do.
In particular, because it has a major impact on the way one has to  
design the code.


For instance, if changing the configuration causes some longish  
computations.
I tried pretty hard to hide this from the user, so that after applying  
the changes of the configuration of my screen saver, the user does not  
have to wait for tens of seconds until the screen saver resumes  
operation.


Now, the design I chose to achieve this is useless, because when the  
user clicks 'Test', System Preferences just goes ahead and creates a  
new instance!
Now, it seems that I have no other choice than keep up the modal panel  
until the computations ensuing the config chance are finished ;-(


If only Apple would have said so in big letters at the beginning of  
the docs of ScreenSaverView!


What did you suppose would happen (not that suppositions and  
assumptions are worth much)?


I supposed that the screen saver manager would just call - 
initWithFrame: again.


Extra credit: the user has multiple displays attached, Main screen  
only option is off, and the user clicks the Test button or  
activates your screen saver (hot corner, inactivity). What do you  
expect will happen then?


I assumed it would load(!)  run the screen saver bundle multiple times.
And it's not that this assumption is complete nonsense, is it?


What actually does happen?


With multiple displays I have no idea, since I've got only one display.
But now I assume that it loads the bundle once and creates multiple  
instances ...


it's really just a way to say Yes, you must be prepared for  
multiple instances of your screen saver view to exist simultaneously.



Again, if only Apple would have said that in the docs!

Best regards,
Gabriel.



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: ScreenSaverView gets instantiated several times

2009-10-05 Thread Uli Kusterer

On 05.10.2009, at 10:39, Gabriel Zachmann wrote:
I supposed that the screen saver manager would just call - 
initWithFrame: again.


 -init... methods are only called once on an instance, when it is  
alloced and inited. Calling it several times on the same instance that  
has already been initialized goes against every bit of documentation  
on AppKit, and more importantly, Objective C out there. I think you  
should get yourself a good book about Objective C, it sounds like the  
one you learned from so far omitted some very important aspects of  
Objective C.


Extra credit: the user has multiple displays attached, Main screen  
only option is off, and the user clicks the Test button or  
activates your screen saver (hot corner, inactivity). What do you  
expect will happen then?


I assumed it would load(!)  run the screen saver bundle multiple  
times.

And it's not that this assumption is complete nonsense, is it?


 You cannot load a bundle several times on the Mac. That's because  
you can't unload a bundle. After all, you could be defining string  
constants or custom subclasses in your bundle, and someone in the  
program that loaded your bundle could be retaining one of those  
objects. Unloading it would make your application crash, because  
suddenly the code the class points to or the TEXT section from which  
the constant string came would be gone.


Cheers,
-- Uli Kusterer
The witnesses of TeachText are everywhere...



___

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: Bundle is not using icon or CFBundleIdentifier

2009-10-05 Thread Uli Kusterer

On 04.10.2009, at 06:30, Timothy Reaves wrote:
I have a bundle defined as a document type for an app.  When I build  
one of these bundles, and double-click it, it opens in my app.  All  
well and good.  Except the following.


 Wait, the bundle is defined as the app's document type? Then of  
course the app's Info.plist provides the icon.


1) I have an icns file in my bundle, and have the CFBundleIconFile  
key in the info.plist in the bundle  set to the name of the icon.   
The icns file is in the correct location in the bundle.  But the  
bundle does not display the icon.  It justuses the generic OS icon.


 You need to specify the icon in the CFBundleDocumentTypes of your  
application. Only certain bundles get scanned for an Info.plist.  
Documents can contain whatever they want, so the OS gets all  
information for them from the app that owns them.


Cheers,
-- Uli Kusterer
The witnesses of TeachText are everywhere...



___

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: Keeping NSWindow below all other windows

2009-10-05 Thread Uli Kusterer

On 03.10.2009, at 20:04, PCWiz wrote:
The lowest constant I could find was 0 (NSNormalWindowLevel) and it  
still positioned itself above other windows. Is there a constant for  
-1 ?



 They're CGWindowLevels. Look for kCGDesktopWindowLevel or whatever  
it was called, that's a better choice.


Cheers,
-- Uli Kusterer
The witnesses of TeachText are everywhere...



___

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: ScreenSaverView gets instantiated several times

2009-10-05 Thread Roland King

Yes, I do.
In particular, because it has a major impact on the way one has to  
design the code.


For instance, if changing the configuration causes some longish  
computations.
I tried pretty hard to hide this from the user, so that after applying  
the changes of the configuration of my screen saver, the user does not  
have to wait for tens of seconds until the screen saver resumes  operation.


Now, the design I chose to achieve this is useless, because when the  
user clicks 'Test', System Preferences just goes ahead and creates a  
new instance!
Now, it seems that I have no other choice than keep up the modal panel  
until the computations ensuing the config chance are finished ;-(




Well it's not necessarily useless, you just need to put it elsewhere. 
What were you doing (or trying to do) before when the user changed 
configuration? Were you displaying the 'last version' whilst calculating 
things in the background and then switching to the new version .. which 
would be a bit confusing. Or are you saying the first time the screen 
saver is used you do a bunch of complicated calculations which are slow 
but the results of which you cache in the instance of your screen saver 
class and when you change the config a bit you can recalculate the new 
values quite rapidly? If it's the latter, you could store the 'basic' 
calculations in static variables in your class, calculate them once and 
then have every instance of the screen saver use them.


___

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


grouping undo across method calls in CoreData

2009-10-05 Thread Jim Thomason
I've got a CoreData document based application, and I'm trying to undo
my object creation in a single step.

Here's the issue - I'm storing an ordered index on my entities so I
can keep track of the order of creation. To do this, upon object
creation, I yank out the highest order parameter for my entity, add 1
to it, and use it to set up my ordered column. But the issue is, in
order to do this and make it work well, I have to put the code to
create the ordered column in a separate selector that I hit using
performSelector:, as such:

-(void) awakeFromInsert {
  [super awakeFromInsert];
  [self performSelector:@selector(createOrder:) withObject:nil afterDelay:0];
}

-(void) createOrder {
  int highOrderIndex = [self getHighestIndexSomeHow];
  [self setValue:[NSNumber numberWithInt:highOrderIndex] forKey:@ordered];
}

If I were to just directly call [self createOrder]; in
-awakeFromInsert, I'd end up with a duplicate entry in my
NSArrayController (though not in the context). AFAIU, that's because I
can't go out and perform queries in CoreData during awakeFromInsert,
and this is the acceptable workaround.

But the problem is, if the user undoes the creation of a new object,
two undos are required. The first one will bump the ordered parameter
back down to zero, and then the second one will actually drop the
object. It's fairly confusing since the ordered parameter isn't
displayed to the user, so it appears that the undo does nothing the
first time, but then works the second.

Even worse - potentially they could hit undo once and end up with an
object in a quasi-state with an invalid order parameter.


How can I deal with this? I've been trying various combinations of
begin/endUndoGrouping, and even turning on and off groupsByEvent, but
I haven't hit the magic incantation yet.

I also tried popping all references to the newly created object off
the stack and using prepareWithInvocationTarget: with a method that
just drops the object:

...
//at the end of createOrder up above
[undoManager removeAllActionsWithTarget:self];
[[undoManager prepareInvocationWithTarget:self] negateCreation];
}

-(void) negateCreation {
  [[self managedObjectContext] deleteObject:self];
}

That gets me closer - it actually does drop the object immediately
upon undo, but I still have an additional undo state on the stack.
That is, I can hit undo once and delete my object entirely, but then I
can hit undo a second time, and seemingly nothing happens. At that
point, I can hit redo twice, and two additional objects will appear.
One with a valid order, and one without. I'm not sure if this approach
is a dead-end or not.

Can anyone point me in the right direction?

-Jim
___

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


GLSLBasicsCocoaDL sample code

2009-10-05 Thread McLaughlin, Michael P.
I downloaded the sample code

http://developer.apple.com/mac/library/samplecode/GLSLBasicsCocoaDL/index.ht
ml

It built and ran under Mac OS 10.5.8 and Xcode 3.1.3.  However, the result
showed a *black*, rotating object on a not-quite-so-black background.

I'm guessing that it should not look like that, yes?

Can anyone confirm?  Am I missing something?  I was hoping to learn about
Cocoa+OpenGL+shaders from this demo :-(

-- 
Mike McLaughlin

___

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: grouping undo across method calls in CoreData

2009-10-05 Thread Stamenkovic Florijan

Jim,

An interesting situation. I do not have anything definitive, but just  
some ideas and comments


On Oct 05, 2009, at 09:10, Jim Thomason wrote:


-(void) createOrder {
 int highOrderIndex = [self getHighestIndexSomeHow];
 [self setValue:[NSNumber numberWithInt:highOrderIndex]  
forKey:@ordered];

}


Hm, do operations using primitive accessors also get registered on the  
undo stack? If not, you could maybe use that approach, so the setting  
of the ordered value would not ever get registered?


Or maybe you could disable / enabled undo registration in createOrder  
like:


NSUndoManager* um = ...
[um disableUndoCreation];
int highOrderIndex = [self getHighestIndexSomeHow];
[self setValue:[NSNumber numberWithInt:highOrderIndex]  
forKey:@ordered];

[um enableUndoRegistration];

Have you tried something like this? From what I understand you don't  
need to have the change of the ordered value on the undo stack, and  
either of these could make that happen...



...

How can I deal with this? I've been trying various combinations of
begin/endUndoGrouping, and even turning on and off groupsByEvent, but
I haven't hit the magic incantation yet.


I guess it is tricky dealing with begin/endUndoGrouping when using  
delayed invoking. Still, AFAIK it should work. Can you elaborate on  
why it does not?



I also tried popping all references to the newly created object off
the stack and using prepareWithInvocationTarget: with a method that
just drops the object:

...
//at the end of createOrder up above
[undoManager removeAllActionsWithTarget:self];
[[undoManager prepareInvocationWithTarget:self] negateCreation];
}

-(void) negateCreation {
 [[self managedObjectContext] deleteObject:self];
}

That gets me closer - it actually does drop the object immediately
upon undo, but I still have an additional undo state on the stack.


Which extra undo state do you have? What is the registered undo that  
does nothing?



That is, I can hit undo once and delete my object entirely, but then I
can hit undo a second time, and seemingly nothing happens. At that
point, I can hit redo twice, and two additional objects will appear.
One with a valid order, and one without. I'm not sure if this approach
is a dead-end or not.


No idea... The concept makes sense though.

HTH,
F
___

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


[Xgrid] GridMandelbrot Sample gone?

2009-10-05 Thread Stefan Wolfrum

Hi all,

I wanted to dive into Xgrid and read that the Mandelbrot sample would  
be a good start and that it's located at /Developer/Examples/Xgrid/ 
GridMandelbrot.


However, after installing the lastest Xcode dmg (3.2) on my 10.6.1  
system I couldn't find such a folder. :-(


Neither could I find this sample code at developer.apple.com. :-((

Any help/hints?

Thanks a lot,
Stefan.

-
Von meinem iPhone 3G gesendet. :-)
___

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


[MEETING] Toronto Area Cocoa WebObjects Developer Group - October 13

2009-10-05 Thread Karl Moskowski
The next meeting of tacow/Toronto CocoaHeads will be held on Tuesday,   
October 13 at 6:30 PM at Ryerson University.


After a C4 recap, Jim Dovey wlll be talking about GCD and blocks.

Details and directions are available at http://groups.google.com/group/tacow 
.



Karl Moskowski kolpa...@voodooergonomics.com
Voodoo Ergonomics Inc. http://voodooergonomics.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

How to manage creation of an unknown number of windows?

2009-10-05 Thread Rui Pacheco
Hi,
I've a class that extends NSWindowController and that class lists an unknown
number of entries. Double clicking on an entry will open a window where it
will be possible to interact with the real world object that entry
represents.

I plan to make the editing window extends NSDocument but I am still at a
loss on something: how do I make sure manage the creation of an unknown
number of windows on my app?

I'm thinking about creating an instance of NSDictionary and saving each
newly created window on it, removing from the dictionary when the window is
closed. What would be the best way to manage an unknown number of windows?

-- 
Best regards,
Rui Pacheco
___

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: ScreenSaverView gets instantiated several times

2009-10-05 Thread Michael Babin


On Oct 5, 2009, at 3:39 AM, Gabriel Zachmann wrote:

When the user clicks 'Test' in System Preferences, it just  
creates a new instance of your subclass of ScreenSaverView!


Do you really find that fact to be shocking?


Yes, I do.


[snip]

If only Apple would have said so in big letters at the beginning of  
the docs of ScreenSaverView!


The documentation on creating screen savers is pretty sparse, no  
argument here. There are also sample screen savers available from the  
developer site, as well as other sources that can help you understand  
more about the environment you're entering. The absence of documented  
details may lead you to making some assumptions about how your screen  
saver objects are created and the environment in which they operate,  
but it is important to test those assumptions before you get too far  
down the road.


I can see being surprised when an assumption proves to be  
inaccurate. I would reserve shocked for situations where the  
documentation is inaccurate or the actual implementation seems to be  
in contradiction with patterns found in other frameworks.


What did you suppose would happen (not that suppositions and  
assumptions are worth much)?


I supposed that the screen saver manager would just call - 
initWithFrame: again.


As Uli pointed out previously, calling -initWithFrame: (or any init  
method) multiple times on one object is not a pattern you find in  
other classes/frameworks. You might have assumed a call to -setFrame:,  
if you assumed the same view was being used and resized, but that  
would be easy to test to verify your assumption.


Extra credit: the user has multiple displays attached, Main screen  
only option is off, and the user clicks the Test button or  
activates your screen saver (hot corner, inactivity). What do you  
expect will happen then?


I assumed it would load(!)  run the screen saver bundle multiple  
times.

And it's not that this assumption is complete nonsense, is it?


Depending upon your knowledge of bundles, it wouldn't be an outrageous  
assumption to make. As Uli pointed out, there are reasons this isn't  
the case. This assumption would again be something important to test  
early in development.



What actually does happen?


With multiple displays I have no idea, since I've got only one  
display.
But now I assume that it loads the bundle once and creates  
multiple instances ...


Yes, one ScreenSaverView per display. Admittedly, this is a tougher  
assumption to test if you don't have access to a machine with multiple  
displays.


it's really just a way to say Yes, you must be prepared for  
multiple instances of your screen saver view to exist  
simultaneously.



Again, if only Apple would have said that in the docs!


Here's another one (newly introduced) that isn't in the docs (as far  
as I know): to run on Snow Leopard on a machine whose processor is  
capable of running in 64-bit mode (all currently shipping Macs), you  
will need a 64-bit version of your screen saver with GC supported. To  
run on Leopard and earlier, as well as on Snow Leopard on machines  
whose processor is not capable of running in 64-bit mode (Core Solo,  
Core Duo), you will need a 32-bit version of your screen saver with GC  
off.


Good luck!

- 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


How to prevent the user from clicking 'Test' in Screen Savers (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread Gabriel Zachmann
Thanks a lot for all the responses, and sorry for bothering you again  
with this.


The problem I'm having is the following: is there an elegant way to  
prevent the user from clicking the 'Test' button in the Screen Savers  
panel in System Preferences?


The reason why I'm asking: when the user changes the configuration in  
my screen saver, I start a Spotlight query that could take up to 30   
seconds (about 10 seconds for the initial phase of the search itself,  
plus 20 seconds for retrieveing the results from the query).

The results of that query then change what the screensaver renders.

Therefore, I would like to give the user some feedback that the query  
is still in progress *AND* I would like to prevent the user from  
clicking that 'Test' button in System Preferences' Screensaver pane.


Right now I'm using an asynchronous NSMetadataQuery, which seems to  
work, except that the only way to prevent the user from clicking that  
'Test' button I found was to keep the configuration sheet up until the  
search has completely finished.


IMHO, this doesn't look very elegant ;-/

Any ideas will be highly appreciated.

Best regards,
Gabriel.




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 prevent the user from clicking 'Test' in Screen Savers (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread Jack Carbaugh
Why not just fake it ... in other words ... since it's a test, just  
supply some generic data for the screen saver to display. Then, when  
they truly activate it, you provide the real data.


Seems that's what others have done, that i've experienced.

Not knowing for sure or not, but i believe you can determine whether  
the button was clicked to test or otherwise.


Jack


On Oct 5, 2009, at 11:45 AM, Gabriel Zachmann wrote:

Thanks a lot for all the responses, and sorry for bothering you  
again with this.


The problem I'm having is the following: is there an elegant way to  
prevent the user from clicking the 'Test' button in the Screen  
Savers panel in System Preferences?


The reason why I'm asking: when the user changes the configuration  
in my screen saver, I start a Spotlight query that could take up to  
30  seconds (about 10 seconds for the initial phase of the search  
itself, plus 20 seconds for retrieveing the results from the query).

The results of that query then change what the screensaver renders.

Therefore, I would like to give the user some feedback that the  
query is still in progress *AND* I would like to prevent the user  
from clicking that 'Test' button in System Preferences' Screensaver  
pane.


Right now I'm using an asynchronous NSMetadataQuery, which seems to  
work, except that the only way to prevent the user from clicking  
that 'Test' button I found was to keep the configuration sheet up  
until the search has completely finished.


IMHO, this doesn't look very elegant ;-/

Any ideas will be highly appreciated.

Best regards,
Gabriel.


___

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/intrntmn%40aol.com

This email sent to intrn...@aol.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 prevent the user from clicking 'Test' in Screen Savers (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread Michael Babin

On Oct 5, 2009, at 10:45 AM, Gabriel Zachmann wrote:

The problem I'm having is the following: is there an elegant way to  
prevent the user from clicking the 'Test' button in the Screen  
Savers panel in System Preferences?


The reason why I'm asking: when the user changes the configuration  
in my screen saver, I start a Spotlight query that could take up to  
30  seconds (about 10 seconds for the initial phase of the search  
itself, plus 20 seconds for retrieveing the results from the query).

The results of that query then change what the screensaver renders.

Therefore, I would like to give the user some feedback that the  
query is still in progress *AND* I would like to prevent the user  
from clicking that 'Test' button in System Preferences' Screensaver  
pane.


Right now I'm using an asynchronous NSMetadataQuery, which seems to  
work, except that the only way to prevent the user from clicking  
that 'Test' button I found was to keep the configuration sheet up  
until the search has completely finished.


I don't know of a way to disable the Test button, but I wonder if  
that's the right approach.


When the user changes the configuration of your screen saver (assuming  
this is done by selecting the Options button and changing the  
settings presented), what do you show in the Preview pane? Perhaps  
displaying some static view with a progress indicator in your screen  
saver view would be a better option?


- 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


Screen saver for Snow Leopard and previous OS (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread Gabriel Zachmann
As Uli pointed out previously, calling -initWithFrame: (or any init  
method) multiple times on one object is not a pattern you find in  
other classes/frameworks. You might have assumed a call to -setFrame:,


Sorry, that was what I meant, of course (setFrameSize is the name, I  
think).



if you assumed the same view was being used and resized, but that  
would be easy to test to verify your assumption.


Yes, I stand corrected.

On the other hand, I think, testing assumptions about an API is not  
The Right Way, because
1. you can never be certain whether you have tested all of your  
(possibly subconscious) assumptions; and,
2. if it's not written in the doc, an assumption might always become  
invalid, no matter how often you tested it, because the developers of  
the framework can always change their minds.


Granted, in my case it probably won't hurt, if the developers change  
their minds and in the future decide to *not* instantiate  
ScreenSaverView multiple times on the same display, provided my code  
is multiple-instance-safe 


Here's another one (newly introduced) that isn't in the docs (as far  
as I know): to run on Snow Leopard on a machine whose processor is  
capable of running in 64-bit mode (all currently shipping Macs), you  
will need a 64-bit version of your screen saver with GC supported.


Thank you so much for pointing out this one to me!

Do I need to change anything in my code for that?

To run on Leopard and earlier, as well as on Snow Leopard on  
machines whose processor is not capable of running in 64-bit mode  
(Core Solo, Core Duo), you will need a 32-bit version of your screen  
saver with GC off.



So, is there any way to compile the screen saver into *one* bundle (or  
exec) such that it runs under SL with 64-bit proc's *and* 10.5/Intel ?


Best regards,
Gabriel.




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: Screen saver for Snow Leopard and previous OS (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread David Duncan

On Oct 5, 2009, at 9:24 AM, Gabriel Zachmann wrote:

So, is there any way to compile the screen saver into *one* bundle  
(or exec) such that it runs under SL with 64-bit proc's *and* 10.5/ 
Intel ?



You need to build a universal binary (the default Xcode universal  
config of PPC/i386/x86_64 should suffice) and ensure that Garbage  
Collection is turned on for the 64-bit slice. Simplest way is to copy  
 paste the following into your Xcode configuration:


ARCHS = x86_64 $(ARCHS_STANDARD_32_BIT)
MACOSX_DEPLOYMENT_TARGET = 10.5
SDKROOT = macosx10.6
GCC_ENABLE_OBJC_GC = unsupported
GCC_ENABLE_OBJC_GC[sdk=macosx10.6][arch=x86_64] = supported
--
David Duncan
Apple DTS Animation and Printing

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


NSTableView: no display until header clicked

2009-10-05 Thread David Hirsch
My window has two NSTableViews.  Each has two columns, each of which  
is bound to a field in Phases, an NSArrayController.


When my window is displayed, I calculate my model, and the  
NSTableViews show the headers, but blank data cells.  However, when I  
click the header of one table, all four columns get populated with  
data.  As far as I can tell (I've set breakpoints), this happens  
without calling any of my code.  Note that this only works if I click  
a text-based column.  If I click the column with image cells, I get no  
response, so presumably the TableView is trying to sort the data on  
the click, and somehow straightens out the previously mucked-up  
binding at that time.


I'm posting here without code to see if anybody has experienced this  
before.  It will be a major undertaking to reduce this problem to a  
post-able amount of code.


I've tried making Phases (the NSArrayController) the data source and  
delegate in addition to the column bindings, without solving the  
problem.  I've tried adding another NSTableView and binding it to  
other columns to see if I had done it wrong the first time.  That did  
not help.  The fact that the bindings do work after the click seems to  
suggest that the binding setup is okay.


Thanks in advance,
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: NSTableView: no display until header clicked

2009-10-05 Thread Volker in Lists

Hi,

without knowing how you add objects to the ArrayController - and when,  
and without knowing what and how is bound exactly - guessing is most  
that can be done.


It seems the bindings are okay from the beginning, but the changes to  
the ArrayControllers content are only observed when the sortOrder is  
changed. Maybe you need only a single [NSArrayController  
rearrangeObjects] call or similar.


Volker

Am 05.10.2009 um 18:32 schrieb David Hirsch:

My window has two NSTableViews.  Each has two columns, each of which  
is bound to a field in Phases, an NSArrayController.


When my window is displayed, I calculate my model, and the  
NSTableViews show the headers, but blank data cells.  However, when  
I click the header of one table, all four columns get populated with  
data.  As far as I can tell (I've set breakpoints), this happens  
without calling any of my code.  Note that this only works if I  
click a text-based column.  If I click the column with image cells,  
I get no response, so presumably the TableView is trying to sort the  
data on the click, and somehow straightens out the previously mucked- 
up binding at that time.


I'm posting here without code to see if anybody has experienced this  
before.  It will be a major undertaking to reduce this problem to a  
post-able amount of code.


I've tried making Phases (the NSArrayController) the data source and  
delegate in addition to the column bindings, without solving the  
problem.  I've tried adding another NSTableView and binding it to  
other columns to see if I had done it wrong the first time.  That  
did not help.  The fact that the bindings do work after the click  
seems to suggest that the binding setup is okay.


Thanks in advance,
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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de


___

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: NSTableView: no display until header clicked

2009-10-05 Thread David Hirsch
Thanks, Volker.  rearrangeObjects did work, but I don't understand why  
that call should be necessary.  If anybody out there wants to educate  
me, I'd appreciate it.


(More info: I have my ArrayController in IB bound to an array (phases)  
of File's Owner (which is my NSDocument subclass).  In the document's  
init method, I make phases an empty NSMutableArray, and in the  
document's windowControllerDidLoadNib method, I populate that array  
with data.)


-Dave

On Oct 5, 2009, at 9:40 AM, Volker in Lists wrote:


Hi,

without knowing how you add objects to the ArrayController - and  
when, and without knowing what and how is bound exactly - guessing  
is most that can be done.


It seems the bindings are okay from the beginning, but the changes  
to the ArrayControllers content are only observed when the sortOrder  
is changed. Maybe you need only a single [NSArrayController  
rearrangeObjects] call or similar.


Volker

Am 05.10.2009 um 18:32 schrieb David Hirsch:

My window has two NSTableViews.  Each has two columns, each of  
which is bound to a field in Phases, an NSArrayController.


When my window is displayed, I calculate my model, and the  
NSTableViews show the headers, but blank data cells.  However, when  
I click the header of one table, all four columns get populated  
with data.  As far as I can tell (I've set breakpoints), this  
happens without calling any of my code.  Note that this only works  
if I click a text-based column.  If I click the column with image  
cells, I get no response, so presumably the TableView is trying to  
sort the data on the click, and somehow straightens out the  
previously mucked-up binding at that time.


I'm posting here without code to see if anybody has experienced  
this before.  It will be a major undertaking to reduce this problem  
to a post-able amount of code.


I've tried making Phases (the NSArrayController) the data source  
and delegate in addition to the column bindings, without solving  
the problem.  I've tried adding another NSTableView and binding it  
to other columns to see if I had done it wrong the first time.   
That did not help.  The fact that the bindings do work after the  
click seems to suggest that the binding setup is okay.


Thanks in advance,
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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de






Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf




___

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


wait for the event?

2009-10-05 Thread jon
i have a webView loading,   and need to wait until it is finished  
loading...


so far i've set up this notification in the wakeFromNib:

NSNotificationCenter *center = [NSNotificationCenter  
defaultCenter];
[center addObserver:self  
selector:@selector(webViewProgressFinished:)   
name:WebViewProgressFinishedNotification object:offScreenWebView];


and then i have a selector/method like so,  with nothing in it,   
because i'm not sure what to put in it yet...


- (void)webViewProgressFinished:(NSNotification*)notification
{
NSInteger i = 1;
}

and then i have a the main method that is running along,  and at a  
certain point below i need to wait for that notification to fire... Or  
that method to fire... same thing...
i need a little push in the correct direction,  because i really am  
stumped in whether to use some sort of NSRunLoop, or NSEvent,  or what  
would it be?


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
   	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


[[NSRunLoop currentRunLoop] runUntil... we get that darn message?];

here is where i need to wait until i get that message, or that that  
method is fired...
I seem to have the selector firing correctly i believe ...   but i  
don't know how to wait until it fires?

that is what i have so far...
and help would be appreciated greatly...

thanks,
Jon.


___

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: grouping undo across method calls in CoreData

2009-10-05 Thread Quincey Morris

On Oct 5, 2009, at 06:10, Jim Thomason wrote:


I've got a CoreData document based application, and I'm trying to undo
my object creation in a single step.

Here's the issue - I'm storing an ordered index on my entities so I
can keep track of the order of creation. To do this, upon object
creation, I yank out the highest order parameter for my entity, add 1
to it, and use it to set up my ordered column. But the issue is, in
order to do this and make it work well, I have to put the code to
create the ordered column in a separate selector that I hit using
performSelector:, as such:

-(void) awakeFromInsert {
 [super awakeFromInsert];
 [self performSelector:@selector(createOrder:) withObject:nil  
afterDelay:0];

}

-(void) createOrder {
 int highOrderIndex = [self getHighestIndexSomeHow];
 [self setValue:[NSNumber numberWithInt:highOrderIndex]  
forKey:@ordered];

}


You might consider a different approach. Instead of trying to bend  
Core Data undo to your will, you might be able to finesse the  
situation by preparing all the information for your object creation  
*first*, then creating the object in a single event cycle (and hence  
undo action).


Thus, calculate the highest index first, which may involve zero or one  
or any number of performSelector...afterDelay calls, and create the  
object when you're done.


Alternately, you might pre-calculate the *next* highest index *after*  
the creation of a new object.


In any scenario (including the one you originally described), there  
does seem to be a theoretical possibility that a new request to create  
an object may arrive in the middle of your sequence of delayed  
selectors. You'd probably want to consider how to handle that situation.



___

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: NSTableView: no display until header clicked

2009-10-05 Thread Volker in Lists

Hi,

 - have you bound contentArray of the ArrayController in IB?
 - how do you populate with data?

In general: Bindings work by the magic of KVO (key value observing).  
This means, that whenever calls to KVO compliant setters are made, in  
the background willchangevalueforkey/didchangevalueforkey messages are  
sent. That way the UI is informed of changes. Rearrangecontet does  
that for the content value of a controller... so you seemed to have  
populated the array controller in a non KVO way... but still, w/o code  
not to be discussed.


Cheers,
Volker



Am 05.10.2009 um 18:47 schrieb David Hirsch:

Thanks, Volker.  rearrangeObjects did work, but I don't understand  
why that call should be necessary.  If anybody out there wants to  
educate me, I'd appreciate it.


(More info: I have my ArrayController in IB bound to an array  
(phases) of File's Owner (which is my NSDocument subclass).  In the  
document's init method, I make phases an empty NSMutableArray, and  
in the document's windowControllerDidLoadNib method, I populate that  
array with data.)


-Dave

On Oct 5, 2009, at 9:40 AM, Volker in Lists wrote:


Hi,

without knowing how you add objects to the ArrayController - and  
when, and without knowing what and how is bound exactly - guessing  
is most that can be done.


It seems the bindings are okay from the beginning, but the changes  
to the ArrayControllers content are only observed when the  
sortOrder is changed. Maybe you need only a single  
[NSArrayController rearrangeObjects] call or similar.


Volker

Am 05.10.2009 um 18:32 schrieb David Hirsch:

My window has two NSTableViews.  Each has two columns, each of  
which is bound to a field in Phases, an NSArrayController.


When my window is displayed, I calculate my model, and the  
NSTableViews show the headers, but blank data cells.  However,  
when I click the header of one table, all four columns get  
populated with data.  As far as I can tell (I've set breakpoints),  
this happens without calling any of my code.  Note that this only  
works if I click a text-based column.  If I click the column with  
image cells, I get no response, so presumably the TableView is  
trying to sort the data on the click, and somehow straightens out  
the previously mucked-up binding at that time.


I'm posting here without code to see if anybody has experienced  
this before.  It will be a major undertaking to reduce this  
problem to a post-able amount of code.


I've tried making Phases (the NSArrayController) the data source  
and delegate in addition to the column bindings, without solving  
the problem.  I've tried adding another NSTableView and binding it  
to other columns to see if I had done it wrong the first time.   
That did not help.  The fact that the bindings do work after the  
click seems to suggest that the binding setup is okay.


Thanks in advance,
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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de






Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf






___

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


NSToolbarGroupItem not showing labels of subitems

2009-10-05 Thread Brad Gibbs

Hi,

I'm trying to create a toolbar with NSSegmentedControl as a custom  
view for an NSToolbarItemGroup in 10.6, but I can't get the labels for  
the subitems to appear.


I added an NSSegmentedControl to the toolbar item in IB and set images  
in the segmented control in IB.  I did not give the NSToolbarGroupItem  
a label.


I added the following code to my appDelegate (oProjectsGroup is an  
IBOutlet, which is bound to the NSToolbarGroupItem in IB):


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
	NSToolbarItem *item1 = [[[NSToolbarItem alloc]  
initWithItemIdentifier:@Item1] autorelease];
	NSToolbarItem *item2 = [[[NSToolbarItem alloc]  
initWithItemIdentifier:@Item2] autorelease];

[item1 setImage:[NSImage imageNamed:@Activities]];
[item2 setImage:[NSImage imageNamed:@Projects]];
[item1 setLabel:@Prev];
[item2 setLabel:@Next];

	[oProjectsGroup setSubitems:[NSArray arrayWithObjects:item1, item2,  
nil]];


for (id item in [oProjectsGroup subitems]) {
NSLog(@label is %@, [item label]);
}
}

The console displays the labels, so, apparently, the labels are being  
set, but they do not appear beneath their respective segments in the  
running app.


I've looked through the documentation and a list thread both of which  
seem to indicate that my code should be working


Any help would be appreciated.


Thanks.

Brad
___

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: NSTableView: no display until header clicked

2009-10-05 Thread Quincey Morris

On Oct 5, 2009, at 09:47, David Hirsch wrote:

(More info: I have my ArrayController in IB bound to an array  
(phases) of File's Owner (which is my NSDocument subclass).  In the  
document's init method, I make phases an empty NSMutableArray, and  
in the document's windowControllerDidLoadNib method, I populate that  
array with data.)


No one can tell you the answer for sure without seeing code, but the  
likelihood is high that you're not populating the array KVO  
compliantly. Thus, the array is empty when the table's bindings are  
established, and there's no KVO notification ever sent to tell it  
otherwise, until you do something like click on a column header.



___

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: NSTableView: no display until header clicked

2009-10-05 Thread Stamenkovic Florijan

On Oct 05, 2009, at 13:08, Volker in Lists wrote:

so you seemed to have populated the array controller in a non KVO  
way... but still, w/o code not to be discussed.


I think that is the problem. If you bind the content of an  
NSArrayController to someObject.variable, then the controller will be  
notified of a change in it's content only if you assign a different  
object (NSArray) to the variable, but NOT if you manipulate the  
contents of the array. Instead, you need to manipulate the contents of  
the variable via the controller. So, instead of populating the mutable  
array directly in your windowControllerDidLoadNib method, try  
populating it via the controller.


HTH,
F
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread David Hirsch
That's right on the money:  The array was indeed bound to the  
contentArray in IB (otherwise it would never have been able to show  
any data), but I needed to surround my populating of the array with:


[phaseController willChangeValueForKey:@arrangedObjects]

and

[phaseController didChangeValueForKey:@arrangedObjects];

Thanks,
Dave

On Oct 5, 2009, at 10:08 AM, Volker in Lists wrote:


Hi,

- have you bound contentArray of the ArrayController in IB?
- how do you populate with data?

In general: Bindings work by the magic of KVO (key value observing).  
This means, that whenever calls to KVO compliant setters are made,  
in the background willchangevalueforkey/didchangevalueforkey  
messages are sent. That way the UI is informed of changes.  
Rearrangecontet does that for the content value of a controller...  
so you seemed to have populated the array controller in a non KVO  
way... but still, w/o code not to be discussed.


Cheers,
Volker



Am 05.10.2009 um 18:47 schrieb David Hirsch:

Thanks, Volker.  rearrangeObjects did work, but I don't understand  
why that call should be necessary.  If anybody out there wants to  
educate me, I'd appreciate it.


(More info: I have my ArrayController in IB bound to an array  
(phases) of File's Owner (which is my NSDocument subclass).  In the  
document's init method, I make phases an empty NSMutableArray, and  
in the document's windowControllerDidLoadNib method, I populate  
that array with data.)


-Dave

On Oct 5, 2009, at 9:40 AM, Volker in Lists wrote:


Hi,

without knowing how you add objects to the ArrayController - and  
when, and without knowing what and how is bound exactly - guessing  
is most that can be done.


It seems the bindings are okay from the beginning, but the changes  
to the ArrayControllers content are only observed when the  
sortOrder is changed. Maybe you need only a single  
[NSArrayController rearrangeObjects] call or similar.


Volker

Am 05.10.2009 um 18:32 schrieb David Hirsch:

My window has two NSTableViews.  Each has two columns, each of  
which is bound to a field in Phases, an NSArrayController.


When my window is displayed, I calculate my model, and the  
NSTableViews show the headers, but blank data cells.  However,  
when I click the header of one table, all four columns get  
populated with data.  As far as I can tell (I've set  
breakpoints), this happens without calling any of my code.  Note  
that this only works if I click a text-based column.  If I click  
the column with image cells, I get no response, so presumably the  
TableView is trying to sort the data on the click, and somehow  
straightens out the previously mucked-up binding at that time.


I'm posting here without code to see if anybody has experienced  
this before.  It will be a major undertaking to reduce this  
problem to a post-able amount of code.


I've tried making Phases (the NSArrayController) the data source  
and delegate in addition to the column bindings, without solving  
the problem.  I've tried adding another NSTableView and binding  
it to other columns to see if I had done it wrong the first  
time.  That did not help.  The fact that the bindings do work  
after the click seems to suggest that the binding setup is okay.


Thanks in advance,
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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de






Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf










Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf




___

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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Volker in Lists

Hi,

maybe it works even without these two lines - how are you populating  
the array controller in code ?



Cheers,
Volker

Am 05.10.2009 um 19:19 schrieb David Hirsch:

That's right on the money:  The array was indeed bound to the  
contentArray in IB (otherwise it would never have been able to show  
any data), but I needed to surround my populating of the array with:


[phaseController willChangeValueForKey:@arrangedObjects]

and

[phaseController didChangeValueForKey:@arrangedObjects];

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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread David Hirsch
I (now) realize that I could use the arrayController to populate the  
array, but retaining my direct array manipulation and doing the KVO  
notification myself is less rewriting, and in fact  entails fewer KVO  
calls.

-Dave


On Oct 5, 2009, at 10:21 AM, Volker in Lists wrote:



maybe it works even without these two lines - how are you populating  
the array controller in code ?



Am 05.10.2009 um 19:19 schrieb David Hirsch:

That's right on the money:  The array was indeed bound to the  
contentArray in IB (otherwise it would never have been able to show  
any data), but I needed to surround my populating of the array with:


[phaseController willChangeValueForKey:@arrangedObjects]

and

[phaseController didChangeValueForKey:@arrangedObjects];




___

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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Kyle Sluder

On Oct 5, 2009, at 10:26 AM, David Hirsch dhir...@mac.com wrote:

I (now) realize that I could use the arrayController to populate the  
array, but retaining my direct array manipulation and doing the KVO  
notification myself is less rewriting, and in fact  entails fewer  
KVO calls.


This seems backwards. You typically don't use an array controller to  
fill an array.


--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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread David Hirsch

NSArrayController has things like insert: or add:
-Dave

On Oct 5, 2009, at 10:36 AM, Kyle Sluder wrote:


On Oct 5, 2009, at 10:26 AM, David Hirsch dhir...@mac.com wrote:

I (now) realize that I could use the arrayController to populate  
the array, but retaining my direct array manipulation and doing the  
KVO notification myself is less rewriting, and in fact  entails  
fewer KVO calls.


This seems backwards. You typically don't use an array controller to  
fill an array.


--Kyle Sluder




Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf




___

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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Kyle Sluder
On Mon, Oct 5, 2009 at 10:39 AM, David Hirsch dhir...@mac.com wrote:
 NSArrayController has things like insert: or add:

Okay... not sure what that has to do with anything.
NSArrayController's content is usually bound to an ordered property
(itself often an NSArray) and is usually used to provide data for UI
elements.

--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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Stamenkovic Florijan


On Oct 05, 2009, at 14:05, Kyle Sluder wrote:


On Mon, Oct 5, 2009 at 10:39 AM, David Hirsch dhir...@mac.com wrote:

NSArrayController has things like insert: or add:


Okay... not sure what that has to do with anything.
NSArrayController's content is usually bound to an ordered property
(itself often an NSArray) and is usually used to provide data for UI
elements.


That is one of it's uses. It is also commonly used to add, insert and  
delete objects in it's content. In a KVO friendly way.


F
___

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: grouping undo across method calls in CoreData

2009-10-05 Thread Fritz Anderson

On 5 Oct 2009, at 8:10 AM, Jim Thomason wrote:


-(void) awakeFromInsert {
 [super awakeFromInsert];
 [self performSelector:@selector(createOrder:) withObject:nil  
afterDelay:0];

}

-(void) createOrder {
 int highOrderIndex = [self getHighestIndexSomeHow];
 [self setValue:[NSNumber numberWithInt:highOrderIndex]  
forKey:@ordered];

}


Important thing, though not responsive to your point:

If you mean your first method to refer to your second, you should  
specify @selector(createOrder) (a method taking no arguments, like the  
one you show), not @selector(createOrder:) (a method taking one  
argument). Colons matter.


— F

--
Fritz Anderson -- Xcode 3 Unleashed: Headed for its third printing -- http://x3u.manoverboard.org/ 



___

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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Kyle Sluder
On Mon, Oct 5, 2009 at 11:16 AM, Stamenkovic Florijan flor...@mac.com wrote:
 That is one of it's uses. It is also commonly used to add, insert and delete
 objects in it's content. In a KVO friendly way.

Okay perhaps I misunderstood.

If you have an array or another ordered property, you typically don't
go backwards through an NSArrayController to manipulate it.  This
seems like what David had noticed he could do.

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


Storing UInt64 in a Core Data attribute ?

2009-10-05 Thread Guillaume Laurent

Hi all,

Apparently, Core Data only handles signed int types for attributes. I  
need to store UInt64 ones (MIDITimeStamp, more precisely), and to show  
these in a table column. Of course the displayed values are signed,  
some negative some not. Google didn't bring anything useful on that  
topic, has anybody been confronted with this problem ? What would be  
the best solution ?


Thanks,

--
Guillaume
http://telegraph-road.org





___

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: Address Book-style editing

2009-10-05 Thread Ben Lachman

Brad:

My app, SousChef, does this.  The way adress book and SousChef do it  
is to use a customized textview.  You add custom attributes to mark  
the different fields (textview's NSTextStorage is a subclass of  
NSAttributedString).  Then you control selection based on these  
attributes when in edit mode.  When a field is selected, you just draw  
a editing box + drop shadow around the full range of the field.  To  
get the plus/minus buttons (which I'm actually kind of thinking about  
removing from SousChef), you can stick them in a customized rulerview  
as markers and show/hide the ruler based on editing mode.


Hope this helps,
-Ben

On Oct 1, 2009, at 1:21 PM, Brad Gibbs wrote:


Hi,

I'm trying to re-create Address Book's editing style - if a user  
pushes a button labeled Edit, subsequent clicks on a label bring up  
what looks like a separate view for the new information.  Clicking  
return after editing commits the edit and moves on to the next field.


I'd also like to be able to have the plus and minus signs next to  
phone numbers, email fields, etc.


I don't see a stock Cocoa / AppKit way to do this.  Does anyone know  
of a public framework that mimics this behavior?  Short of that, any  
ideas on how to re-create the editing field that pops up?



Thanks.

Brad
___

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

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


--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009





--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



___

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: Checking whether a file is a genuine PDF file

2009-10-05 Thread Sean McBride
On 10/5/09 7:49 AM, Squ Aire said:

Thanks for the reply. However=2C of course a file can start with %PDF witho=
ut being a valid PDF file (and not openable by Preview).

I think I found an acceptable way of doing my thing. Just include the Quart=
z framework and do

PDFDocument *pdfDoc =3D [[PDFDocument alloc] initWithURL:fileURL]=3B

There is another case to consider: valid PDF files that are not
supported by Preview/Quartz.  For example, pdf files with 3D content
display fine in Acrobat Reader but not in Preview.

--

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: NSTableView: no display until header clicked

2009-10-05 Thread Stuart Malin


On Oct 5, 2009, at 1:13 PM, David Hirsch dhir...@mac.com wrote:


Thanks, Volker.  rearrangeObjects did work, but I don't understand why
that call should be necessary.  If anybody out there wants to educate
me, I'd appreciate it.

(More info: I have my ArrayController in IB bound to an array (phases)
of File's Owner (which is my NSDocument subclass).  In the document's
init method, I make phases an empty NSMutableArray, and in the
document's windowControllerDidLoadNib method, I populate that array
with data.)


Dave,

An NSMutableArray is not KVO compliant for addition and deletion of  
entries. You must either provide manual notification or create a class  
with a To-Many property that is KVO compliant.


From the Key Value Observing Programming Guide --

Automatic notification is also supported for the collection proxy  
objects returned by mutableArrayValueForKey: and  
mutableSetValueForKey: . This works for to-many relationships that  
support the indexed accessor methods  
insertObject:inKeyAtIndex:,replaceObjectInKeyAtIndex:, and  
removeObjectFromKeyAtIndex:.


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/AutoVsManual.html#/ 
/apple_ref/doc/uid/20001844



To implement a KVO compliant class for a To-Many property,  read more  
about Collection Accessor Patterns for To-Many Properties in the  
Key Value Coding Programming Guide


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html

Which says:

For manipulating the contents of the collection it is best practice  
to implement the additional accessor methods referred to as the  
collection accessor methods.


To do so, you must provide a minimal complement of indexed accessors  
(you may certainly use an NSMutableArray as a backing store).


HTH,
--Stuart




-Dave

On Oct 5, 2009, at 9:40 AM, Volker in Lists wrote:


Hi,

without knowing how you add objects to the ArrayController - and
when, and without knowing what and how is bound exactly - guessing
is most that can be done.

It seems the bindings are okay from the beginning, but the changes
to the ArrayControllers content are only observed when the sortOrder
is changed. Maybe you need only a single [NSArrayController
rearrangeObjects] call or similar.

Volker

Am 05.10.2009 um 18:32 schrieb David Hirsch:


My window has two NSTableViews.  Each has two columns, each of
which is bound to a field in Phases, an NSArrayController.

When my window is displayed, I calculate my model, and the
NSTableViews show the headers, but blank data cells.  However, when
I click the header of one table, all four columns get populated
with data.  As far as I can tell (I've set breakpoints), this
happens without calling any of my code.  Note that this only works
if I click a text-based column.  If I click the column with image
cells, I get no response, so presumably the TableView is trying to
sort the data on the click, and somehow straightens out the
previously mucked-up binding at that time.

I'm posting here without code to see if anybody has experienced
this before.  It will be a major undertaking to reduce this problem
to a post-able amount of code.

I've tried making Phases (the NSArrayController) the data source
and delegate in addition to the column bindings, without solving
the problem.  I've tried adding another NSTableView and binding it
to other columns to see if I had done it wrong the first time.
That did not help.  The fact that the bindings do work after the
click seems to suggest that the binding setup is okay.

Thanks in advance,
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: [Solved] Re: NSTableView: no display until header clicked

2009-10-05 Thread Quincey Morris

On Oct 5, 2009, at 10:52, David Hirsch wrote:

This seems to be precisely the solution.  The problem was that the  
bound object didn't know about changes to the array.  There are two  
ways to inform it: manipulate the array through the controller, or  
fire my own KVO.  In fact,  here is the latter solution in the Apple  
docs:http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/ 
Conceptual/KeyValueObserving/Concepts/AutoVsManual.html#//apple_ref/ 
doc/uid/20001844 (listing 3).


Or are you suggesting that I should be notifying using some other key?


I'm suggesting that you have a data model (an array property of your  
document), a mediating controller (the NSArrayController) that has a  
derived property (arrangedObjects, derived from the data model), a  
user interface object (the NSTableView), and, incidentally a  
coordinating controller (the NSDocument subclass, or its  
NSWindowController).


The problem isn't in arrangedObjects. The problem is that your data  
model isn't (apparently) being updated KVO compliantly:


- (id) init... {
...
myArrayIvar = [NSMutableArray array];
...
}

- (void) awakeFromNib {
...
[myArrayIvar addObject: someObject]; // oops, not KVO compliant
...
}

If that's what's going wrong, then the solution is, most directly:

- (void) awakeFromNib {
...
	[[self mutableArrayValueForKey: @myArrayPropertyName] addObject:  
someObject]; // KVO compliance FTW

...
}

Or, indirectly:

- (void) awakeFromNib {
...
[myArrayController addObject: someObject];
...
}

(because the behavior of the latter is to add the object KVO  
compliantly to the data model array on your behalf)


Which solution you chose depends on other factors (for example, the  
second one requires that your document subclass have an outlet to the  
array controller, which as a design choice has its own set of  
considerations).


Usually, if you find yourself using willChange/didChange, then  
something has gone wrong and you've leaped into hackland -- though, to  
be sure, there are non-controversial situations where using them is a  
viable choice.



___

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: NSLayoutManager and best override point for temporary attributes

2009-10-05 Thread Keith Blount
Hi,

I spent the weekend on this and the only thing I'm still having problems with 
is finding the best place to apply the underline and strikethrough temporary 
attributes so that they get applied automatically and efficiently (using the 
showPackedGlyphs:... method worked perfectly for the text itself - thank you 
Aki!).

I tried saving the edited range of text in the text storage and then having my 
layout manager check this from:

-textStorage:edited:range:changeInLength:invalidatedRange:

Then my layout manager adds temp attribs in this method. Turns out that this is 
a Bad Thing (which I should have realised beforehand), as it can cause glyph 
generation before the text storage has ended editing. D'oh.

Another solution that occurs to me is to have the text storage tell all of its 
layout managers to apply any temporary attributes after it has processed 
editing, e.g:

- (void)processEditing
{
  [super processEditing];

  if (dirtyRange.length == 0)
return;

  NSEnumerator *e = [[self layoutManagers] objectEnumerator];
  NSLayoutManager *lm;
  while (lm = [e nextObject])
   [lm applyTemporaryAttributesToDirtyRangeIfNecessary:dirtyRange];

  dirtyRange = NSMakeRange(NSNotFound,0);
}

I'm still unsure that this is the best route to take, though. (As I say, I 
previously did all of this stuff in the text view delegate, but that meant 
duplicating code for each text view and was hugely inefficient; and overriding 
NSLayoutManager's -temporaryAttributesAtRange: was just too slow.)

In fact, does anyone know how NSTextView handles keeping the temporary 
attributes up to date for NSLinkAttributeName? Essentially I'm just trying to 
do the same but with a custom attribute instead of NSLinkAttributeName. The 
problem is simply that if you apply a temporary attribute to a range of text, 
typing in that range doesn't take on the temporary attribute (because temporary 
attributes are handled by the layout manager and so the text view knows nothing 
about them presumably). But NSTextView or NSLayoutManager (actually presumably 
the latter) has some internal magic that handles applying the 
linkTextAttributes (which are, according to the docs, just temporary attributes 
too) to any typed text with NSLinkAttributeName applied. All I'm trying to 
achieve is the same thing but with a custom attribute, and it seems more 
difficult than it should be... But I'm probably just making it so.

Many thanks and all the best,
Keith

--- On Sat, 10/3/09, Aki Inoue a...@apple.com wrote:

 From: Aki Inoue a...@apple.com
 Subject: Re: NSLayoutManager and best override point for temporary attributes
 To: Keith Blount keithblo...@yahoo.com
 Cc: Martin Wierschin mar...@nisus.com, cocoa-dev@lists.apple.com
 Date: Saturday, October 3, 2009, 1:03 AM
 The font and color attributes are
 just hint for the settings already applied to the current
 graphics context.
 
 You can do:
 NSGraphicsContext *context = [NSGraphicsContext
 currentContext];
 
 [context saveGraphicsState];
 
 [yourCustomColor set];
 
 [super showPackedGlyphs:...];
 
 [context restoreGraphicsState];
 
  My custom attributes set only the colour, so this
 should be fine. (Although I'm not sure how I would use this
 method if I wanted, say, the underline to be a different
 colour from the text, which I need for certain link
 attributes.)
 
 There is no rendering primitive method like this for
 underlines.  You still need to use temporary attributes
 for that purpose.  I believe the temporary attribute
 approach is efficient enough for that kind of usage
 patterns.
 
 Aki
 
 On 2009/10/02, at 17:32, Keith Blount wrote:
 
  Hi Aki,
  
  Many thanks for your reply, much appreciated. Would
 you mind giving me a little more information on how to
 override this method? The docs are a little sparse in this
 regard. For instance, if I try passing a different colour
 into super's method, it has no effect; instead, it seems
 that I need to use [color set] before calling super (which
 would seem to be hinted at by the docs, as they say if for
 any reason you modify the set color or font...). Do I call
 [customColor set] using my own colour, then call super, then
 call [color set] using the passed-in colour after calling
 super?
  
  My custom attributes set only the colour, so this
 should be fine. (Although I'm not sure how I would use this
 method if I wanted, say, the underline to be a different
 colour from the text, which I need for certain link
 attributes.)
  
  Many thanks again and all the best,
  Keith
  
  --- On Fri, 10/2/09, Aki Inoue a...@apple.com
 wrote:
  
  From: Aki Inoue a...@apple.com
  Subject: Re: NSLayoutManager and best override
 point for temporary attributes
  To: Keith Blount keithblo...@yahoo.com
  Cc: Martin Wierschin mar...@nisus.com,
 cocoa-dev@lists.apple.com
  Date: Friday, October 2, 2009, 10:24 PM
  Keith,
  
  If your custom attributes modifies just the
 graphics state
  (don't affect the layout), you can override
  -[NSLayoutManager
 
 

Re: NSTableView: no display until header clicked

2009-10-05 Thread Quincey Morris

On Oct 5, 2009, at 11:54, Stuart Malin wrote:

An NSMutableArray is not KVO compliant for addition and deletion of  
entries. You must either provide manual notification or create a  
class with a To-Many property that is KVO compliant.


From the Key Value Observing Programming Guide --

Automatic notification is also supported for the collection proxy  
objects returned by mutableArrayValueForKey: and  
mutableSetValueForKey: . This works for to-many relationships that  
support the indexed accessor methods  
insertObject:inKeyAtIndex:,replaceObjectInKeyAtIndex:, and  
removeObjectFromKeyAtIndex:.


Except that, although your first paragraph is correct as far as it  
goes, it's not the whole answer.


You can use the mutable array proxy for an array property that is  
*not* implemented with the indexed accessor methods. They're sort of  
irrelevant to the problem.


You can also replace the entire array, but KVO compliantly via KVC of  
course, without being concerned with either mutable proxies or indexed  
accessors. This is the brute force method, though, so it's often not  
the best way. (Someone suggested this solution earlier in the thread,  
but seemed to be saying that it was the *only* option, which isn't so.)



___

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] : Los Angeles CocoaHeads this Thursday 10/8 7:30pm

2009-10-05 Thread Rob Ross

Greetings LA CocoaHeads.

This Thursday, David Hodge will be discussing his experiences with  
making public transit applications for the iPhone. Starting with iBART  
and iBART Live in the Bay Area, now CDTA iRide that he made on  
contract for New York state, and a few other related applications.  
He'll also be describing some technical hurdles he faced with the sdk,  
and challenges with Apple.



We meet at the offices of E! Entertainment at 7:30pm.

Our meeting location is

5750 Wilshire Blvd
Los Angeles, CA 90036.

Here's a google map of the location:

http://www.google.com/maps?f=qhl=enq=5750+Wilshire+Blvd,+Los+Angeles+CA+90036ie=UTF8z=15om=1iwloc=addr

Free street parking is available after 8pm - FEED THE METER UP TO 8PM
OR YOU MIGHT GET A TICKET!

I'd suggest trying Masselin Ave, which is one block East of Courtyard
Place.

We meet near the lobby of the West building at 5750 Wilshire Blvd, on
the West side of Courtyard Place. There are picknick tables in front
of the lobby and we'll gather there starting at 7:20pm. From there we
go inside and up to conference room 3A at around 7:45pm .

If you arrive late, please ask the building security personnel in the
lobby to direct you to the E! Security office, and they will be able
to contact the group in conference room 3A and send someone down to
meet you.

Rob
___

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: GLSLBasicsCocoaDL sample code

2009-10-05 Thread Sean McBride
On 10/5/09 9:27 AM, McLaughlin, Michael P. said:

I downloaded the sample code

http://developer.apple.com/mac/library/samplecode/GLSLBasicsCocoaDL/index.ht
ml

It built and ran under Mac OS 10.5.8 and Xcode 3.1.3.  However, the result
showed a *black*, rotating object on a not-quite-so-black background.

I'm guessing that it should not look like that, yes?

Can anyone confirm? Am I missing something?

With my Mac it shows a very colourful thing rotating slowly on a black
background.  Probably we have different GPUs.  I'd take this to the
OpenGL list...

I was hoping to learn about
Cocoa+OpenGL+shaders from this demo :-(

You have! :)

--

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: Storing UInt64 in a Core Data attribute ?

2009-10-05 Thread Sean McBride
On 10/5/09 8:31 PM, Guillaume Laurent said:

Apparently, Core Data only handles signed int types for attributes. I

Yes, this has annoyed me too.  I believe the reason is because that's
how SQL does things.

need to store UInt64 ones (MIDITimeStamp, more precisely), and to show
these in a table column. Of course the displayed values are signed,
some negative some not. Google didn't bring anything useful on that
topic, has anybody been confronted with this problem ? What would be
the best solution ?

You could store it as an NSNumber (using a 'transformable' type).

--

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: NSToolbarGroupItem not showing labels of subitems

2009-10-05 Thread Peter Ammon

Hi Brad,

The group item will use its own label, if it has been set.  Probably  
creating the toolbar in IB caused the item to acquire an empty label.   
Calling [groupItem setLabel:nil] should cause it to discard its own  
label and use its children.


Let me know if that doesn't work,
-Peter

On Oct 5, 2009, at 10:06 AM, Brad Gibbs wrote:


Hi,

I'm trying to create a toolbar with NSSegmentedControl as a custom  
view for an NSToolbarItemGroup in 10.6, but I can't get the labels  
for the subitems to appear.


I added an NSSegmentedControl to the toolbar item in IB and set  
images in the segmented control in IB.  I did not give the  
NSToolbarGroupItem a label.


I added the following code to my appDelegate (oProjectsGroup is an  
IBOutlet, which is bound to the NSToolbarGroupItem in IB):


- (void)applicationDidFinishLaunching:(NSNotification *) 
aNotification {

// Insert code here to initialize your application
	NSToolbarItem *item1 = [[[NSToolbarItem alloc]  
initWithItemIdentifier:@Item1] autorelease];
	NSToolbarItem *item2 = [[[NSToolbarItem alloc]  
initWithItemIdentifier:@Item2] autorelease];

[item1 setImage:[NSImage imageNamed:@Activities]];
[item2 setImage:[NSImage imageNamed:@Projects]];
[item1 setLabel:@Prev];
[item2 setLabel:@Next];

	[oProjectsGroup setSubitems:[NSArray arrayWithObjects:item1, item2,  
nil]];


for (id item in [oProjectsGroup subitems]) {
NSLog(@label is %@, [item label]);
}
}

The console displays the labels, so, apparently, the labels are  
being set, but they do not appear beneath their respective segments  
in the running app.


I've looked through the documentation and a list thread both of  
which seem to indicate that my code should be working


Any help would be appreciated.


Thanks.

Brad
___

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

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


NSInvocation: Restrictions Adding and Retaining Args : Undocumented??

2009-10-05 Thread Jerry Krinock

-- The documentation for -retainArguments states...

If the receiver hasn’t already done so, retains the target and all  
object arguments of the receiver and copies all of its C-string  
arguments  Discussion: Before this method is invoked,  
argumentsRetained returns NO; after, it returns YES.


-- The documentation for -setArgument:atIndex: states...

Sets an argument of the receiver.

***

This documentation leaves some questions unanswered

* What if I want to send -retainArguments before all arguments are  
added?  Will arguments that are added later have their arguments  
retained, because the branch for doing so reads the value of  
'argumentsRetained'?


* Is it necessary to add setArguments:: in order?  For example, if the  
method's signature has two arguments, can I add an argument at index  
3, and then later add an argument at index 2?
Hint: The documentation does not say so, but it seems that if I add an  
argument at index 3 and then immediately invoke -retainArguments, it  
crashes [1], but no exception is noted.


Sincerely,

Jerry Krinock

[1] Call Stack for The Crash (Mac OS X 10.5.8)
#0  0x9305e084 in CFRetain
#1  0x92fee084 in _CFArrayReplaceValues
#2  0x935bc873 in -[NSCFArray insertObject:atIndex:]
#3  0x935bc7e4 in -[NSCFArray addObject:]
#4  0x930da5c9 in __NSI3
#5  0x930da994 in -[NSInvocation 
retainArguments]___

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: wait for the event?

2009-10-05 Thread Matthew Mashyna


On Oct 5, 2009, at 12:51 PM, jon wrote:

i have a webView loading,   and need to wait until it is finished  
loading...


so far i've set up this notification in the wakeFromNib:

   NSNotificationCenter *center = [NSNotificationCenter  
defaultCenter];
   [center addObserver:self  
selector:@selector(webViewProgressFinished:)   
name:WebViewProgressFinishedNotification object:offScreenWebView];


and then i have a selector/method like so,  with nothing in it,   
because i'm not sure what to put in it yet...


- (void)webViewProgressFinished:(NSNotification*)notification
{
NSInteger i = 1;
}

and then i have a the main method that is running along,  and at a  
certain point below i need to wait for that notification to fire...  
Or that method to fire... same thing...
i need a little push in the correct direction,  because i really am  
stumped in whether to use some sort of NSRunLoop, or NSEvent,  or  
what would it be?


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
  	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


[[NSRunLoop currentRunLoop] runUntil... we get that darn message?];

here is where i need to wait until i get that message, or that that  
method is fired...
I seem to have the selector firing correctly i believe ...   but i  
don't know how to wait until it fires?

that is what i have so far...
and help would be appreciated greatly...

thanks,
Jon.




In general you don't want to wait for, uh what did you say? a selector  
to fire? You start an asynchronous operation (like loadRequest) and  
let the current run loop notify you. Exit the method after you do your  
loadRequest. When you get the notification, do your thing to finish it  
in webViewProgressFinished -- do the thing that you were waiting to do.


I could be wrong but I think you might actually be blocking the  
notification by doing the sit 'n spin bit with [[NSRunLoop  
currentRunLoop] runUntil... we get that darn message?];


Is there a reason you have to loop and wait for it to finish instead  
of doing more work in the notification method? If there is then maybe  
you should use a lock to synchronize the threads instead of waiting.


You might want to tell us more about what you're trying to do.


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: grouping undo across method calls in CoreData

2009-10-05 Thread Jerry Krinock


On 2009 Oct 05, at 06:10, Jim Thomason wrote:


But the problem is, if the user undoes the creation of a new object,
two undos are required


Welcome to what I call Core Data Undodoodoo :)


How can I deal with this? I've been trying various combinations of
begin/endUndoGrouping,


The second change to your data model is performed with delay 0.0.  So,  
try ending your undo group just a little bit later...


[undoManager beginUndoGrouping] ;
[undoManager performSelector:@selector(endUndoGrouping)
  withObject:nil
  afterDelay:0.01] ;


and even turning on and off groupsByEvent,


Experiments that I have done similar to yours led me to conclude that  
Core Data kind-of doesn't like groupsByEvent being turned off.  I'm  
not really sure, though.



That is, I can hit undo once and delete my object entirely, but then I
can hit undo a second time, and seemingly nothing happens.


Possibly this is because your mortal eyes cannot see the magic that  
Core Data is doing and undoing under the hood.  Sometimes you can find  
out by implementing the Dave Fernandes WhoDooUndo NSLogger, shown  
below.  If nothing gets logged, it's probably Core Data under-hood.


#if 0
#warning overrode willChangeValueForKey.  Do not ship this.
/*!
 @briefIn a Core Data document-based application, you
 often have the problem of the close button getting a dirty
 dot immediately after a new document is created or an old
 one loaded, or you just want to know what the hell is
 happening when you click Undo and nothing happens.
 Paste this code into the NSManagedObject subclass that you
 suspect may be changing, or even better, if you have a
 NSManagedObject parent class for all your subclasses
 paste it in there.  Set #if 1 above, compile,
 and run your app so that the dot gets dirty.  Then click
 Undo until the dot becomes clean as you watch the console.
 Any changes to your model will be logged.

 @details  Thanks to Dave Fernandes for this idea!
*/
- (void)willChangeValueForKey:(NSString*)key {
NSUndoManager* um = [[self managedObjectContext] undoManager] ;
// Since NSUndoManager is not thread-safe,
BOOL isUndoing = [um  
performSelectorOnMainThread:@selector(isUndoing)] ;
BOOL isRedoing = [um  
performSelectorOnMainThread:@selector(isRedoing)] ;

if (isUndoing || isRedoing) {
NSLog(@%@ %...@did changed value for key: %@,
  [[self entity] name],
  isUndoing ? @un : @re,
  key) ;
// Optional: Put a breakpoint here and debug to see what  
caused it

;
}
[super willChangeValueForKey:key];
}

#endif

___

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: wait for the event?

2009-10-05 Thread Jerry Krinock
You can get the behavior you want by running the run loop, preferably  
in a custom mode, but it will require retesting in 10.5 and 10.6 since  
much of the run loop stuff has changed.  It was suggested to me, and I  
now believe, that a more robust and comprehensible approach is to use  
an NSConditionLock.


Here is some code that I wrote last week.  In my case, I'm putting the  
NSConditionLock into a dictionary but you can put it into an ivar or  
wherever.  Also, in your case, what I call the manager thread would  
be your main thread.


** DECLARATIONS

/*!
 @briefCreates the receiver's condition lock and sets it into
 the receiver's info dictionary.

 @details  This is one of four methods provided in the event it is
 necessary to  block a manager thread while a worker thread
 completes work.

 This method should be invoked on the manager thread just before
 spinning off the worker thread to do the work.

 SSYOperationLinker provides only one such condition lock.
 If a condition lock has previously been created by this method
 and not yet removed by -blockForLock, an exception will be raised.
 */
- (void)prepareLock ;

/*!
 @briefLocks the receiver's condition lock.

 @details  This is one of four methods provided in the event it is
 necessary to  block a manager thread while a worker thread
 completes work.

 This method should be invoked on the worker thread before
 beginning the work.
 */
- (void)lockLock ;

/*!
 @briefBlocks until the receiver's condition lock is unlocked
 by -unlockLock, and then, before returning, removes the condition
 lock from the receiver's info dictionary.

 @details  This is one of four methods provided in the event it is
 necessary to  block a manager thread while a worker thread
 completes work.

 This method should be invoked on the manager thread after
 spinning off the worker thread to do the work.
 */
- (void)blockForLock ;

/*!
 @briefUnlocks the receiver's condition lock.

 @details  This is one of four methods provided in the event it is
 necessary to  block a manager thread while a worker thread
 completes work.

 This method should be invoked on the worker thread after work
 has been completed.
 */
- (void)unlockLock ;


*** IMPLEMENTATIONS

#define SSY_OPERATION_BLOCKED 0
#define SSY_OPERATION_CLEARED 1


- (void)prepareLock {
NSAssert(([[self info] objectForKey:constKeyLock] == nil), @Lock  
is already in use) ;
NSConditionLock* lock = [[NSConditionLock alloc]  
initWithCondition:SSY_OPERATION_BLOCKED] ;

[[self info] setObject:lock
forKey:constKeyLock] ;
[lock release] ;
}

- (void)lockLock {
[[[self info] objectForKey:constKeyLock] lock] ;
}

- (void)blockForLock {
NSConditionLock* lock = [[self info] objectForKey:constKeyLock] ;
BOOL workFinishedInTime = [lock  
lockWhenCondition:SSY_OPERATION_CLEARED
   beforeDate: 
[NSDatedateWithTimeIntervalSinceNow:99]] ;

if (workFinishedInTime) {
[lock unlock] ;
}

[[self info] removeObjectForKey:constKeyLock] ;
}

- (void)unlockLock {
[[[self info] objectForKey:constKeyLock]  
unlockWithCondition:SSY_OPERATION_CLEARED] ;

}


___

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: wait for the event?

2009-10-05 Thread jon
I had a bunch of arguments in the method and a returning boolean  
value,   which hampered the effort...  I'm in the process of making  
them variables in the class,  so i can get it down to a void method  
with no arguments,  and am putting the rest of the method into the  
selector as you suggested...


now i've got a new problem,   i have two methods that are similar,  
that run for different webpages,  but use the same offscreen  
webView,   so i need to have the notification select two different  
method/selectors (or one with a flag)  (because the code that ends up  
in them is vastly different)..  so i'm going to have to have yet  
another flag that says, go off and do two different things at the  
selector method  i'm trying to figure that out now too.  If anyone  
has a suggestion on that,  that would be great too...


sorry for terminology,  i'm still trying to wrap my brain around what  
to call things (how they work)...


interestingly,  i tried to put the


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
 	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


code into a secondary thread,   and let it run,  then had the thing  
exit to the main thread when it was done,  or so i thought,  but it  
appears to load
 it into it's own thread,  because the way i had it set up,  it  
immediately exited the secondary thread,  and then the notification  
fired sometime later


 i'm reverting to doing it in the main thread as you suggested...

here is what i was using as an example,   which does not work in the  
case of loading a webView for anyone thinking of doing it.  (or  
atleast i couldn't get it to work)

(last comment has the code example that i followed...)
Best way to make NSRunLoop wait for a flag to be set? - Stack Overflow


thanks,
jon.


On Oct 5, 2009, at 3:46 PM, Matthew Mashyna wrote:

Is there a reason you have to loop and wait for it to finish instead  
of doing more work in the notification method


___

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: wait for the event?

2009-10-05 Thread Jerry Krinock


On 2009 Oct 05, at 14:46, Matthew Mashyna wrote:

I could be wrong but I think you might actually be blocking the  
notification by doing the sit 'n spin bit with [[NSRunLoop  
currentRunLoop] runUntil... we get that darn message?];


Indeed, Matthew is correct.  This is part of the Wonderland you want  
to avoid.



you should use a lock to synchronize the threads


Yes.


instead of waiting.



Well, it's still waiting.
___

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


[Performance issue] Resizing an alert sheet = blinks

2009-10-05 Thread Iceberg-Dev
Is it the intended behavior that resizing an Alert Sheet in Mac OS X  
10.5.8 on a MacBook Pro produces a lot of blinking?



I have a custom alert sheet that can be resized and when I resize it  
on a MacBook Pro (either 9400 or 9600 GPU), the resize operation  
produces flicking.


I tried with some Apple's applications and with the standard save  
sheet and it's also blinking (less though).


I removed almost every widget in the sheet, disabled the default  
button, it's still blinking.


This does not happen with standard window and I am not experiencing  
this phenomenon on a PowerMac G5 running Mac OS X 10.4.11.



___

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: wait for the event?

2009-10-05 Thread Mike Abdullah
I've got a method which does something like this, feel free to  
pillage :)


- (BOOL)loadUntilDate:(NSDate *)date;
{
BOOL result = NO;

NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
while (!result  [date timeIntervalSinceNow]  0)
{
[runLoop runUntilDate:[NSDate distantPast]];
result = ![self isLoading];
}

return result;
}


Where -isLoading should return whether your webview has loaded yet.  
Note that this is running in the default run loop mode which is your  
only public API option for now.


Mike.

On 5 Oct 2009, at 17:51, jon wrote:

i have a webView loading,   and need to wait until it is finished  
loading...


so far i've set up this notification in the wakeFromNib:

   NSNotificationCenter *center = [NSNotificationCenter  
defaultCenter];
   [center addObserver:self selector:@selector 
(webViewProgressFinished:)  name:WebViewProgressFinishedNotification  
object:offScreenWebView];


and then i have a selector/method like so,  with nothing in it,   
because i'm not sure what to put in it yet...


- (void)webViewProgressFinished:(NSNotification*)notification
{
NSInteger i = 1;
}

and then i have a the main method that is running along,  and at a  
certain point below i need to wait for that notification to fire...  
Or that method to fire... same thing...
i need a little push in the correct direction,  because i really am  
stumped in whether to use some sort of NSRunLoop, or NSEvent,  or  
what would it be?


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
  	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


[[NSRunLoop currentRunLoop] runUntil... we get that darn message?];

here is where i need to wait until i get that message, or that that  
method is fired...
I seem to have the selector firing correctly i believe ...   but i  
don't know how to wait until it fires?

that is what i have so far...
and help would be appreciated greatly...

thanks,
Jon.


___

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/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.net


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to prevent the user from clicking 'Test' in Screen Savers (Was: ScreenSaverView gets instantiated several times)

2009-10-05 Thread Paul M

This is a much better approach IMO.

If your user is trying out a bunch of options to find a particular 
combination that works for them, and the machine goes away for ~30 secs 
each time they test a new change, the'll get pretty irriated with your 
screen saver pretty quickly.


Showing the results of the changed config using faked data that has no 
loading delay, will give a much more satisfactory experience.



paulm


On 6/10/2009, at 5:08 AM, Jack Carbaugh wrote:

Why not just fake it ... in other words ... since it's a test, just 
supply some generic data for the screen saver to display. Then, when 
they truly activate it, you provide the real data.


Seems that's what others have done, that i've experienced.

Not knowing for sure or not, but i believe you can determine whether 
the button was clicked to test or otherwise.


Jack


On Oct 5, 2009, at 11:45 AM, Gabriel Zachmann wrote:

Thanks a lot for all the responses, and sorry for bothering you again 
with this.


The problem I'm having is the following: is there an elegant way to 
prevent the user from clicking the 'Test' button in the Screen Savers 
panel in System Preferences?


The reason why I'm asking: when the user changes the configuration in 
my screen saver, I start a Spotlight query that could take up to 30  
seconds (about 10 seconds for the initial phase of the search itself, 
plus 20 seconds for retrieveing the results from the query).

The results of that query then change what the screensaver renders.

Therefore, I would like to give the user some feedback that the query 
is still in progress *AND* I would like to prevent the user from 
clicking that 'Test' button in System Preferences' Screensaver pane.


Right now I'm using an asynchronous NSMetadataQuery, which seems to 
work, except that the only way to prevent the user from clicking that 
'Test' button I found was to keep the configuration sheet up until 
the search has completely finished.


IMHO, this doesn't look very elegant ;-/

Any ideas will be highly appreciated.

Best regards,
Gabriel.


___

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/intrntmn%40aol.com

This email sent to intrn...@aol.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/list%40no-tek.com

This email sent to l...@no-tek.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: CoreData async fetch request

2009-10-05 Thread Ben Trumbull

Is there a way to do an asynchronous fetch request against Core data
returning partial results?


That depends on whether it's the query part that's expensive (e.g.  
WHERE clause with complex text searching and table scans) or simply  
the quantity of the row data that's your problem.  For the latter, you  
can just use -setFetchBatchSize: and be done.


You can use a separate MOC on a background thread to perform  
asynchronous work.  You can then pass over results to the main thread  
to display to the user.  However, unless your search terms are very  
expensive, it's usually easier and faster to use -setFetchBatchSize:  
synchronously.  For well indexed queries, it can handle a million or  
two rows per second.  Not sure why you'd subject your users to that  
kind of experience.  It's common to use fetch limits, count requests,  
and only show the top N results.  What's your user going to do with a  
hundred thousand results anyway ?


If you need to attack the computational expense of your query terms,  
that's more complicated.  Obviously it would be best to optimize the  
queries and ensure they are using an index.  But if that's not enough,  
you can execute the queries in a background MOC, fetching objectIDs +  
row data (put in the the row cache) and then have the other MOC  
materialize the objects by ID from the row cache.  There's a  
BackgroundFetching example in /Developer/Examples/CoreData.  It shows  
how to do this.  Returning partial results incrementally would require  
some creativity on your part to subdivide the query into several.   
Since most expensive queries are text searches, it's usually possible  
to subdivide the result set naturally.  Like the first letter of  
'title'.  Similar to the thumb bar index on the side of the Contacts  
app on the iPhone.


There's also a DerivedProperty example on ADC for optimizing text  
queries.



Obviously, Apple's own Spotlight could not use something like
Coredata, since it heavily relies on returning asynchronous partial
results.


Which is neither here nor there.  Most Cocoa applications wouldn't  
want Spotlight to be the sole persistence back end of their data.  The  
latency of putting all your data in a full text index instead of a  
relational database or keyed archive would be pretty absurd.  Now, if  
you're writing an app that's primarily structured around full text  
searching, you might instead prefer to focus on putting your data in  
Spotlight via small files, and using the Spotlight APIs.  But it's not  
suitable for apps interested in an OOP view of their data.



Frankly, this is my second application I've attempted to use Coredata
to find it come up surprisingly short. The first time the issue was
core data not being thread safe.


Core Data can be used efficiently with multiple threads.  It might  
help to think of each MOC as a separate writeable view.  If you'd like  
to know more, you can search the archives for my posts.



What is the target market for Core Data? Why sort of application is
ideal for its use? What size data store? Right now it escapes me.


Cocoa and Cocoa Touch applications, particularly done in an MVC style  
with an OO perspective on their data.  Some people also use it as a  
persistent cache for data stored in another canonical format, such as  
XML files.  On the Mac side, we've had customers with 3+ million rows  
(multi GB) databases, and on the embedded side, roughly 400,000 rows  
(100s MB).  However, it does take some care and feeding to handle data  
sets like that, and most developers find it straight forward up to  
about 10% those numbers.


It sounds like you're having performance issues.  What kinds of  
queries are you trying to accomplish ?  How much data are you working  
with ?  How have you modeled your primary entities?


You can fetch back just NSManagedObjectIDs, and - 
setIncludesPropertyValues: to NO to effectively create your own  
cursors if you prefer.


- 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: [Performance issue] Resizing an alert sheet = blinks

2009-10-05 Thread Jens Alfke


On Oct 5, 2009, at 3:12 PM, Iceberg-Dev wrote:

Is it the intended behavior that resizing an Alert Sheet in Mac OS X  
10.5.8 on a MacBook Pro produces a lot of blinking?
I have a custom alert sheet that can be resized and when I resize it  
on a MacBook Pro (either 9400 or 9600 GPU), the resize operation  
produces flicking.


No, it should be smooth.
Is the entire sheet window appearing and disappearing, or just the  
contents?
Is anything being logged to the console while resizing, like error/ 
exception messages?


—Jens___

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: whether to use core data...

2009-10-05 Thread Ben Trumbull

But the Core Data documentation starts like this:

...
Core Data is not an entry-level technology.
...
You should not simply try to read [The Core Data Programming Guide]
straight through to understand Core Data.
...
Do not attempt the NSPersistentDocument Core Data Tutorial unless or
until you also understand Cocoa bindings.
...
Although Cocoa bindings and Core Data are independent and address
different issues, both provide abstraction layers that˜while
individually they are reasonably straightforward to grasp˜can be
challenging to master simultaneously.


Bloody hell!

WARNING! Do not even ATTEMPT the NSPersistentDocument Core Data
Tutorial! Your very MIND is in MORTAL DANDER!


Ironically, the Low level Persistent Store tutorial was a lot easier  
for people new to Cocoa.  I believe it's been replaced by http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html 



The warning is a touch harsh.  Still, it's there because the Core Data  
abstractions are built on top of the other foundational Cocoa  
elements.  If you don't get KeyValueCoding, you're going to be lost.   
It wouldn't be doing you any favors to suggest otherwise.  Ditto for  
Cocoa collection classes, KVO, and NSNotificationCenter.


The NSPersistentDocument tutorial is more difficult because it's at  
the intersection of several different technologies.  NSDocument from  
AppKit, Cocoa Bindings, and Core Data.  So that's learning 3 separate  
things at once, and it's rarely clear to people new to Cocoa where  
those technologies intersect, and where they are distinct.  It'd be  
like learning how to whistle, juggle, and snap all at  once.  Could  
you ?  Sure.  But experience has demonstrated it's easier and  
significantly less frustrating to learn them separately.


Or put another way, some of the tutorials are intended for advanced  
Cocoa developers new to Core Data, not developers new to Cocoa.  Try  
the Core Data Utility Tutorial.  It's a CLI, so you don't have to get  
wrapped up in NSViews or Cocoa Bindings as you experiment with Core  
Data.


- 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: How to manage creation of an unknown number of windows?

2009-10-05 Thread Jens Alfke


On Oct 5, 2009, at 7:20 AM, Rui Pacheco wrote:

I've a class that extends NSWindowController and that class lists an  
unknown
number of entries. Double clicking on an entry will open a window  
where it

will be possible to interact with the real world object that entry
represents.
I plan to make the editing window extends NSDocument


NSDocument assumes every document is a file. If the real-world objects  
you're using aren't individual files, you won't be able to use  
NSDocument. Instead you can use NSWindowController, and have each  
instance manage one of these objects.



but I am still at a
loss on something: how do I make sure manage the creation of an  
unknown

number of windows on my app?


Creating the windows is easy; you just instantiate another of your  
controllers with the data object as a parameter, and it opens another  
instance of the nib.


I think what you're asking about is how to find the window associated  
with a particular object. Two ways to do this:


[1] Create a global NSMutableDictionary that maps objects (or their  
unique identifier strings) to controllers. The controller adds its  
object to the dictionary when it's created, and removes itself when  
the window's closed. (You can't put the remove code in the  
controller's -dealloc method, because the reference from the  
dictionary will keep the controller's refcount from going to zero.)


[2] Write a function that walks the window list. For each window, it  
checks whether its delegate is an instance of your controller class.  
If so, it looks at the controller's model object, and if it's the one  
being looked for, returns the controller.


I usually use method #2 because it requires less bookkeeping.

—Jens

___

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


NSOutlineView - Automatically select newly added item - Help needed

2009-10-05 Thread Mario Kušnjer

Hello to the list !

Request for help regarding a little problem.
So I have this piece of code:

- (IBAction)addNewItem:(id)sender
{
if ([lsOutlineView selectedRow]  0)
{
[sourceListLevelZero addObject:[Parent new]];
[lsOutlineView reloadItem:nil reloadChildren:YES];
[lsOutlineView expandItem:nil expandChildren:YES];
		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO];

}
...
}

It is the last line that trouble's me.
It should select newly added item in the list (right ?), but it does  
not !

Or am I doing something wrong (very likely !) ?

Ok, so you got it by now that I am trying to get the behavior that  
when user clicks add button new item that appears in the list  
automatically gets selected.


Thanks for help
Bye

Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982
mariokusn...@skype

___

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: NSOutlineView - Automatically select newly added item - Help needed

2009-10-05 Thread Stamenkovic Florijan


On Oct 05, 2009, at 19:44, Mario Kušnjer wrote:


Hello to the list !

Request for help regarding a little problem.
So I have this piece of code:

- (IBAction)addNewItem:(id)sender
{
if ([lsOutlineView selectedRow]  0)
{
[sourceListLevelZero addObject:[Parent new]];
[lsOutlineView reloadItem:nil reloadChildren:YES];
[lsOutlineView expandItem:nil expandChildren:YES];


Can't comment on this part as I am not exactly sure what you are  
doing. However note that in the first line of the block above you are  
most probably retaining an object twice. This is not a leak if you  
insist on garbage collection, but otherwise it is.


		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO];


Well, assuming that you wanted to select the Parent item you added to  
the sourceListLevelZero, you should query the outline for the row  
index of *that* item, and not of a new Parent. Besides that to me the  
line makes sense...


HTH,
F


}
...
}

It is the last line that trouble's me.
It should select newly added item in the list (right ?), but it does  
not !

Or am I doing something wrong (very likely !) ?

Ok, so you got it by now that I am trying to get the behavior that  
when user clicks add button new item that appears in the list  
automatically gets selected.


Thanks for help
Bye


___

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: wait for the event?

2009-10-05 Thread jon

well there seems to be a problem,   I do the main Method like so,

- (void)loadThePage
{
URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
	[[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];

}

@end

and i put the rest in the selector method like so...  to be executed  
when the page is fully loaded,  which works...  but the thing is,  the  
code immediately following the main call to loadThePage isn't  
waiting, it keeps on executing... which defeats the purpose,  the  
whole program needs that data.


//  
---

- (void) webViewProgressFinished:(NSNotification*)notification
{
didChange = NO;
	DOMDocument *myDOMDocument = [[offScreenWebView mainFrame]  
DOMDocument];

... etc

 if the webpage was quick to load it works   in reality the page  
takes a while to load,  and in the mean time,  the rest of my  
application  (the code after the loadThePage keeps on executing so i  
have not successfully controlled the running of the app.,  it is  
executing methods left and right,  without the finishLoadingTheWebPage  
ever being called until half the application has already executed...


putting the loading into another thread results in the same thing,
the rest of the application needs the data,  so it can not be running  
until the webPage is fully loaded...


so i have to use a combination,  i need to put in a flagging type of  
thing, and have the runLoop wait for that flag,  the flag needs to be  
in the webViewProgressFinished  to work (it was not before)..  yet i  
still need that flag



thanks,
Jon.



On Oct 5, 2009, at 3:46 PM, Matthew Mashyna wrote:



On Oct 5, 2009, at 12:51 PM, jon wrote:

i have a webView loading,   and need to wait until it is finished  
loading...


so far i've set up this notification in the wakeFromNib:

  NSNotificationCenter *center = [NSNotificationCenter  
defaultCenter];
  [center addObserver:self  
selector:@selector(webViewProgressFinished:)   
name:WebViewProgressFinishedNotification object:offScreenWebView];


and then i have a selector/method like so,  with nothing in it,   
because i'm not sure what to put in it yet...


- (void)webViewProgressFinished:(NSNotification*)notification
{
NSInteger i = 1;
}

and then i have a the main method that is running along,  and at a  
certain point below i need to wait for that notification to fire...  
Or that method to fire... same thing...
i need a little push in the correct direction,  because i really am  
stumped in whether to use some sort of NSRunLoop, or NSEvent,  or  
what would it be?


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
 	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


[[NSRunLoop currentRunLoop] runUntil... we get that darn message?];

here is where i need to wait until i get that message, or that that  
method is fired...
I seem to have the selector firing correctly i believe ...   but i  
don't know how to wait until it fires?

that is what i have so far...
and help would be appreciated greatly...

thanks,
Jon.




In general you don't want to wait for, uh what did you say? a  
selector to fire? You start an asynchronous operation (like  
loadRequest) and let the current run loop notify you. Exit the  
method after you do your loadRequest. When you get the notification,  
do your thing to finish it in webViewProgressFinished -- do the  
thing that you were waiting to do.


I could be wrong but I think you might actually be blocking the  
notification by doing the sit 'n spin bit with [[NSRunLoop  
currentRunLoop] runUntil... we get that darn message?];


Is there a reason you have to loop and wait for it to finish instead  
of doing more work in the notification method? If there is then  
maybe you should use a lock to synchronize the threads instead of  
waiting.


You might want to tell us more about what you're trying to do.


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: wait for the event?

2009-10-05 Thread Jens Alfke


On Oct 5, 2009, at 5:34 PM, jon wrote:

and i put the rest in the selector method like so...  to be executed  
when the page is fully loaded,  which works...  but the thing is,  
the code immediately following the main call to loadThePage isn't  
waiting, it keeps on executing... which defeats the purpose, the  
whole program needs that data.


That's the expected behavior. The -loadRequest: method doesn't block;  
it returns immediately, but the action hasn't happened yet. The  
delegate callbacks will tell you when it's finished.


Most Cocoa networking calls work this way. Rather than block the  
thread, which forces you to run the operation on a background thread  
to avoid locking up the UI, they're asynchronous. You have to write  
your code somewhat differently this way, but it's a lot better than  
having to deal with multithreading hell.


in reality the page takes a while to load,  and in the mean time,   
the rest of my application  (the code after the loadThePage keeps  
on executing so i have not successfully controlled the running of  
the app.,  it is executing methods left and right,  without the  
finishLoadingTheWebPage ever being called until half the application  
has already executed...


You need to write your app so it keeps running without having the data  
yet. Probably you can just return from your event handler back to the  
event loop. Any fields in the UI that will show results should start  
out being blank. Once your delegate method is called to tell you the  
network activity is finished, you can fill in the data.


—Jens___

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: NSOutlineView - Automatically select newly added item - Help needed

2009-10-05 Thread Colin Howarth

On 6 Oct, 2009, at 01:44, Mario Kušnjer wrote:
...

		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO];



It is the last line that trouble's me.
It should select newly added item in the list (right ?), but it does  
not !


without trying to understand what's happening, or supposed to, you  
could also (in cases like this) try TEMPORARILY unravelling your  
method calls. Like this:


Parent *parent = [Parent new];

int index = [lsOutlineView rowForItem: parent];

NSArray *indices = [NSIndexSet indexSetWithIndex: index];

[IsOutlineView selectRowIndexes: indices byExtendingSelection:NO];


 where I don't know what the actual classes are 


Then you can check these intermediate steps, to see they're doing what  
you think they should.


Then you can wrap it all up again once you've fixed it, to save screen  
space :-)


--colin___

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: NSOutlineView - Automatically select newly added item - Help needed

2009-10-05 Thread Graham Cox


On 06/10/2009, at 10:44 AM, Mario Kušnjer wrote:


[sourceListLevelZero addObject:[Parent new]];


		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO];



Assuming -addObject: in the first line adds the object to the end of  
the array, just do this:



[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[sourceListLevelZero count] - 1] byExtendingSelection:NO];



This generalises to any position - just find the index of the object  
you just added.


--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: Checking whether a file is a genuine PDF file

2009-10-05 Thread Graham Cox


On 04/10/2009, at 11:07 PM, Squ Aire wrote:

 But that isn't good enough really, because a file can have the pdf  
extension without being a true PDF file.



This is true, but how far are you prepared to go? Others have  
suggested checking a few bytes into the file's header which should be  
reasonable enough, but I could create a file having a valid PDF header  
and garbage thereafter... you cannot protect yourself against that  
sort of thing, so the question is where your code would draw the line.  
Most people would draw it with a simple check of the extension and  
maybe for files that traditionally have been subject to extension  
abuse (I don't think pdf is one of them), a few header bytes.


What is it you're afraid of?

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


How to check if a class derives from another?

2009-10-05 Thread Rick Mann
I have a need to tell if a class I'm loading dynamically is derived  
from another class. How do I do this?


TIA,
Rick

___

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 check if a class derives from another?

2009-10-05 Thread Jens Alfke


On Oct 5, 2009, at 6:35 PM, Rick Mann wrote:

I have a need to tell if a class I'm loading dynamically is derived  
from another class. How do I do this?



Class justLoadedClass = ... ;
if ([justLoadedClass isSubclassOfClass: [MyBaseClass class]]) {
...
}

—Jens

___

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 check if a class derives from another?

2009-10-05 Thread Colin Howarth

On 6 Oct, 2009, at 03:35, Rick Mann wrote:

I have a need to tell if a class I'm loading dynamically is derived  
from another class. How do I do this?


Perhaps NSObject's class method

+superclass

might 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


Re: wait for the event?

2009-10-05 Thread Matthew Mashyna
Well, all I can say is that you need some time to come around to a  
different way of thinking. You are thinking too linearly. You need to  
set up your loads and listens and coordinate them.


You don't want to design your app to sit and spin on the main thread.  
It's job is to handle all the basic events. If I were you I would have  
my app fire up a thread to kick off these web pages you need to load.  
I would create a new class of object that manages these web loads and  
register each of them to each listen for just one webview. Don't have  
you main class listen have these other objects listen.


Have your processing thread -- the one that starts the webloads -- set  
a lock for each of the manager objects. These manager objects can  
handle the post-load processing and clear the lock. When all the locks  
are cleared then your processing thread moves on.


So, what I'm saying is: don't do the run loop in the main thread  
manually like you want to. Resist the urge. Control things from a  
secondary thread that doesn't mind being blocked until the locks are  
cleared.


What you are describing with the flagging and the data arriving out of  
sync is the classic, text book example of when to use locks. You have  
a resource (the loaded web pages) that another object wants to  
consume. Look at the NSLock documentation. I think that will help you.


Good luck,
Matt

On Oct 5, 2009, at 8:34 PM, jon wrote:


well there seems to be a problem,   I do the main Method like so,

- (void)loadThePage
{
URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
	[[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];

}

@end

and i put the rest in the selector method like so...  to be executed  
when the page is fully loaded,  which works...  but the thing is,   
the code immediately following the main call to loadThePage isn't  
waiting, it keeps on executing... which defeats the purpose,  the  
whole program needs that data.


//  
---

- (void) webViewProgressFinished:(NSNotification*)notification
{
didChange = NO;
	DOMDocument *myDOMDocument = [[offScreenWebView mainFrame]  
DOMDocument];

... etc

 if the webpage was quick to load it works   in reality the page  
takes a while to load,  and in the mean time,  the rest of my  
application  (the code after the loadThePage keeps on executing so  
i have not successfully controlled the running of the app.,  it is  
executing methods left and right,  without the  
finishLoadingTheWebPage ever being called until half the application  
has already executed...


putting the loading into another thread results in the same thing,
the rest of the application needs the data,  so it can not be  
running until the webPage is fully loaded...


so i have to use a combination,  i need to put in a flagging type of  
thing, and have the runLoop wait for that flag,  the flag needs to  
be in the webViewProgressFinished  to work (it was not before)..   
yet i still need that flag



thanks,
Jon.



On Oct 5, 2009, at 3:46 PM, Matthew Mashyna wrote:



On Oct 5, 2009, at 12:51 PM, jon wrote:

i have a webView loading,   and need to wait until it is finished  
loading...


so far i've set up this notification in the wakeFromNib:

  NSNotificationCenter *center = [NSNotificationCenter  
defaultCenter];
  [center addObserver:self  
selector:@selector(webViewProgressFinished:)   
name:WebViewProgressFinishedNotification object:offScreenWebView];


and then i have a selector/method like so,  with nothing in it,   
because i'm not sure what to put in it yet...


- (void)webViewProgressFinished:(NSNotification*)notification
{
NSInteger i = 1;
}

and then i have a the main method that is running along,  and at a  
certain point below i need to wait for that notification to  
fire... Or that method to fire... same thing...
i need a little push in the correct direction,  because i really  
am stumped in whether to use some sort of NSRunLoop, or NSEvent,   
or what would it be?


URLToLoad = [NSURL URLWithString:theUrlString];
[offScreenWebView setFrameLoadDelegate:self];
 	 [[offScreenWebView mainFrame] loadRequest:[NSURLRequest  
requestWithURL:URLToLoad]];


[[NSRunLoop currentRunLoop] runUntil... we get that darn message?];

here is where i need to wait until i get that message, or that  
that method is fired...
I seem to have the selector firing correctly i believe ...   but i  
don't know how to wait until it fires?

that is what i have so far...
and help would be appreciated greatly...

thanks,
Jon.




In general you don't want to wait for, uh what did you say? a  
selector to fire? You start an asynchronous operation (like  
loadRequest) and let the current run loop notify you. Exit the  
method after you do your loadRequest. When you get the  

Re: Checking whether a file is a genuine PDF file

2009-10-05 Thread Charles Srstka

On Oct 5, 2009, at 8:30 PM, Graham Cox wrote:

Most people would draw it with a simple check of the extension and  
maybe for files that traditionally have been subject to extension  
abuse (I don't think pdf is one of them)


Well, in this day and age I believe you should actually be checking  
the UTI rather than the extension.


Charles
___

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: NSOutlineView - Automatically select newly added item - Help needed

2009-10-05 Thread Charles Srstka

On Oct 5, 2009, at 7:49 PM, Colin Howarth wrote:


On 6 Oct, 2009, at 01:44, Mario Kušnjer wrote:
...

		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO];



It is the last line that trouble's me.
It should select newly added item in the list (right ?), but it  
does not !


without trying to understand what's happening, or supposed to, you  
could also (in cases like this) try TEMPORARILY unravelling your  
method calls. Like this:


Parent *parent = [Parent new];

int index = [lsOutlineView rowForItem: parent];

NSArray *indices = [NSIndexSet indexSetWithIndex: index];

[IsOutlineView selectRowIndexes: indices byExtendingSelection:NO];


 where I don't know what the actual classes are 


Then you can check these intermediate steps, to see they're doing  
what you think they should.


Then you can wrap it all up again once you've fixed it, to save  
screen space :-)


Note that if your NSOutlineView is using an NSTreeController rather  
than a custom data source, rowForItem: still won't work.


Charles___

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: wait for the event?

2009-10-05 Thread jon
oh you've got that right,  I unfortunately have it ingrained for 25  
years of straight pascal in MacOS...  i could destroy a runloop with  
the best of them...


I wish i started cocoa 7 years ago, but it was not to be.  My  
brain is trying to refactor,  and it is fighting mightily... trying to  
keep up with the young-uns who have no such baggage...


I'll look into NSLock thanks,
Jon.

On Oct 5, 2009, at 7:45 PM, Matthew Mashyna wrote:

you need some time to come around to a different way of thinking.  
You are thinking too linearly.


___

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: Checking whether a file is a genuine PDF file

2009-10-05 Thread John Joyce

Google magic number
This is unix and there is a ver nifty tool for such things.
Ultimately u just have to ask yourself how you will handle files that  
seem wrong.
You could also ask yourself how you would handle an unreasonably large  
PDF file...

Then u can ask yourself if it is really necessary...
It is entirely easy to create a PDF with nothing in it or with  
egregious amounts of stuff in it that no app could read well yet is a  
valid PDF


Weigh carefully how far down the rabbit hole you need to go.
if it needs to be military-secure, why is PDF being used at all?  
That sort of thing


Sent from my iPhone

On 2009/10/05, at 20:38, cocoa-dev-requ...@lists.apple.com wrote:


Re: Checking whether a file is a genuine PDF file

___

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: re: CoreData async fetch request

2009-10-05 Thread enki1711
I am doing a simple query search for a text string pattern (ie 'SELF like  
foo') on ~10 million small records stored persistently using sqlite. This  
is a performance test to make sure I get reasonable performance from my  
database engine before I commit too much code to it.


The query is taking over 3 minutes with a small result set. This is on a  
new 13 macbook pro w 4gb memory.


The query is taking too long for a user to sit and wait for it. Is there a  
way to speed it up? Can indexing be applied to it?


I had thought if I could display results as they are found that might be  
reasonable. In my tests, if I use setFetchBatchSize and setOffset to  
restart it, then it ends up repeating the query taking that many times  
longer to get a result. Not reasonable. It does not seem to start the query  
where it left off, as a database cursor would do.


My impression is that my usage scenario is not an appropriate use of core  
data.


I was planning to try SQLite directly. Would it be more appropriate?

Thanks

On Oct 5, 2009 7:14pm, Ben Trumbull trumb...@apple.com wrote:

Is there a way to do an asynchronous fetch request against Core data
returning partial results?


That depends on whether it's the query part that's expensive (eg WHERE  
clause with complex text searching and table scans) or simply the  
quantity of the row data that's your problem. For the latter, you can  
just use -setFetchBatchSize: and be done.



You can use a separate MOC on a background thread to perform asynchronous  
work. You can then pass over results to the main thread to display to the  
user. However, unless your search terms are very expensive, it's usually  
easier and faster to use -setFetchBatchSize: synchronously. For well  
indexed queries, it can handle a million or two rows per second. Not sure  
why you'd subject your users to that kind of experience. It's common to  
use fetch limits, count requests, and only show the top N results. What's  
your user going to do with a hundred thousand results anyway ?



If you need to attack the computational expense of your query terms,  
that's more complicated. Obviously it would be best to optimize the  
queries and ensure they are using an index. But if that's not enough, you  
can execute the queries in a background MOC, fetching objectIDs + row  
data (put in the the row cache) and then have the other MOC materialize  
the objects by ID from the row cache. There's a BackgroundFetching  
example in /Developer/Examples/CoreData. It shows how to do this.  
Returning partial results incrementally would require some creativity on  
your part to subdivide the query into several. Since most expensive  
queries are text searches, it's usually possible to subdivide the result  
set naturally. Like the first letter of 'title'. Similar to the thumb bar  
index on the side of the Contacts app on the iPhone.




There's also a DerivedProperty example on ADC for optimizing text queries.




Obviously, Apple's own Spotlight could not use something like
Coredata, since it heavily relies on returning asynchronous partial
results.


Which is neither here nor there. Most Cocoa applications wouldn't want  
Spotlight to be the sole persistence back end of their data. The latency  
of putting all your data in a full text index instead of a relational  
database or keyed archive would be pretty absurd. Now, if you're writing  
an app that's primarily structured around full text searching, you might  
instead prefer to focus on putting your data in Spotlight via small  
files, and using the Spotlight APIs. But it's not suitable for apps  
interested in an OOP view of their data.




Frankly, this is my second application I've attempted to use Coredata
to find it come up surprisingly short. The first time the issue was
core data not being thread safe.


Core Data can be used efficiently with multiple threads. It might help to  
think of each MOC as a separate writeable view. If you'd like to know  
more, you can search the archives for my posts.




What is the target market for Core Data? Why sort of application is
ideal for its use? What size data store? Right now it escapes me.



Cocoa and Cocoa Touch applications, particularly done in an MVC style  
with an OO perspective on their data. Some people also use it as a  
persistent cache for data stored in another canonical format, such as XML  
files. On the Mac side, we've had customers with 3+ million rows (multi  
GB) databases, and on the embedded side, roughly 400,000 rows (100s MB).  
However, it does take some care and feeding to handle data sets like  
that, and most developers find it straight forward up to about 10% those  
numbers.




It sounds like you're having performance issues. What kinds of queries  
are you trying to accomplish ? How much data are you working with ? How  
have you modeled your primary entities?



You can fetch back just NSManagedObjectIDs, and  
-setIncludesPropertyValues: to NO to effectively 

Re: Checking whether a file is a genuine PDF file

2009-10-05 Thread James Walker

Graham Cox wrote:


On 04/10/2009, at 11:07 PM, Squ Aire wrote:

 But that isn't good enough really, because a file can have the pdf 
extension without being a true PDF file.



This is true, but how far are you prepared to go? Others have suggested 
checking a few bytes into the file's header which should be reasonable 
enough, but I could create a file having a valid PDF header and garbage 
thereafter... you cannot protect yourself against that sort of thing, so 
the question is where your code would draw the line. Most people would 
draw it with a simple check of the extension and maybe for files that 
traditionally have been subject to extension abuse (I don't think pdf is 
one of them), a few header bytes.


What is it you're afraid of?


FWIW, in the classic Mac OS, it was not uncommon to see a PDF with NO 
extension, but with the file type set to 'PDF '.

--
  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: Checking whether a file is a genuine PDF file

2009-10-05 Thread Kyle Sluder
On Mon, Oct 5, 2009 at 6:30 PM, Graham Cox graham@bigpond.com wrote:
 This is true, but how far are you prepared to go? Others have suggested
 checking a few bytes into the file's header which should be reasonable
 enough, but I could create a file having a valid PDF header and garbage
 thereafter... you cannot protect yourself against that sort of thing, so the
 question is where your code would draw the line. Most people would draw it
 with a simple check of the extension and maybe for files that traditionally
 have been subject to extension abuse (I don't think pdf is one of them), a
 few header bytes.

Please don't read files that you haven't been asked to open.  Those of
us with network-mounted home directories will not appreciate our open
dialogs beachball as your delegate traverses the network for every
single file.

--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: wait for the event?

2009-10-05 Thread Scott Ribe
 I unfortunately have it ingrained for 25
 years of straight pascal in MacOS...

OK, so you already have some event-driven experience when dealing with
user events, now you need to extend that thinking to other sources of data,
such as the network, in addition to mouse  keyboard.

-- 
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: Checking whether a file is a genuine PDF file

2009-10-05 Thread Charles Srstka

On Oct 5, 2009, at 9:02 PM, James Walker wrote:

FWIW, in the classic Mac OS, it was not uncommon to see a PDF with  
NO extension, but with the file type set to 'PDF '.


Yes. Fortunately, if you have your application check the UTI instead  
of the filename extension, you'll always detect that it's  
com.adobe.pdf whether the identifying information is in the extension,  
HFS type code, or anything else the OS may use in the future to  
determine the type.


Charles
___

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: Making a opaque copy of an NSImage

2009-10-05 Thread Graham Cox


On 02/10/2009, at 6:39 AM, David Alter wrote:


*I have an NSImage that I would like to make a transparent version for
dragging. I have used - (void)dissolveToPoint:(NSPoint)aPoint
fraction:(CGFloat)delta to do this in the past. That appears to be  
getting
deprecated and I would like to update my code. What is the suggested  
way of

doing things. I still need to support 10.4 and up.



To make a drag image from an existing image is pretty easy - just  
instantiate a new image of the same size and copy the first into the  
second, applying a value  1.0 for fraction:



- (NSImage*)dragImageFromImage:(NSImage*) inImage
{
NSImage* dragImage = [[NSImage alloc] initWithSize:[inImage size]];

[dragImage lockFocus];
	[inImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect  
operation:NSCompositeCopy fraction:0.5];

[dragImage unlockFocus];

return [dragImage autorelease];
}


(warning: typed into Mail)

--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: Rounded NSBox/NSView?

2009-10-05 Thread Rob Keniger


On 06/10/2009, at 1:07 PM, Graham Cox wrote:

Views are defined by their frame/bounds rectangles. But there's  
nothing to stop you from setting a round-cornered clipping path at  
the start of your view's drawRect method to clip the view's content  
to a round-cornered rect. Since the view draws nothing by default,  
the fact that the real edge is a rectangle will not be apparent.


Unfortunately the OP is still going to find things difficult. A lot of  
Apple's standard views, such as NSTableView/NSScrollView seem to set  
their own custom clipping path during drawing which overrides anything  
you set, so it's not as straightforward as it might seem.


I agree with Kyle, it is probably a good idea to rethink the design.

--
Rob Keniger



___

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


Two digit dates with NSDateFormatter

2009-10-05 Thread Matthew Lindfield Seager
Hi All,

I have a 10.4 style date formatter applied to an NSTextFieldCell. I
call setTwoDigitStartDate: (tried with both the epoch date and the
reference date) but when I type a date with a two digit year in it sets
the year to 0009 instead of 2009. Am I missing something obvious?
Regards,
Matt

//.h
IBOutlet NSTextFieldCell *transactionDateField; // this outlet *IS* set
correctly in IB

//.m
- (void)awakeFromNib {
NSDate *startDate = [NSDate dateWithTimeIntervalSinceReferenceDate:0];
//NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:0]; // also
tried this
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormat setDateStyle:NSDateFormatterMediumStyle];
[dateFormat setTwoDigitStartDate:startDate];
[dateFormat setLenient:YES];
 [transactionDateField setFormatter:dateFormat];
}


-- 


Safe, comfortable and satisfied? Please consider supporting some people who
aren't!
I'm riding 100 kilometres to raise funds for refugees!
http://my.e2rm.com/personalPage.aspx?registrationID=750445
___

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: Rounded NSBox/NSView?

2009-10-05 Thread Graham Cox


On 06/10/2009, at 2:25 PM, Rob Keniger wrote:


On 06/10/2009, at 1:07 PM, Graham Cox wrote:

Views are defined by their frame/bounds rectangles. But there's  
nothing to stop you from setting a round-cornered clipping path at  
the start of your view's drawRect method to clip the view's content  
to a round-cornered rect. Since the view draws nothing by default,  
the fact that the real edge is a rectangle will not be apparent.


Unfortunately the OP is still going to find things difficult. A lot  
of Apple's standard views, such as NSTableView/NSScrollView seem to  
set their own custom clipping path during drawing which overrides  
anything you set, so it's not as straightforward as it might seem.


I agree with Kyle, it is probably a good idea to rethink the design.



Ah, I was reading the OP's question as if he wanted round corners only  
for his custom views, not all possible views. In that case, yes,  
probably a silly thing to try and attempt, and destined to fail.


--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 check if a class derives from another?

2009-10-05 Thread Rick Mann
Well, that's obvious. I wonder why I didn't see that when I was  
looking at the docs. Thanks!


On Oct 5, 2009, at 18:41:38, Jens Alfke wrote:



On Oct 5, 2009, at 6:35 PM, Rick Mann wrote:

I have a need to tell if a class I'm loading dynamically is derived  
from another class. How do I do this?



Class justLoadedClass = ... ;
if ([justLoadedClass isSubclassOfClass: [MyBaseClass class]]) {
...
}

—Jens



___

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


self release

2009-10-05 Thread Dragos Ionel
I have the following scenario:
A UIViewController, called BookViewController represents a book.

Another UIViewController, ChapterViewController, represents a chapter in the
book.

BookViewController initializes and displays one ChapterViewController, that
represents the current chapter that is read.

The user moves through the pages of the chapter, back and forth. This
functionality belongs to ChapterViewController.

When the last page of the chapter is reached and the user tries to get to
the next page, the code inside the ChapterViewController has somehow to tell
the parent controller, BookViewController that it needs to be released and
another chapter to be initialized.

How can this be achieved?

Your help is appreciated.
Dragos
___

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: wait for the event?

2009-10-05 Thread Matthew Mashyna
Well, I'm an old fart too so I'll try to make one more point and maybe  
that will help. Once the bulb goes on over your head you'll love the  
asynchronous nature of Cocoa. Let asynchronicity work for you. Put  
things in motion and let them tell you when they are done instead of  
watching them.


If you bake brownies you can sit in front of the oven and watch the  
timer or you can do something else until the timer beeps to tell you  
they're ready. That's what the notification center is all about.  
WebViewProgressFinishedNotification will tell you when it's time to  
open the oven.


You're baking your brownies in one set of steps. I want you to have  
two sets of steps: before you start the timer steps and after the  
timer beeps steps. Between these sets of steps you can do whatever you  
want or do nothing or do what the Mrs tells you to do (or since we're  
old we might nap). When the timer beeps you finish the job.


I THINK what you are doing, more or less is something like this:

-(void) awakeFromNib
{
createMyWebView;
startMyWebviewLoading;
	while(mywebview != loaded) // the phone is ringing but you can't  
answer because you have
		wait;	// to keep an eye the brownies. You're the jackpot winner  
if only you could answer.

processTheDOMstuffFromMyWebView;
}

When what I would do would be a two step approach -- without needing  
locks by the way


-(void) awakeFromNib
{
createMyWebView;
	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(webViewProgressFinished:)  
name:WebViewProgressFinishedNotification  object:myWebView];


startMyWebviewLoading;
// they're in the oven, timer's on!
	// nap, read letters to the editor from people who write  
incoherently, watch kitties on YouTube

}

- (void)webViewProgressFinished:(NSNotification*)notification
{
// Bing! They're done, wake up and get back to work
processTheDOMstuffFromMyWebView;
}

If you have a bunch of webviews you could find a scheme to wait until  
they have all finished before final processing. Make a queue of them  
maybe but for this you want to look into using the @synchronized  
directive in webViewProgressFinished when you move things in and out  
of the array.


Look here for more about synchronization. 
http://developer.apple.com/iPhone/library/documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html


On Oct 5, 2009, at 9:58 PM, jon wrote:

oh you've got that right,  I unfortunately have it ingrained for 25  
years of straight pascal in MacOS...  i could destroy a runloop with  
the best of them...


I wish i started cocoa 7 years ago, but it was not to be.  My  
brain is trying to refactor,  and it is fighting mightily... trying  
to keep up with the young-uns who have no such baggage...


I'll look into NSLock thanks,
Jon.

On Oct 5, 2009, at 7:45 PM, Matthew Mashyna wrote:

you need some time to come around to a different way of thinking.  
You are thinking too linearly.





___

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: Bundle is not using icon or CFBundleIdentifier

2009-10-05 Thread Timothy Reaves
 On 04.10.2009, at 06:30, Timothy Reaves wrote:
 I have a bundle defined as a document type for an app.  When I build
 one of these bundles, and double-click it, it opens in my app.  All
 well and good.  Except the following.

   Wait, the bundle is defined as the app's document type? Then of
 course the app's Info.plist provides the icon.

 1) I have an icns file in my bundle, and have the CFBundleIconFile
 key in the info.plist in the bundle  set to the name of the icon.
 The icns file is in the correct location in the bundle.  But the
 bundle does not display the icon.  It justuses the generic OS icon.

   You need to specify the icon in the CFBundleDocumentTypes of your
 application. Only certain bundles get scanned for an Info.plist.
 Documents can contain whatever they want, so the OS gets all
 information for them from the app that owns them.


 I did not know this.  Thanks.

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


A question of CFBundleIdentifier kMDItemContentType

2009-10-05 Thread Timothy Reaves
 I have a bundle wit the CFBundleIdentifier set using the form
com.mycompany.myapp.mybundle.  When I run mdls against it, the
kMDItemContentType shows dyn.ah62d4qmuhk2x42pxsv3g825bsu.  I
thought it was supposed to show the com.mycompany.myapp.mybundle.

 Any idea why this is?

___

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: Rounded NSBox/NSView?

2009-10-05 Thread PCWiz
Thanks for the advice everyone. What I ended up doing was just making  
a plain HUD panel (which is somewhat rounded)


On 2009-10-05, at 9:25 PM, Rob Keniger r...@menumachine.com wrote:



On 06/10/2009, at 1:07 PM, Graham Cox wrote:

Views are defined by their frame/bounds rectangles. But there's  
nothing to stop you from setting a round-cornered clipping path at  
the start of your view's drawRect method to clip the view's content  
to a round-cornered rect. Since the view draws nothing by default,  
the fact that the real edge is a rectangle will not be apparent.


Unfortunately the OP is still going to find things difficult. A lot  
of Apple's standard views, such as NSTableView/NSScrollView seem to  
set their own custom clipping path during drawing which overrides  
anything you set, so it's not as straightforward as it might seem.


I agree with Kyle, it is probably a good idea to rethink the design.

--
Rob Keniger



___

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/pcwiz.support%40gmail.com

This email sent to pcwiz.supp...@gmail.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: app delegate +initialize

2009-10-05 Thread John Baldwin
OK. I've found a pattern, but I don't know how to debug effectively.  
Compiling with Snow Leopard seems to have been a red herring.


Essentially, I copy my app to the test computer by putting it in a  
drop box folder in a user's Public folder. If the app is run from this  
location on the machine, it functions correctly. If, however, I move  
it to the desktop or to Applications, then it fails and the  
+initialize method doesn't seem to get called (based on console  
logging).


Any advice?

John

For context, since this thread has been idle for a while:

On Sep 22, 2009, at 10:50 PM, John Baldwin wrote:


I'm missing something in the loading of an application delegate.

In my MainMenu.xib file, the File's Owner delegate connection is set  
to an AppController object. File's Owner's class is set to  
NSApplication.


In the AppController class, a +(void)initialize method is defined.

The +(void)initialize method gets called and my initialization  
happens as expected on my development machine. Every time, it seems.


But on a second test machine, the method doesn't get called. Ever,  
it seems.


Both machines are running 10.5.8.

I can't figure out what I'm missing to get the AppController class  
loaded and initialized as planned. Could anyone point me in the  
right direction?


On Wednesday Sep 23  3:55 PM, at 3:55 PM, Dave Keck wrote:

Does your class have a subclass, which also has a +initialize  
method, which
doesn't call [super initialize]? That might cause this sort of  
behavior,

because the order in which the classes load may be indeterministic.




___

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: self release

2009-10-05 Thread Graham Cox


On 06/10/2009, at 3:00 PM, Dragos Ionel wrote:

When the last page of the chapter is reached and the user tries to  
get to
the next page, the code inside the ChapterViewController has somehow  
to tell
the parent controller, BookViewController that it needs to be  
released and

another chapter to be initialized.

How can this be achieved?



Many different ways.

One possibility is to define an informal protocol that your chapter  
and book controllers agree upon, such that when the chapter has  
finished, it calls the book controller with something like - 
chapterDidFinish: at which point the book controller can set up the  
next chapter. If chapters are owned by books it it the responsibility  
of the book to release the chapter - it should not typically release  
itself.


How does the chapter know which book it belongs to? Easy - it keeps a  
reference (non-retained) to it which the book sets whenever it  
initialises a chapter.


Essentially what you have here is a straightforward tree structure,  
with book at the root, chapter as the next level of nodes and pages as  
the next level. Any tree-management approach will work here.


--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: Faster adding of files to targets

2009-10-05 Thread Greg Guerin

ML wrote:

But the source is already in Xcode and the targets came over blank.  
Plus the source is nested in many folders.


Is there a way I can edit a target in a text editor and paste in  
the list of files as I was given a list of what files are required  
for each target.



My firs thought was you might be able to script it.  Just a thought.   
It may not be practical, or it may take more time to write and test  
the script than it does to do it manually.  I'm assuming this isn't a  
task you expect to repeat.


My second thought was you might be able to do some careful clicking.   
If all the source files are added, but they aren't assigned to any  
targets, try the following.  I just tested it in Xcode version 3.1.2  
(Leopard) and 3.2 (Snow Leopard).  I'm pretty sure it works on  
earlier Xcode versions, too.


Refer to the left-hand column, where the outline view is labeled  
Groups  Files.  Right-click the Groups  Files heading, then  
choose Target Membership from the contextual menu. A column will  
appear on the left.


Now choose as the Active Target the target to which you want to add  
source files.


Next, expand one of your source groups so all the files are visible.   
In the left-hand column that appeared when Target Membership was  
chosen, you should see a checkbox for each file.  If the file is a  
member of the target it will be checked, if not it will be  
unchecked.  So simply go down the list and check the box for every  
file you want added to the active target.  I would try grouping the  
files in a logical order by target, if possible, so expanding or  
collapsing a single group-folder shows or hides all the relevant  
checkboxes at once.


If you change the active target to your second target, the checkboxes  
will change state to reflect membership in that target.  Again, go  
down the list and check or uncheck the membership checkbox as needed.


There is another pane to review target membership.

First, select one or more groups of source files (yellow folders).   
Right-click one and choose Get Info.  Choose the Targets tab and  
you'll see a target-membership table similar to the column of  
checkboxes.  I mostly use this view to check my work from the Groups  
 Files outline-view, rather than as the primary way to add items to  
targets.  I also find it useful for removing multiple files at once  
from a target.


  -- GG
___

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