Re: odd behavior with NSError?

2009-10-16 Thread mmalc Crawford

On Oct 15, 2009, at 10:41 pm, Nathan Vander Wilt wrote:

 Ouch. So the following pattern is incorrect?
 
 NSError* internalError = nil;
 (void)[foo somethingReturningBool:bar error:internalError];
 if (internalError) {
// ...
 }
 
http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html#//apple_ref/doc/uid/TP40001806-CH204-BAJIIGCC

Note: Cocoa methods that indirectly return error objects in the Cocoa error 
domain are guaranteed to return such objects if the method indicates failure by 
directly returning nil or NO. With such methods, you should always check if the 
return value is nil or NO before attempting to do anything with the NSError 
object.

mmalc

___

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 detect and disable/delay sleep event in cocoa for some critical threads to complete

2009-10-16 Thread Ken Ferry
Hi Parimal,
See NSWorkspace.

NSWorkspaceWillSleepNotification
Posted before the machine goes to sleep. An observer of this message can
delay sleep for up to 30 seconds while handling this notification.

-Ken


On Thu, Oct 15, 2009 at 10:36 PM, Parimal Das parimal@webyog.comwrote:

 Hi All

 When my app is doing some critical I/O transactions with OpenSsl,
 And the user is sleeping the machine (just by folding the laptop).
 Some of the app threads are hanging

 Is there any way in cocoa to do following steps? Also is this logic
 correct?

 1. Detect when a sleep (soft or hard) is issued
 2. Delay sleep till my threads come out
 3. Then continue to going into sleep.

 Please suggest.

 Thank you
 -Parimal Das
 ___

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

 This email sent to kenfe...@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: odd behavior with NSError?

2009-10-16 Thread Greg Guerin

Bill Bumgarner wrote:


On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote:
...
You're saying that some methods go out of their way to trample my  
(potentially unavailable) error storage even on success?



If the error storage is not available, as indicated by passing an  
NSError** of nil, then the unavailable error storage is never  
written.  Correct?


I just want to be sure I understand this completely.

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


Re: odd behavior with NSError?

2009-10-16 Thread Ben Trumbull

(response is pedantic for the purposes of the archive :)


even more better flaming pedanticism!


On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote:


Ouch. So the following pattern is incorrect?


Yes;  it is incorrect.


NSError* internalError = nil;
(void)[foo somethingReturningBool:bar error:internalError];
if (internalError) {
  // ...
}


Specifically, assuming anything about the value of 'internalError'
without first determining the return value of -
somethingReturningBool:error: returned a value indicating an error
(typically NO/0/nil/NULL) is an error.


The specific issue is failing to check the return value of the method  
before touching the internalError value.  You MUST check it.


However, the documentation also encourages not assigning nil to local  
NSError* declarations.  Not initializing locals is imho,  
professionally, realistically, and morally wrong.  It's just a bug  
waiting to happen.  And you have to know it is, just looking at it.   
Whatever might have been saved / gained by not initializing them was  
wasted, for all of time, the first time I had to debug the segfault.   
Which I did, like an idiot, a long time ago.


Let me just say I really especially appreciated the time spent  
debugging other people not initializing their locals.  It wasn't  
visions of sugar plums.


Other people have different perspectives on local variable  
initialization.  Wrong perspectives, but different.  Fortunately now,  
they waste their arguments upon the merciless http://llvm.org/img/DragonFull.png 



- 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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Scott Anguish
I used the semi-colon until Ali at Apple said that we don’t do it that way.

So I no longer do it that way.

Personal preference only.


On Oct 15, 2009, at 8:54 PM, Frederick C. Lee wrote:

 1) I've seen an alternative way of defining a method, with the semicolon 
 after the declaration, before the body:
 
 - (NSArray *)sortedIncredients;   -- notice the semicolon
{
   ...
}
 
 2) ... versus the standard declaration + body of the definition (without the 
 semicolon):
 
 - (NSArray *)sortedIncredients {
  ...
 }
 
 Both seem to work the same.
 Is there any benefit of (1) over (2) or is it merely style of programming?

___

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: odd behavior with NSError?

2009-10-16 Thread Rob Keniger

On 16/10/2009, at 4:45 PM, Ben Trumbull wrote:

 Other people have different perspectives on local variable initialization.  
 Wrong perspectives, but different.  Fortunately now, they waste their 
 arguments upon the merciless http://llvm.org/img/DragonFull.png

Clangdor the Burninator. Excellent.

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


Re: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Kyle Sluder
On Fri, Oct 16, 2009 at 12:01 AM, Scott Anguish sc...@cocoadoc.com wrote:
 I used the semi-colon until Ali at Apple said that we don’t do it that way.

Heh, I didn't use the semi-colon until Tim at Omni said we do it that way.  :-P

The triple-clickiness is a very nice convenience (especially when you
are putting together a pipeline and uniq(1)ing things together) but
it's always bugged me that it's never explicitly allowed.  I think I
filed a radar on its undocumentedness a while back and it came back
dup'd.

--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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Sander Stoks

Hello,

If it's a feature, then it's definitely a new one since the original  
specification of Objective-C.  It turned out to be surprisingly hard  
to find that specification, but I found a grammar description here: http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html


There it says:

instance-method-definition:
inline: sp.gifinline: c2D.gif  [ method-type ]  method-selector  [ declaration-list ]  compound- 
statement


method-selector:
inline: sp.gif
unary-selector
inline: sp.gif
keyword-selector  [ ,  ... ]
inline: sp.gif
keyword-selector  [ ,  parameter-type-list ]

The declaration-list and compound-statement are not specified further  
and are taken from the C spec.  In other words: There's no semicolon.


On the other hand, the grammar spec has been removed from Apple's  
documentation, and I suppose the official line is now Objective-C is  
whatever we ship with Xcode.


--Sander


1) I've seen an alternative way of defining a method, with the
semicolon after the declaration, before the body:

- (NSArray *)sortedIncredients;   -- notice the semicolon
   {
  ...
   }
___

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: Record and Playback immediately

2009-10-16 Thread Jean-Daniel Dupas


Yes, the coreaudio list:

http://lists.apple.com/mailman/listinfo/coreaudio-api

You can find the listing of available lists on

http://lists.apple.com/mailman/listinfo



Le 16 oct. 2009 à 04:41, Symadept a écrit :


Hi Jean,

Thank you very much for your response. Similarly Cocoa dev do we  
have any Macos Dev forums where I can ask this kind of questions.  
And I am working on AQRecord/Play. But still I haven't figured it  
out how to make it immediately.


Regards
Mustafa

On Thu, Oct 15, 2009 at 4:27 PM, Jean-Daniel Dupas devli...@shadowlab.org 
 wrote:


Le 15 oct. 2009 à 09:41, Symadept a écrit :


Hi,
I took the examples of afplay  afrecord. But it does the normal  
record to
completion and play to completion manner. How can I Record into  
buffer and
play from there. I hope instead of AFPlay, Queue based recording and  
playing

would help. Can anybody put some light on this example.


Cocoa-dev is not Macos-dev. This question has nothing to do with  
Cocoa and should be ask on coreaudio list.


That said, maybe the AudioQueueTools sample code may help.

-- Jean-Daniel







-- Jean-Daniel




___

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

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

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

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


Re: Status Bar Search Field Can't Get Focus w/ LSUIElement PList Setting

2009-10-16 Thread Dalmazio Brisinda

In case anyone that is interested, I've solved this problem. Here's how:

In the -awakeFromNib method, add the following two lines (where  
statusItem is an NSStatusItem *):


[statusItem setAction:@selector(statusItemClicked:)];
[statusItem setTarget:self];

and make sure to comment the line:

	// [statusItem setMenu:statusItemMenu];  -- comment so your click  
selection method is invoked instead


Now in the custom selection method -statusItemClicked: do the  
following (where statusItemMenu is an NSMenu *):


// Show the popup menu associated with the status item.
[statusItem popUpStatusItemMenu:statusItemMenu];

	// *** Must activate *after* showing the popup menu to obtain focus  
for the search field. ***

[NSApp activateIgnoringOtherApps:YES];

And that's it.

The problem I was having was placing the -activateIgnoringOtherApps:  
before popping up the status item menu. If you place it  before  
popping up the menu it will only work the first time (from xcode)  
because it auto-activates. But the app needs to be activated after the  
menu is popped up in order for the search field to receive focus.


Oh, and make sure LSUIElement is set in the Info.plist file.

Best,
Dalmazio



On 2009-10-15, at 5:19 PM, Dalmazio Brisinda wrote:

I'm having a problem getting a NSSearchField to work properly in an  
NSStatusItem a la the Apple Help menu or the Apple Spotlight menu.


Here's what's happening.

I create my custom NSStatusItem / menu / custom view/ search field,  
and insert into into the status bar in -awakeFromNib. Setting the  
LSUIElement property in the Info.plist file then results in  
everything displaying and working correctly the very first time the  
NSStatusItem is clicked (after running the application from Xcode  
and it becomes active). The associated menu pops up with the  
custom view and search field, the search field has focus, shows the  
insertion pointer, and I can type a search term, press enter, and  
everything works great. But if I select the NSStatusItem a second  
time to perform a second search there is no insertion pointer, and I  
can't select the search field. When I try clicking around the custom  
view several times I get the following error:


HIViewSetFocus() failed with error -30599

Now, if I don't set the LSUIElement property in the Info.plist file,  
and just run the application as a normal application, then I can get  
around the above problem by selecting the application first (making  
it active) and then the search field in the menu associated with the  
NSStatusItem always gets focus, the insertion pointer appears, and  
everything works fine. But I want to build an application that  
doesn't have a doc icon, window, or main menu using the LSUIElement  
property setting.


From what I understand, it seems that the application needs to be  
active in order for the search field to get focus and for the text  
insertion pointer to appear, but I don't understand how to force  
this for an application that doesn't have a main window, doc icon,  
or menu bar by enabling LSUElement.


Can anyone help?

Best,
Dalmazio



___

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


NSURLRequest SSL Mac vs iPhone

2009-10-16 Thread Greg Hoover
I have the same piece of code making a secure request to a server in a  
Mac application and in an iPhone app.  Both use an NSURLRequest with  
exactly the same settings, message, body, etc.  On the Mac, the  
request succeeds, returning the data expected.  On the iPhone however,  
the request fails with an untrusted server certificate error  
(NSURLErrorDomain -1202).


I suspected that the iPhone implementation somehow doesn't have access  
to the root certificates, so I checked on the servers SSL cert using  
openssl.  Openssl says: unable to verify the first certificate.  So  
now I figure that the Mac (10.6.1) implementation just allows the  
request to proceed when the verification fails (it doesn't return an  
error of any kind actually).  Can anyone shed some light on this?


Thanks,
Greg
___

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: Status Bar Search Field Can't Get Focus w/ LSUIElement PList Setting

2009-10-16 Thread Dalmazio Brisinda

Oops. I spoke too soon.

It *seems* to work because I send a URL off to Safari (which becomes  
active) and then with Safari active I try clicking on the status bar  
item and the search field accepts focus. But if I switch to another  
application first, the same problem appears as before. I have to click  
on the status bar item twice (the popup shows up disappears and shows  
up again) before I can edit the search field.


???

Anyone have any ideas?

Best,
Dalmazio



On 2009-10-16, at 1:36 AM, Dalmazio Brisinda wrote:

In case anyone that is interested, I've solved this problem. Here's  
how:


In the -awakeFromNib method, add the following two lines (where  
statusItem is an NSStatusItem *):


[statusItem setAction:@selector(statusItemClicked:)];
[statusItem setTarget:self];

and make sure to comment the line:

	// [statusItem setMenu:statusItemMenu];  -- comment so your click  
selection method is invoked instead


Now in the custom selection method -statusItemClicked: do the  
following (where statusItemMenu is an NSMenu *):


// Show the popup menu associated with the status item.
[statusItem popUpStatusItemMenu:statusItemMenu];

	// *** Must activate *after* showing the popup menu to obtain focus  
for the search field. ***

[NSApp activateIgnoringOtherApps:YES];

And that's it.

The problem I was having was placing the -activateIgnoringOtherApps:  
before popping up the status item menu. If you place it  before  
popping up the menu it will only work the first time (from xcode)  
because it auto-activates. But the app needs to be activated after  
the menu is popped up in order for the search field to receive focus.


Oh, and make sure LSUIElement is set in the Info.plist file.

Best,
Dalmazio



On 2009-10-15, at 5:19 PM, Dalmazio Brisinda wrote:

I'm having a problem getting a NSSearchField to work properly in an  
NSStatusItem a la the Apple Help menu or the Apple Spotlight menu.


Here's what's happening.

I create my custom NSStatusItem / menu / custom view/ search field,  
and insert into into the status bar in -awakeFromNib. Setting the  
LSUIElement property in the Info.plist file then results in  
everything displaying and working correctly the very first time the  
NSStatusItem is clicked (after running the application from Xcode  
and it becomes active). The associated menu pops up with the  
custom view and search field, the search field has focus, shows the  
insertion pointer, and I can type a search term, press enter, and  
everything works great. But if I select the NSStatusItem a second  
time to perform a second search there is no insertion pointer, and  
I can't select the search field. When I try clicking around the  
custom view several times I get the following error:


HIViewSetFocus() failed with error -30599

Now, if I don't set the LSUIElement property in the Info.plist  
file, and just run the application as a normal application, then I  
can get around the above problem by selecting the application first  
(making it active) and then the search field in the menu associated  
with the NSStatusItem always gets focus, the insertion pointer  
appears, and everything works fine. But I want to build an  
application that doesn't have a doc icon, window, or main menu  
using the LSUIElement property setting.


From what I understand, it seems that the application needs to be  
active in order for the search field to get focus and for the  
text insertion pointer to appear, but I don't understand how to  
force this for an application that doesn't have a main window,  
doc icon, or menu bar by enabling LSUElement.


Can anyone help?

Best,
Dalmazio





___

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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Bill Bumgarner


On Oct 16, 2009, at 12:17 AM, Sander Stoks wrote:

If it's a feature, then it's definitely a new one since the original  
specification of Objective-C.  It turned out to be surprisingly hard  
to find that specification, but I found a grammar description  
here:http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Concepts/ 
ObjectiveC/B_Grammar/Grammar.htmld/index.html


There it says:

instance-method-definition:
sp.gifc2D.gif  [ method-type ]  method-selector  [ declaration- 
list ]  compound-statement


method-selector:
sp.gifunary-selector
sp.gifkeyword-selector  [ ,  ... ]
sp.gifkeyword-selector  [ ,  parameter-type-list ]

The declaration-list and compound-statement are not specified  
further and are taken from the C spec.  In other words: There's no  
semicolon.


On the other hand, the grammar spec has been removed from Apple's  
documentation, and I suppose the official line is now Objective-C  
is whatever we ship with Xcode.


I haven't booted my NS 0.8 cube in about a decade, but I'm pretty sure  
the semi-colon was always required in the header file and always  
allowed in the @implementation.


'Twas many a moon ago, but, I do distinctly remember triple-clicking  
method declarations from headers (with semis) to copy-paste into my  
implementation without deleting the semi.   It always stuck with me as  
an über-convenience.


b.bum

___

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

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

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

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


Re: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Uli Kusterer


On 16.10.2009, at 03:35, Graham Cox wrote:



On 16/10/2009, at 12:30 PM, Roland King wrote:

I'm ploughing it with you, I hate it too and spend 30 seconds every  
time I let XCode stub out a function for me moving the brace onto  
the correct line,  
andputtingspacesbackbetweenparanetheses,bracketsandarguments so I  
have a hope in hell of reading the code later.



Agree 2000%!

But you don't have to let Xcode frustrate you like this - you can  
define your own templates for all of the stubs it inserts.


 How? Where?!!! :-D

-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.masters-of-the-void.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: NSURLRequest SSL Mac vs iPhone

2009-10-16 Thread Andrew Farmer

On 16 Oct 2009, at 00:48, Greg Hoover wrote:
I have the same piece of code making a secure request to a server in  
a Mac application and in an iPhone app.  Both use an NSURLRequest  
with exactly the same settings, message, body, etc.  On the Mac, the  
request succeeds, returning the data expected.  On the iPhone  
however, the request fails with an untrusted server certificate  
error (NSURLErrorDomain -1202).


My guess is the root certificates are different on the two platforms.  
Just a guess, but if the server you're connecting to is using a cert  
signed by a weird authority, that might be it.


I suspected that the iPhone implementation somehow doesn't have  
access to the root certificates, so I checked on the servers SSL  
cert using openssl.  Openssl says: unable to verify the first  
certificate.  So now I figure that the Mac (10.6.1) implementation  
just allows the request to proceed when the verification fails (it  
doesn't return an error of any kind actually).  Can anyone shed some  
light on this?


OpenSSL is a red herring. NSURLRequest doesn't use openssl to verify  
certificates. In fact, openssl has no root certs installed at all by  
default on OS X, so it'll fail to verify any certificate at all.

___

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: debugging cursors

2009-10-16 Thread Uli Kusterer

On 08.10.2009, at 23:02, David M. Cotter wrote:
sorry, yes.  when the user types a number in a box and presses  
enter, i create a cursor based on that number and set it.


 So now you've told us what you are doing, you still haven't said  
why ... ? Please tell us, in high-level terms that a user would  
understand, why you need to do this, and it can help us provide an  
alternate approach.


 You are really making it hard to give you answers. I don't like the  
article I. Savant linked to, because it is very condescending, but  
here's another one along the same vein that may help you find a way to  
improve your question so we can actually answer it: http://www.mikeash.com/getting_answers.html


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://groups.yahoo.com/group/mac-gui-dev/

___

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

2009-10-16 Thread gMail.com
Thank you I.S.
This is what I am doing. Overriding the tableView APIs and keeping trace of
the selection through my array.

You're going to have to track changes in selection yourself
 (examine the NSTableView API - there are methods to help you with this).
Since I have noticed that even
selectRow:(int)rowIndex byExtendingSelection:(BOOL)flag
gets invoked with a sorted index (like 0, 1, 2...) in case of multiple
selection, I guess I have to override mouseDown and keyDown to invoke
selectRow by myself passing the sorted and right sequence of indexes.
If you meant some other specific API, please let me know which one.

 1 - Click the third row, shift-click the seventh row. Now the
 selection index set is now {2, 3, 4, 5, 6}.
Ok, this is equal to my selection sort order
 
 2 - With that last result, command-click row 3, then, 4, then 3 again.
 The selection set is now {2, 3, 5, 6}.
command-click row 3 - now my selection is {3, 4, 5, 6}
command-click row 4 - now my selection is {4, 5, 6}
command-click row 3 - now my selection is {4, 5, 6, 3}

 3 - Click row 7 shift-click row 6, then Cmd-click row 8. Selection is
 now {5, 6, 7}.
click row 7 - now my selection is {6}
shift-click row 6 - now my selection is {6, 5}
command-click row 8 - now my selection is {6, 5, 7}
It makes sense.


:-D
--
L.L.

 Da: I. Savant idiotsavant2...@gmail.com
 Data: Wed, 14 Oct 2009 12:11:39 -0400
 A: gMail.com mac.iphone@gmail.com
 Cc: cocoa-dev@lists.apple.com
 Oggetto: Re: SelectedRowIndexes
 
 On Oct 14, 2009, at 11:55 AM, gMail.com wrote:
 
Oh, come on, at least pick a witty pseudonym. :-D
 
 
 when I call [tableView selectedRowIndexes];
 I always get a indexSet already sorted by row.
 Instead I need to sort it as the selection order.
 I mean, if the user selected the rows in the order
 
 Row 6
 Row 2
 Row 8
 
 I want to get 6, 2, 8 and not 2, 6, 8 as I get now with
 selectedRowIndexes.
 How can I do that?
 
You can't. Not with -selectedRowIndexes. As you said, it returns an
 NSIndexSet. Sets are unordered by nature. Not in the sense you're
 looking for. They're kept internally as an ascending-order list for
 efficiency.
 

 
Also consider a few scenarios that will affect the selection order:
 
 1 - Click the third row, shift-click the seventh row. Now the
 selection index set is now {2, 3, 4, 5, 6}.
 
 2 - With that last result, command-click row 3, then, 4, then 3 again.
 The selection set is now {2, 3, 5, 6}.
 
 3 - Click row 7, shift-click row 6, then Cmd-click row 8. Selection is
 now {5, 6, 7}.
 
Considering these scenarios, what would your selection order be in
 each? What about combining them? Selection can go in many directions
 and things can be added and removed to/from anywhere in the set. Think
 carefully - getting this basic behavior wrong has the potential to
 annoy users.
 
 
 Please note that I can select the rows even programmatically,
 because the
 user selects an object on the canvas.
 
Same as above - you'll have to track the order. I'd make a table
 view subclass and override (calling super, then my custom code) the
 selection-changing methods, then provide a separate selection-getting
 routine (to provide an ordered array of indexes) called
 orderedSelection or something similar. This gives you one central
 place for user- or code-initiated selection changes.
 
 --
 I.S.
 
 


___

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

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

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

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


Re: SelectedRowIndexes

2009-10-16 Thread gMail.com
Thanks. I will file a request.

 Well, you could do it yourself with heavy subclassing of NSTableView and
 overriding the -selectRow type of methods and keeping track of the order
 yourself.
I did it, using my own array, but I have noticed that in case of multiple
selection (by clicking on the tableView rows), even
selectRow:(int)rowIndex byExtendingSelection:(BOOL)flag
gets always invoked sequentially with a positive incremental rowIndex (like
0, 1, 2...). This doesn't help.
I guess I have to override mouseDown and keyDown then invoke by myself
selectRow sequentially passing my rowIndex.



 Da: Corbin Dunn corb...@apple.com
 Data: Wed, 14 Oct 2009 09:38:16 -0700
 A: gMail.com mac.iphone@gmail.com
 Cc: cocoa-dev@lists.apple.com
 Oggetto: Re: SelectedRowIndexes
 
 
 On Oct 14, 2009, at 8:55 AM, gMail.com wrote:
 
 Hi,
 when I call [tableView selectedRowIndexes];
 I always get a indexSet already sorted by row.
 Instead I need to sort it as the selection order.
 I mean, if the user selected the rows in the order
 
 Row 6
 Row 2 
 Row 8
 
 I want to get 6, 2, 8 and not 2, 6, 8 as I get now with selectedRowIndexes.
 How can I do that?
 
 
 You can't. Please log a bug requesting this ability (I have heard of more than
 one person wanting this).
 corbin



___

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

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

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

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


Re: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Graham Cox


On 16/10/2009, at 7:12 PM, Uli Kusterer wrote:

But you don't have to let Xcode frustrate you like this - you can  
define your own templates for all of the stubs it inserts.


How? Where?!!! :-D


http://arstechnica.com/apple/guides/2009/04/cocoa-dev-design-your-own-xcode-project-templates.ars

http://www.cocoadev.com/index.pl?XcodeProjectTemplates

http://www.macresearch.org/custom_xcode_templates

http://briksoftware.com/blog/?p=28

--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 retrieve the font information from TrueType font file?

2009-10-16 Thread XiaoGang Li
Hi,
 In the resource directory of my application bundle, there is a
directory named Fonts, which includes all the fonts I can use. I means
that the other uncontained fonts which come from the system or third party
application will be invalid in my application. when the users use my
application to draw text, only the fonts contained in the bundle should be
valid. This is the backgroud of my question.
After getting the font name from the font used by the user, need to
check whether this font is valid, so, how to get the font information from
my font files.
I have read NSFontManager, it can get all the fonts in the system, I
just to want to get the font name from my .ttf font file.
I also have read ATS relalted, but failed to find a solution, there is
no such interface to get detailed information from a ttf file.

Hope the list can help me, the point of  my question is how to get the
information from the ttf font file?

Thanks.
___

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

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

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

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


Re: odd behavior with NSError?

2009-10-16 Thread Kevin Bracey
If we get an NSError, or in the case of NSAppleScript an NSDictionary  
with the error description, what is the Retain count and do we release  
it when we're done with it?


I'd been not releasing them, I didn't allocate or copy it, but when I  
Build and Analyzed my code in 3.2 on Snow Leopard it said that I had a  
retain count of +1. Am I leaking?


Any advice on this?

Cheers
Kevin
___

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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Sander Stoks

Woah,

I'm sorry everybody... only when I saw my post in the list I realized  
that my copy-paste from Safari contained spacer GIFs.  Here's the  
story again.


---

If it's a feature, then it's definitely a new one since the original
specification of Objective-C.  It turned out to be surprisingly hard
to find that specification, but I found a grammar description here: 
http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html

There it says:

instance-method-definition:
  [ method-type ]  method-selector  [ declaration-list ]  compound- 
statement


method-selector:
  unary-selector
  keyword-selector  [ ,  ... ]
  keyword-selector  [ ,  parameter-type-list ]

The declaration-list and compound-statement are not specified further
and are taken from the C spec.  In other words: There's no semicolon.

On the other hand, the grammar spec has been removed from Apple's
documentation, and I suppose the official line is now Objective-C is
whatever we ship with Xcode.

---

I already read the reply that it has probably always been in the  
language as a hidden feature,  but my C++ past has made me weary of  
simply check what the compiler accepts instead of look it up in the  
standard.  Since we're getting an alternative ObjC compiler now (with  
clang), perhaps a proper standard becomes more important..?


--Sander

___

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: GC crash due to being naughty

2009-10-16 Thread Kirk Kerekes

...

  This led me to generate a new hypothesis: that I am an idiot.  I
have now proven that hypothesis to my full satisfaction.

...

A remarkably universal observation. I certainly have made it many  
times about myself. One of my rules of thumb about Cocoa coding is  
Code for your Inner Idiot.



___

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: Toolbar with capsule style items (Similiar to Mail)

2009-10-16 Thread Stamenkovic Florijan

On Oct 15, 2009, at 13:39, Mazen Abdel-Rahman wrote:


Hi All,

I am new at programming with Cocoa -  so  I had a basic question.

Is it possible to create a capsule style toolbar with a search field  
in it (like how Mail's toolbar is) just using interface building to  
create the UI?  And if so - how would it be done?


I am trying to create by first dragging a Toolbar item to the  
window.  When I try to put a segmented control or a search control  
in the toolbar it gets rejected.


If I understand you correctly you are dragging things into the toolbar  
itself, on the window. What you need to do is first double click the  
toolbar. This will bring up a sheet similar to what you get when  
customizing the toolbar in whichever app. You drag toolbar elements  
into that sheet from the IB palettes. Then, to customize the toolbar  
itself, you drag items from the sheet into the toolbar area of your  
window.


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


NSInvocationOperations and background Threads

2009-10-16 Thread John Love

NSOperation.pdf states:

For a non-concurrent operation, an operation queue automatically  
creates a thread and calls the operation object’s start method, the  
default implementation of which configures the thread environment and  
calls the operation object’s main method to run your custom code.


In my app, I have a very long for-loop, each time thru which, I call  
NSInvocationOperation's -initWithTarget:selector:object:, followed by  
a call to add the resulting Operation to the NSOperationQueue.  This  
queue is previously created via itsQueue = [[NSOperationQueue alloc]  
init], itsQueue being a instance variable.


I do not have a custom -start or a -main method, so I count on the  
default -start and -main methods to handle the creation of a  
background Thread for me.  It appears however, that in my app there is  
no background Thread that begins and the reason for that is because my  
app's window stays in the background until all NSOperations are  
complete.  Any clues?


By the way, when I alternately use either +detachNewThreadSelector or  
NSMachPorts, everything works just fine, including the app's window  
coming to the foreground, which event I force via  [NSApp  
activateIgnoringOtherApps:YES] even before I start the background  
Thread.


One last question .. if a new background Thread is automatically  
started when I add the new NSInvocationOperation to the  
NSOperationQueue, is there a NSAutoreleasePool automatically created  
before the above selector method starts and is this NSAutoreleasePool  
released after this method finishes?


John Love
Touch the Future! Teach!



___

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: NSURLConnection timeout -- what happens?

2009-10-16 Thread Stuart Malin


On Oct 15, 2009, at 3:59 PM, Jens Alfke wrote:


On Oct 15, 2009, at 11:44 AM, Stuart Malin wrote:

I have looked through the NSURLConnection class reference, the  
NSURLRequest class reference, the URL Loading System guide, queried  
Google, searched mailing list archives, and even looked through  
NSURLConnection.h, but can not find documentation about what  
happens when an NSURLConnection times out.  I presume that -- for  
the asynchronous case -- the invoker's - 
connection:didFailWithError: selector will be messaged. Is this so?  
Where is that defined?


I think so, but I don't remember for sure. Why not try it? Set a  
timeout of 0.1 sec and send a request to a slow server.


(shhepishly): good suggestion.  Have done so: yes, an error is the  
result with code 1001, which is defined in NSURLError.h as  
NSURLErrorTimedOut


But I haven't been able to find any documentation of what the  
possible errors are, and what the data would be for those reported  
failures.


NSURLError.h.


Sure enough -- there they are.

But in practice you can sometimes get errors from other domains too,  
especially if SSL is involved.


Well, logging will again be my friend :-)

The URL Loading System guide has an example that uses the key  
NSErrorFailingURLStringKey to access a value from the error  
object's userInfo dictionary. Where might other such keys be defined?


Tip: To see where a symbol is defined, hold down Command and double- 
click it. If you'd done that with that key, it would have taken you  
to NSURLError.h and answered part of your question.


Ah, I hadn't tried copying that symbol from the docs to Xcode in order  
to search for its definition -- that's a good idea that I will hold  
for the future.


Also, thanks for the Command-double-click tip -- I had been doing  
Option-click and then selecting Jump to definition from the  
contextual menu.


___

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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread Andy Lee

On Oct 16, 2009, at 3:55 AM, Bill Bumgarner wrote:
I haven't booted my NS 0.8 cube in about a decade, but I'm pretty  
sure the semi-colon was always required in the header file and  
always allowed in the @implementation.


'Twas many a moon ago, but, I do distinctly remember triple-clicking  
method declarations from headers (with semis) to copy-paste into my  
implementation without deleting the semi.   It always stuck with me  
as an über-convenience.


I too had the feeling this feature had been around forever, or at  
least a pretty long time, possibly as far back as the NeXT days.


I don't like it because:

* It's jarring to see the semicolon used as a terminator in the method  
declaration and as something else -- I'm not sure what; a superfluous  
separator? -- in the definition where the line of code is otherwise  
identical.


* I sometimes look for method overrides in my project by doing a  
global search for )myMethod (trusting myself to be consistent about  
having no space between the return type and the method name).  If both  
the declaration and the definition use the line (void)myMethod;, it  
takes slightly more effort to distinguish the declarations from the  
definitions in the search results.  Sure, I could address this by  
putting the opening brace on the same line, but I strongly prefer the  
method's opening brace on its own line.


* I'm paranoid about getting used to the pattern

blah blah blah;
{
   etc etc
}

...because it might make it easier to overlook a bug like:

if ([they respondsToSelector:@selector(didStartItFirst)]  [(id) 
they didStartItFirst]);

{
[self startThermonuclearWar];
}

--Andy

___

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: Programming Style: Method Definition with or without a semicolon.

2009-10-16 Thread glenn andreas


On Oct 16, 2009, at 2:55 AM, Bill Bumgarner wrote:



On Oct 16, 2009, at 12:17 AM, Sander Stoks wrote:

If it's a feature, then it's definitely a new one since the  
original specification of Objective-C.  It turned out to be  
surprisingly hard to find that specification, but I found a grammar  
description here:http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/ 
Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html


There it says:

instance-method-definition:
sp.gifc2D.gif  [ method-type ]  method-selector  [ declaration- 
list ]  compound-statement


method-selector:
sp.gifunary-selector
sp.gifkeyword-selector  [ ,  ... ]
sp.gifkeyword-selector  [ ,  parameter-type-list ]

The declaration-list and compound-statement are not specified  
further and are taken from the C spec.  In other words: There's no  
semicolon.


On the other hand, the grammar spec has been removed from Apple's  
documentation, and I suppose the official line is now Objective-C  
is whatever we ship with Xcode.


I haven't booted my NS 0.8 cube in about a decade, but I'm pretty  
sure the semi-colon was always required in the header file and  
always allowed in the @implementation.


'Twas many a moon ago, but, I do distinctly remember triple-clicking  
method declarations from headers (with semis) to copy-paste into my  
implementation without deleting the semi.   It always stuck with me  
as an über-convenience.


b.bum



You can (or at least could) copy the entire @interface section from  
the .h, paste into the .m and change @interface to @implementation and  
it would compile.


So yes, this is legal:

@implementation MyObject : NSObjectSomeProtocol {
id myIvar;
}
- (void) doSomething;
@end

Not that I'd recommend or even admit to doing this (I have no idea  
what happens if the @implementation class details are different from  
the @interface ones, and, again, not that I'd ever admit to having  
done this, it is easy to accidentally write your implementation in  
your .h file and leave the pasted @interface in your .m).



Glenn Andreas  gandr...@gandreas.com
The most merciful thing in the world ... is the inability of the human  
mind to correlate all its contents - HPL


___

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


NSCollectionView issues

2009-10-16 Thread Half Activist

Hi,
	I'm using a NSCollectionView to display a stack of items (a table)  
but since what's display is far too complex to be laid out  
programmatically I went for the NSCollectionView. And it's been all  
problems from the beginning.
	First of all with setContent that never worked no matter what I  
did...it only works if I bind the content to an nsarraycontroller.


	Now, when I add a new item in this table i want to be able to  
scroll it to the displayed area of the view, but the  
frameForItemAtIndex: method only appeared in 10.6, so I decided to use  
the subviews and get the frame this way, and now what did I discover:  
Suppose I have N items and therefore N subviews in the  
NSCollectionView, after changing the array that now contains N + 1  
items, the nscollectionview has after the update N + N + 1 subviews!

So, accessing subviews is not an option either.

If anyone knows how to do fix these bugs, and how to disable the  
animation, i'd be really glad. I'm considering writing an homebrew  
nscollectionview.


regards.
___

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: NSURLRequest SSL Mac vs iPhone

2009-10-16 Thread Greg Hoover


On Oct 16, 2009, at 1:13 AM, Andrew Farmer wrote:


On 16 Oct 2009, at 00:48, Greg Hoover wrote:
I have the same piece of code making a secure request to a server  
in a Mac application and in an iPhone app.  Both use an  
NSURLRequest with exactly the same settings, message, body, etc.   
On the Mac, the request succeeds, returning the data expected.  On  
the iPhone however, the request fails with an untrusted server  
certificate error (NSURLErrorDomain -1202).


My guess is the root certificates are different on the two  
platforms. Just a guess, but if the server you're connecting to is  
using a cert signed by a weird authority, that might be it.




It's signed by Verisign.  Where does NSURLRequest and its supporting  
routines find the CA root certs?


I suspected that the iPhone implementation somehow doesn't have  
access to the root certificates, so I checked on the servers SSL  
cert using openssl.  Openssl says: unable to verify the first  
certificate.  So now I figure that the Mac (10.6.1) implementation  
just allows the request to proceed when the verification fails (it  
doesn't return an error of any kind actually).  Can anyone shed  
some light on this?


OpenSSL is a red herring. NSURLRequest doesn't use openssl to verify  
certificates. In fact, openssl has no root certs installed at all by  
default on OS X, so it'll fail to verify any certificate at all.



Well when I run OpenSSL on my own server it checks out fine.  I was  
thinking that my CA root certs were just out of date, but when I run  
OpenSSL its more like it can't find several certs that should be part  
of the chain.


___

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: NSCollectionView issues

2009-10-16 Thread Jim Turner
10.5's collection view is, safe to say, kind of a train wreck. I've
had to work around quite a few things.  Your problem is solvable by
asking the NSCollectionViewItem created for your new table element for
its view and to have that view scrollRectToVisible: for its bounds.

If you need to get the ViewItem for a specific index (available via
NSCollectionView's itemAtIndex: under 10.6), you'll need to go into
slightly undocumented land and look at the collection view's
_targetItems ivar. It contains the list of NSCollectionViewItems
currently displayed in the collection view.  Make sure you
conditionalize this for 10.6 as _targetItems isn't there anymore.

Hope that helps

-- 
Jim
http://nukethemfromorbit.com


On Fri, Oct 16, 2009 at 9:32 AM, Half Activist halfactiv...@gmail.com wrote:
 Hi,
        I'm using a NSCollectionView to display a stack of items (a table)
 but since what's display is far too complex to be laid out programmatically
 I went for the NSCollectionView. And it's been all problems from the
 beginning.
        First of all with setContent that never worked no matter what I
 did...it only works if I bind the content to an nsarraycontroller.

        Now, when I add a new item in this table i want to be able to
 scroll it to the displayed area of the view, but the frameForItemAtIndex:
 method only appeared in 10.6, so I decided to use the subviews and get the
 frame this way, and now what did I discover: Suppose I have N items and
 therefore N subviews in the NSCollectionView, after changing the array that
 now contains N + 1 items, the nscollectionview has after the update N + N +
 1 subviews!
 So, accessing subviews is not an option either.

 If anyone knows how to do fix these bugs, and how to disable the animation,
 i'd be really glad. I'm considering writing an homebrew nscollectionview.

 regards.
 ___

 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/jturner.lists%40gmail.com

 This email sent to jturner.li...@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: NSCollectionView issues

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 10:32 AM, Half Activist wrote:

	I'm using a NSCollectionView to display a stack of items (a table)  
but since what's display is far too complex to be laid out  
programmatically I went for the NSCollectionView. And it's been all  
problems from the beginning.


  Yes, depending on what you need from it, its convenience can be  
outweighed by its limitations.



	First of all with setContent that never worked no matter what I  
did...it only works if I bind the content to an nsarraycontroller.


  Okay ... what have you tried? Can't help if you don't say what you  
did.



	Now, when I add a new item in this table i want to be able to  
scroll it to the displayed area of the view,


  Can you rephrase this? The displayed area of the view is  
ambiguous, but generally the displayed area is displayed because the  
scroll vie is already scrolled to that area. :-)


  Did you mean you want to scroll to the currently-selected (or newly- 
added) collection view item (or some UI element within that view item)?



Suppose I have N items and therefore N subviews in the  
NSCollectionView, after changing the array that now contains N + 1  
items, the nscollectionview has after the update N + N + 1 subviews!

So, accessing subviews is not an option either.


  I haven't heard of this problem but then again, I had dismissed  
NSCollectionView early on as not being up to the tasks for which I'd  
hoped it'd be useful, so my experience with it is limited.


  Again, what did you try? How did you go about this? I find it odd  
that it doesn't scroll to the selection (if that's what you were  
doing), but I imagine if you ask the array controller for the  
*arranged* index of the object just inserted (whole other question -  
ask it if it's required), then ask the collection view for the - 
itemAtIndex:, you can ask that item for its -view, then use the  
scrolling methods as needed.



If anyone knows how to do fix these bugs, and how to disable the  
animation, i'd be really glad.


  I don't think there's any (public API) way to disable the  
animation. Why do you want to do that?




I'm considering writing an homebrew nscollectionview.


  Depending on your needs, this could be easier. If you only need one  
column, it's *almost* trivial. Especially if, like NSCollectionView,  
the size of each view is the same.


  If they can vary in vertical size, you can even use the same  
prototype view approach by caching at least the height of the items  
for the current view width, which lets you quickly size the whole view  
and work out the rect for the desired item (or the items for the  
desired rect). This can *greatly* improve performance for lots of  
irregularly-sized items.


  Of course there is more than one way to approach this but building  
a basic one-column layout view like this is fairly simple. Even adding  
drag-and-drop to this isn't too difficult for a moderately-experienced  
Cocoa developer.


--
I.S.




___

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

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

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

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


Re: NSCollectionView issues

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 11:42 AM, Jim Turner wrote:


If you need to get the ViewItem for a specific index (available via
NSCollectionView's itemAtIndex: under 10.6)


  Bah - I failed to notice -itemAtIndex: is also 10.6-only.

  I mostly agree with the train wreck sentiment. The 10.5  
implementation seemed useful only for its most common demonstration:  
image thumbnails.


--
I.S.




___

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

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

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

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


Re: How to retrieve the font information from TrueType font file?

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 3:31 AM, XiaoGang Li wrote:


other uncontained fonts which come from the system or third party
application will be invalid in my application. when the users use my
application to draw text, only the fonts contained in the bundle  
should be

valid. This is the backgroud of my question.


I don't know what your applications does, but that seems like a really  
strange feature. I have a lot of fonts installed, and when I use an  
app I expect to be able to use them. If the app only let me use a  
couple of fonts that were bundled with it, I'd call that a bug.


(Also, do you have permission to bundle these fonts? Most fonts can't  
be re-distributed without a commercial license from the owner.)



   After getting the font name from the font used by the user, need to
check whether this font is valid, so, how to get the font  
information from

my font files.


Isn't the set of bundled fonts hard-coded? Just make a list of their  
names (maybe in a plist file) and read that. I think trying to extract  
the names out of the font files themselves would be much too difficult  
since there's no API for it.


—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: NSURLRequest SSL Mac vs iPhone

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 7:52 AM, Greg Hoover wrote:

It's signed by Verisign.  Where does NSURLRequest and its supporting  
routines find the CA root certs?


In the Keychain. You can see the list of pre-installed root certs by  
launching Keychain Access and selecting System Roots from the  
keychain list. (It's also possible for other roots to be added to the  
system or login keychain, esp. if you're in a corporate environment.)


I'm not sure if there's a way to find the root certs on iPhone. It  
would certainly have to be done programmatically, as there's no UI for  
viewing the keychain. The Keychain API on iPhone is entirely different  
than the one on Mac OS, and even more confusing.


You should probably take this to the apple-cdsa list, which is  
actually for any security/crypto related issues.


—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: A good Obc-C framework for sending email?

2009-10-16 Thread Jens Alfke


On Oct 15, 2009, at 4:34 PM, Peter Hudson wrote:


The ED code looks like interesting and I will give it a try as well.
Does anybody know of a good primer on creating / sending  email  
( possibly in a Cocoa / Objective-C environment )


I don't think there is one, given how hard it is to even find code for  
doing it at all.


BTW I just mentioned off-list to Ben that these days it's probably  
better not to use email at all, when trying to send a message back  
from the app to the developer (like for feedback or crash reports.)  
Instead use HTTP — on the client side make an NSURLConnection to send  
the data in a POST, and on the server just hack together a little PHP  
script to receive the data and process it. Uli Kusterer's  
UKCrashReporter does this.


—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: NSInvocationOperations and background Threads

2009-10-16 Thread Nick Zitzmann


On Oct 16, 2009, at 7:01 AM, John Love wrote:

I do not have a custom -start or a -main method, so I count on the  
default -start and -main methods to handle the creation of a  
background Thread for me.


You don't need them if you're using NSInvocationOperation. The  
documentation was talking about those methods being defined in the  
NSOperation subclass, and NSInvocationOperation just does the  
invocation in its main method. And they don't create the thread;  
NSOperation spins off the thread in different ways depending on your  
OS and CPU architecture.


It appears however, that in my app there is no background Thread  
that begins and the reason for that is because my app's window stays  
in the background until all NSOperations are complete.  Any clues?


Can you verify this in the debugger by breaking on the method being  
invoked? I've never seen an NSInvocationOperation run in the same  
thread in which it was added to a queue; in fact, this should not be  
possible in Snow Leopard and later.


Nick Zitzmann
http://www.chronosnet.com/

___

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

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

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

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


Re: A good Obc-C framework for sending email?

2009-10-16 Thread Torsten Curdt
 The ED code looks like interesting and I will give it a try as well.
 Does anybody know of a good primer on creating / sending  email ( possibly
 in a Cocoa / Objective-C environment )

 I don't think there is one, given how hard it is to even find code for doing
 it at all.

Maybe this could be helpful?

http://vafer.org/blog/20080604120118

 BTW I just mentioned off-list to Ben that these days it's probably better
 not to use email at all, when trying to send a message back from the app to
 the developer (like for feedback or crash reports.) Instead use HTTP — on
 the client side make an NSURLConnection to send the data in a POST, and on
 the server just hack together a little PHP script to receive the data and
 process it.

Totally agree.

 Uli Kusterer's UKCrashReporter does this.

And others too ;)

http://vafer.org/projects/feedbackreporter/

We have a bunch of them these days actually:

http://www.red-sweater.com/blog/860/crash-reporter-roundup

cheers
--
Torsten
___

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: odd behavior with NSError?

2009-10-16 Thread Jerry Krinock

On 2009 Oct 16, at 03:44, Kevin Bracey wrote:

If we get an NSError, or in the case of NSAppleScript an  
NSDictionary with the error description, what is the Retain count


The retain count of an object is equal to 1 for alloc + the number of - 
retain messages - the number of -release messages that the object has  
been sent.  (I realize that's not the answer you wanted ... read on.)



and do we release it when we're done with it?


No, because you didn't alloc, copy or retain it.

I'd been not releasing them, I didn't allocate or copy it, but when  
I Build and Analyzed my code in 3.2 on Snow Leopard it said that I  
had a retain count of +1.


It had better be, because if it was not = 1 it would be gone.


Am I leaking?


No.

Whoever retained it is responsible for releasing it.  In this trivial  
case, *probably* whoever gave it to you autoreleased it.  But use such  
conjectures for debugging only, never for design.


___

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: odd behavior with NSError?

2009-10-16 Thread Greg Guerin

Kevin Bracey wrote:

If we get an NSError, or in the case of NSAppleScript an  
NSDictionary with the error description, what is the Retain count  
and do we release it when we're done with it?


Wrong question.  The retain count is not an ownership count.  The  
right question is Do I own it?  If you own it, you're responsible  
for releasing it.  If you don't own it, you must not release it.



I'd been not releasing them, I didn't allocate or copy it, but when  
I Build and Analyzed my code in 3.2 on Snow Leopard it said that I  
had a retain count of +1. Am I leaking?


Any advice on this?



Find the word NSError on this page:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ 
MemoryMgmt/Articles/mmObjectOwnership.html


It's under the heading Objects Returned by Reference.

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


Re: NSURLRequest SSL Mac vs iPhone

2009-10-16 Thread Alastair Houghton

On 16 Oct 2009, at 15:52, Greg Hoover wrote:

It's signed by Verisign.  Where does NSURLRequest and its supporting  
routines find the CA root certs?


Are you sure it's the root certificate that it needs and not some  
certificate beneath that?  Some CAs sign their SSL certs with  
certificates a few layers down from the actual root, and if you don't  
include the extra ones in the certificate chain **on your web server**  
then some machines would flag up an error while others (if they had  
some of these certificates installed locally) wouldn't.


That seems to match the symptoms you're reporting, so it's worth  
checking out.


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: A good Obc-C framework for sending email?

2009-10-16 Thread Alastair Houghton

On 16 Oct 2009, at 03:54, Andrew Farmer wrote:


On 15 Oct 2009, at 13:34, Ben Haller wrote:
Hi all.  I need a good Obj-C framework for sending email.  I used  
to use the Message.framework associated with Apple's Mail, but they  
killed that a long time ago, sadly.  Then I used Pantomime; but it  
seems to also be abandoned, now, and it is crashing on 10.5 (and it  
was never terribly reliable anyway).  Does anybody know of a good  
replacement?  I haven't had any luck trying to find one using Google.


Keep in mind that many users may not have any SMTP server configured  
-- an increasing number of users use webmail for everything, and  
don't have a desktop client set up. And, in many of these cases,  
they may be behind a firewall or ISP that blocks connections to port  
25 (SMTP) on all servers other than their own. If you need to  
reliably deliver email from a user's machine, you'll probably need  
to set up a gateway of some sort yourself, or have them input SMTP  
settings manually.


Or you could do what we do and ask their mail client to deliver it for  
us.  The code we use for that is Open Source, and you can get it here:


  http://www.coriolis-systems.com/opensource/

CSMail can also generate messages and pop them up in their client  
ready for them to send themselves, which is something we use in some  
circumstances as well.


(It's possible that we have updated CSMail a bit since the version on  
that page, I don't know... but if someone's interested in using it, I  
can check.)


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


Extract plain text content from a Text View

2009-10-16 Thread Ian Piper

Hi all,

Is there a way to get the plain text content out of an NSTextStorage  
object (displaying using a Text View) that contains rich text and  
images? I want to figure out a way to build a search predicate that  
will allow me to search a Text View and I think this is likely to be  
the only way.


Thanks,


Ian.
--

___

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

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

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

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


Re: A good Obc-C framework for sending email?

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 12:04 PM, Alastair Houghton wrote:

Or you could do what we do and ask their mail client to deliver it  
for us.


What if they don't have a mail client configured? As Andrew said in  
the message you replied to:


an increasing number of users use webmail for everything, and don't  
have a desktop client set up.


Most of the people I work with at Google use GMail for everything. In  
that environment if an app launched Mail.app to send mail it wouldn't  
work, because chances are the user's never launched it, let alone  
configured an account.


—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: Extract plain text content from a Text View

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 12:37 PM, Ian Piper wrote:

Is there a way to get the plain text content out of an NSTextStorage  
object (displaying using a Text View) that contains rich text and  
images? I want to figure out a way to build a search predicate that  
will allow me to search a Text View and I think this is likely to be  
the only way.


NSTextStorage is a subclass of NSAttributedString, which has a -string  
property. This is easy to overlook :)


—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: Extract plain text content from a Text View

2009-10-16 Thread Douglas Davidson
NSTextStorage is a subclass of NSMutableAttributedString.  Is that  
enough of a hint?


Douglas Davidson

On Oct 16, 2009, at 12:37 PM, Ian Piper ianpi...@mac.com wrote:


Hi all,

Is there a way to get the plain text content out of an NSTextStorage  
object (displaying using a Text View) that contains rich text and  
images? I want to figure out a way to build a search predicate that  
will allow me to search a Text View and I think this is likely to be  
the only way.


Thanks,


Ian.
--

___

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

This email sent to ddavi...@apple.com

___

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

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

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

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


Re: Extract plain text content from a Text View

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 3:37 PM, Ian Piper wrote:

Is there a way to get the plain text content out of an NSTextStorage  
object (displaying using a Text View) that contains rich text and  
images?


  An NSTextStorage is a subclass of NSMutableAttributedString, which  
is a subclass of NSAttributedString. With this in mind ...



I want to figure out a way to build a search predicate that will  
allow me to search a Text View and I think this is likely to be the  
only way.


  Seems a bit odd. Could you elaborate?

--
I.S.


___

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

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

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

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


Re: Extract plain text content from a Text View

2009-10-16 Thread Nick Zitzmann


On Oct 16, 2009, at 1:37 PM, Ian Piper wrote:

Is there a way to get the plain text content out of an NSTextStorage  
object (displaying using a Text View) that contains rich text and  
images?


http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/Reference/Reference.html#//apple_ref/doc/uid/2166-string 



Nick Zitzmann
http://www.chronosnet.com/

___

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

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

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

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


Re: Extract plain text content from a Text View

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 3:44 PM, I. Savant wrote:

I want to figure out a way to build a search predicate that will  
allow me to search a Text View and I think this is likely to be the  
only way.


 Seems a bit odd. Could you elaborate?


  Let *me* elaborate on *that*. :-) You normally use predicates to  
filter objects in the model layer of your application. Note  
normally. If you're trying to provide a way to search within a text  
view, this is a very strange way of going about it:


1 - NSTextView already takes advantage of the Find field.

2 - Searching for a substring inside a string with a predicate  
searches the *whole* string as one ... this is only really useful if  
your text view's content is made up of a bunch of smaller units, but  
then again ... see 1 above.


3 - The predicate would be used to filter an array of NSTextStorages,  
not one NSTextStorage, returning those which contain your search string.


4 - Related to 3: if you're searching text storages because you treat  
them as individual subunits in your model, it would likely make more  
sense to apply this filter to the model layer.


--
I.S.




___

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

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

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

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


Re: A good Obc-C framework for sending email?

2009-10-16 Thread Ben Haller

On 16-Oct-09, at 3:04 PM, Alastair Houghton wrote:


On 16 Oct 2009, at 03:54, Andrew Farmer wrote:


On 15 Oct 2009, at 13:34, Ben Haller wrote:
Hi all.  I need a good Obj-C framework for sending email.  I used  
to use the Message.framework associated with Apple's Mail, but  
they killed that a long time ago, sadly.  Then I used Pantomime;  
but it seems to also be abandoned, now, and it is crashing on 10.5  
(and it was never terribly reliable anyway).  Does anybody know of  
a good replacement?  I haven't had any luck trying to find one  
using Google.


Keep in mind that many users may not have any SMTP server  
configured -- an increasing number of users use webmail for  
everything, and don't have a desktop client set up. And, in many of  
these cases, they may be behind a firewall or ISP that blocks  
connections to port 25 (SMTP) on all servers other than their own.  
If you need to reliably deliver email from a user's machine, you'll  
probably need to set up a gateway of some sort yourself, or have  
them input SMTP settings manually.


Or you could do what we do and ask their mail client to deliver it  
for us.  The code we use for that is Open Source, and you can get it  
here:


 http://www.coriolis-systems.com/opensource/

CSMail can also generate messages and pop them up in their client  
ready for them to send themselves, which is something we use in some  
circumstances as well.


(It's possible that we have updated CSMail a bit since the version  
on that page, I don't know... but if someone's interested in using  
it, I can check.)


  I am definitely interested in using it, Alastair.  This solution  
would in fact be optimal for my purposes.  If you could make sure it's  
up to date, that would be great.


Ben Haller
Stick Software

___

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

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

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

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


Re: A good Obc-C framework for sending email?

2009-10-16 Thread Alastair Houghton

On 16 Oct 2009, at 20:42, Jens Alfke wrote:


On Oct 16, 2009, at 12:04 PM, Alastair Houghton wrote:

Or you could do what we do and ask their mail client to deliver it  
for us.


What if they don't have a mail client configured? As Andrew said in  
the message you replied to:


an increasing number of users use webmail for everything, and  
don't have a desktop client set up.


Most of the people I work with at Google use GMail for everything.  
In that environment if an app launched Mail.app to send mail it  
wouldn't work, because chances are the user's never launched it, let  
alone configured an account.


True, but it's still better than trying to snarf their mail settings  
from somewhere random, and even if they're using GMail, Apple Mail  
*does* support it and so they can just give that their GMail settings,  
which is better than us asking for them separately IMO.


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: Can I make custom pasteboard type for an object reference?

2009-10-16 Thread Sean McBride
On 10/15/09 6:34 AM, Timothy Stafford Larkin said:

I messed around with this problem for some time, before I gave up
trying to be clever and cast the pointer as an unsigned long.

   NSNumber *p = [NSNumber numberWithUnsignedLong:(unsigned 
 long)object];

The number can be added to a pasteboard. Or if dragging more than one
object, NSNumbers can be added to an NSArray, and the array written to
the pasteboard.

That seems quite dangerous, especially in a GC app.  Creating such an
NSNumber will not keep a strong reference to object, and so it risks
getting prematurely collected.  If you do do this, better CFRetain the
object first.

--

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: Serial comm in Cocoa?

2009-10-16 Thread Sean McBride
On 10/15/09 5:12 PM, Oftenwrong Soong said:

What is the Cocoa-fied way to communicate via a serial port?

The newest AMSerialPort code is now on sourceforge:
http://sourceforge.net/projects/amserial/

--

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: Can I make custom pasteboard type for an object reference?

2009-10-16 Thread glenn andreas


On Oct 16, 2009, at 3:51 PM, Sean McBride wrote:


On 10/15/09 6:34 AM, Timothy Stafford Larkin said:


I messed around with this problem for some time, before I gave up
trying to be clever and cast the pointer as an unsigned long.

		NSNumber *p = [NSNumber numberWithUnsignedLong:(unsigned long) 
object];


The number can be added to a pasteboard. Or if dragging more than one
object, NSNumbers can be added to an NSArray, and the array written  
to

the pasteboard.


That seems quite dangerous, especially in a GC app.  Creating such an
NSNumber will not keep a strong reference to object, and so it risks
getting prematurely collected.  If you do do this, better CFRetain the
object first.



And that isn't enough to help if you use some sort of pasteboard/ 
scrapbook manager to store the dragging pasteboard, quit the app, and  
later relaunch it and try to drag the archived pasteboard from you  
pasteboard manager app.




Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
quadrium2 | build, mutate, evolve, animate  | images, textures,  
fractals, art



___

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

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

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

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


Re: NSArrayController performance using NSManagedObject content on 10.6 [SOLVED]

2009-10-16 Thread jonat...@mugginsoft.com
To begin with I built a test core data project utilising an  
NSArrayController bound to an NSTableView.
This showed no performance issues at all so, surprise surprise, the  
problem was of my own creation.


Looking at the Shark traces reveals an implementation change in the  
way that model observing is handled.

So I go to my NSManagedObject subclass and note the following:

[self addObserver:self forKeyPath:@message options:0 context:(void *) 
MGSContextMessage];
[self addObserver:self forKeyPath:@date options:0 context:(void *) 
MGSContextDate];
[self addObserver:self forKeyPath:@score options:0 context:(void *) 
MGSContextScore];
[self addObserver:self forKeyPath:@category options:0 context:(void  
*)MGSContextCategory];


Removing these observers fixes the problem.

And why is self observing self?
Because my NSManagedObject subclass has a number of derived properties  
backed by ivars.
Core Data undo doesn't call accessors during undo, but does update  
KVO, so the observations keep the modelled and un-modelled derived  
properties in sync during undo.

On 10.5 it's fine, on 10.6 dog slow.

The solution is simply to ditch the un-modelled derived properties in  
favour of transient modelled properties.

Core Data undo works and the self-self observation is redundant.

On 15 Oct 2009, at 13:01, jonat...@mugginsoft.com wrote:



I am using an array of simple NSManagedObject subclasses bound to an  
NSArrayController.

The object graph is shallow with a tiny number of objects (500).

All objects are loaded into the NSArrayController MOC using an  
NSFetchRequest with setReturnsObjectsAsFaults:NO.

Therefore no faulting should be occurring.
The app is garbage collected.
The CoreData atore type is XML.

The NSArrayController's arrangedObjects is bound to an NSTableView.
The NSArrayController's filterPredicate is bound to an NSSearchField.

Under 10.5 manipulating the NSArrayController's arrangedObjects  
using either sort descriptors or the predicate is quick.

Under 10.6 the performance is noticeably worse.

Shark shows the following for both 10.5 and 10.6 when the filter  
predicate is updated.

The issue seems to make itself manifest on the lines marked .
Obviously the implementation here is different.

NSPointerArray -compact seems to be the centre of activity.

What options do I have here to try and restore performance?
Is the issue related to the use of NSManagedObject content at all?

OS X 10.6 (poor)
	0.0%	89.5%	AppKit	-[NSArrayController  
setFilterPredicate:]
	0.0%	89.5%	AppKit	 -[NSArrayController  
_didChangeArrangementCriteriaWithOperationsMask:useBasis:]
	0.0%	65.3%	AppKit	  -[NSArrayController  
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis 
:]
	0.0%	49.7%	AppKit	   - 
[NSArrayController _setObjects:]
	0.0%	49.7%	AppKit	- 
[_NSModelObservingTracker  
setIndexReferenceModelObjectArray:clearAllModelObjectObserving:]
	0.0%	49.7%	AppKit	 - 
[_NSModelObservingTracker clearAllModelObjectObserving]
	0.0%	49.6%	AppKit	  - 
[_NSModelObservingTracker  
_registerOrUnregister:observerNotificationsForModelObject:]
	0.0%	49.6%	Foundation	   -[NSObject 
(NSKeyValueObserverRegistration) removeObserver:forKeyPath:]
	0.0%	49.5%	Foundation	-[NSObject 
(NSKeyValueObserverRegistration) _removeObserver:forProperty:]
	0.1%	49.0%	Foundation	  
_NSKeyValueObservationInfoCreateByRemoving
	0.0%	48.5%	Foundation	  - 
[NSKeyValueObservationInfo _initWithObservances:count:]
	3.6%	46.4%	Foundation	   - 
[NSConcretePointerArray compact]
	10.0%	42.8%	Foundation	 
readWeakAt
	9.7%	31.4%	libobjc.A.dylib	  
objc_read_weak
	19.6%	19.8%	libauto.dylib	   
auto_read_weak_reference
	0.2%	0.2%	 
libSystem.B.dylib	
__spin_lock


OS X 10.5 (Good)
	0.0%	37.6%	AppKit	-[NSArrayController  
setFilterPredicate:]	
	0.0%	37.6%	AppKit	 -[NSArrayController  
_didChangeArrangementCriteriaWithOperationsMask:useBasis:]	
	0.0%	29.9%	AppKit	  -[NSArrayController  
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis 
:]	
	0.0%	13.3%	AppKit	   - 
[NSArrayController _setObjects:]	
	0.0%	12.4%	AppKit	   - 
[NSArrayController  
_updateObservingForAutomaticallyRearrangingObjects]	
	0.0%	12.1%	AppKit	- 
[_NSModelObservingTracker  
startObservingModelObjectsAtReferenceIndexes:]	
	0.0%	

Re: NSArrayController performance using NSManagedObject content on 10.6 [SOLVED]

2009-10-16 Thread Kyle Sluder
On Fri, Oct 16, 2009 at 2:49 PM, jonat...@mugginsoft.com
jonat...@mugginsoft.com wrote:
 [self addObserver:self forKeyPath:@message options:0 context:(void
 *)MGSContextMessage];
 [self addObserver:self forKeyPath:@date options:0 context:(void
 *)MGSContextDate];
 [self addObserver:self forKeyPath:@score options:0 context:(void
 *)MGSContextScore];
 [self addObserver:self forKeyPath:@category options:0 context:(void
 *)MGSContextCategory];

 Removing these observers fixes the problem.

If that's the solution (as opposed to *a* solution), it's upsetting.
There are plenty of occasions where this is a necessary or useful
pattern.

Would someone from Apple like to chime in and explain why Jonathan is
seeing the results he is?

--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: Extract plain text content from a Text View

2009-10-16 Thread Ian Piper


On 16 Oct 2009, at 20:51, I. Savant wrote:


On Oct 16, 2009, at 3:44 PM, I. Savant wrote:

I want to figure out a way to build a search predicate that will  
allow me to search a Text View and I think this is likely to be  
the only way.


Seems a bit odd. Could you elaborate?


 Let *me* elaborate on *that*. :-) You normally use predicates to  
filter objects in the model layer of your application. Note  
normally. If you're trying to provide a way to search within a  
text view, this is a very strange way of going about it:


1 - NSTextView already takes advantage of the Find field.

2 - Searching for a substring inside a string with a predicate  
searches the *whole* string as one ... this is only really useful if  
your text view's content is made up of a bunch of smaller units, but  
then again ... see 1 above.


3 - The predicate would be used to filter an array of  
NSTextStorages, not one NSTextStorage, returning those which contain  
your search string.


4 - Related to 3: if you're searching text storages because you  
treat them as individual subunits in your model, it would likely  
make more sense to apply this filter to the model layer.


I will elaborate...

I have a Core Data application that has a Text View in its main  
window, and also has a Find field. I want to create a search field  
predicate to allow the user to search the text in the Text View. I'm  
interested in point 1 above, because I initially thought it made sense  
for an NSTextView to just work with the Find field, but I couldn't  
seem to get it working. That is what led me to wondering whether I  
could get at the string content in the NSTextView and search that  
instead. I'm happy to just use the inherent capabilities of  
NSTextField but I can't figure out what they are!


The Text View is simply used as a place for the user to put any rich  
text and or images. Is there a way either to search or to get all of  
the plain text out from such a Text View? It's probably a simplistic  
question and I rather suspect that ultimately the answer is no!



Ian.
--
___

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: Strange Core Data save behaviour (required relationship nil... when it is set the line before saving)

2009-10-16 Thread Luke Evans
Darn, I thought his problem had gone away, but I still get the failure  
to save from time to time (the probability of occurrence is pretty low  
though).
I'm even setting the problematic relationship to nil before deleting  
the object, then calling -processPendingChanges, then saving the  
object (which will then cause other thread's MOCs to be updated via - 
mergeChangesFromContextDidSaveNotification.


I currently don't understand the difference between the many cases  
that seem to work, and the case that then suddenly doesn't.  Again,  
while the change can be introduced by a number of threads, only one  
MOC is changed (and saved) at a time, and this MOC is strictly  
associated with the thread.
I need to spend more time researching this problem, but the issue  
seems to raise its head when I'm testing some 'quick fire' changes  
between types of my object B (where old B gets deleted, new B created  
and linked into the owning object A).


I'm wondering if it's possible to have a change come in on the second  
thread, just as the change before it is being processed from the other  
thread, somehow leaving the second thread's MOC in an odd state, and  
unable to save.  I'm pretty sure the Context Did Save Notifications  
and behaviour of -mergeChagnesFromContextDidSaveNotification are  
synchronous though, so should offer no opportunity for interleaving in  
my current test regime.  In any case, there's certainly no locking on  
my part, and I've been assuming that changes propagating from an  
earlier change in another MOC (via - 
mergeChangesFromContextDidSaveNotification) would be atomic, or  
otherwise would automatically act correctly when a changed is  
attempted on an object that has been changed in another MOC.


Should I be calling -[NSManagedObjectContext  
refreshObject:mergeChanges:] on any object in any MOC before I attempt  
to make any changes to it?   I don't read anything suggesting this is  
necessary, though maybe it is safer if it gives the object a change to  
be fully updated from other MOCS (??).
I'm clutching at straws a little here, I realise... no substitute for  
actually trying to grok the dynamics, but there's a lot about what  
actually happens when you do a - 
mergeChangesFromContextDidSaveNotification that remains opaque (to me).


-- lwe


On 2009-09-29, at 8:16 PM, Ben Trumbull wrote:



On Sep 29, 2009, at 8:22 PM, Luke Evans wrote:


Hello Ben.

What happens if you add a call to -processPendingChanges in  
between #2 and #3 ?


... well then everything works wonderfully (oh joy!!) :-)

OK.  I need to get a proper mental picture of why this is needed in  
this case.
I guess I was vaguely aware of this method from previous passes  
though the Core Data docs, but...


- The method documentation itself doesn't _really_ suggest it may  
be essential in some cases.   Rather, the talk is about getting the  
undo manager into step, and even then the statement is made that  
this is done by default at the end of the run loop.
- deleteObject docs, or indeed the guide section on deleting  
(Creating and Deleting Managed Objects) makes no mention of a need  
to call this method
- I had tried manually setting the old deleted objects 'back  
relationship' to nil, before deleting it, and before setting A's  
relationship to the new B.  This hadn't worked, but was my attempt  
to keep the relationships consistent - at least in in the MOC that  
induced the change.


It's tempting to just think that you should _always_ do a - 
processPendingChanges before a -save:, but I'd prefer to understand  
what's really happening here.


It's not before the save.  It's in between the deletion and the re- 
assignment of the relationship of the surviving object to a new  
object.  The problem is reassigning the relationship before delete  
propagation runs.  Delete propagation, as well as the change  
notifications and several other aspects of object graph change  
tracking are coalesced and run later.   Calling  
processPendingChanges is one of those later times.  The application  
event loop also calls it, which is the default timing.  Executing a  
fetch, or a save will also call it.


Manually setting the deleted object's relationship instead of  
calling processPendingChanges between steps #2  #3 should also work.


I don't think anyone has cared enough to file a bug on this.

- Ben



If you have insights on the above, then that would be great.   
Regardless, you've just improved my humour by several degrees ;-)


-- Luke


On 2009-09-29, at 3:59 PM, Ben Trumbull wrote:


Now, I have some code that changes the value of the 'B enumeration
value' that A is using.  This does the following:
1. Create a new instance of the B subentity that represents the  
value

we want (in the same MOC as A)
2. Delete the old B object that A was pointing to, i.e. [moc
deleteObject:B];
3. Set A's to-one relationship to point to the new B object (and  
for

good measure, set B's inverse relationship - though 

Re: Extract plain text content from a Text View

2009-10-16 Thread Charles Srstka

On Oct 16, 2009, at 5:42 PM, Ian Piper wrote:

The Text View is simply used as a place for the user to put any rich  
text and or images. Is there a way either to search or to get all of  
the plain text out from such a Text View? It's probably a simplistic  
question and I rather suspect that ultimately the answer is no!


As others have already said, you can get the plain text by just  
sending the -string message to the NSTextStorage object.


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


UITextField formatting for IP Address

2009-10-16 Thread Alex Kac
On desktop Cocoa I can put in a custom formatter on a textfield and  
get what I'm looking for. On iPhone, I can say I'm a bit confused as  
to the best way to handle this.


Given a UITextField and my desire to have the user type in an IP  
address, it sounds like it could be simple, but I can't figure it out.


Using

- (BOOL)textField:(UITextField *)textField  
shouldChangeCharactersInRange:(NSRange)range replacementString: 
(NSString *)string


works fine if I'm assuming the user is simply typing in the text going  
forward. The problem is if a user edits the text field then they lose  
their place as I set the text.


So my guess to this is that no I cannot do this (though I'm sure I've  
seen it on the iPhone), but would there be a good way to handle this  
properly?


There will always be death and taxes; however, death doesn't get  
worse every year.

-- Anonymous




___

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: UITextField formatting for IP Address

2009-10-16 Thread Alex Kac
Here is my code, btw. It works OK, but it still has the issue of  
moving the cursor to the end. Perhaps there is no way to do this on  
the iPhone - I just don't want to bang my head for hours.


- (void)formatForIP:(UITextField*)textField string:(NSString*)string
{
	long long ip = [[string stringByReplacingOccurrencesOfString:@.  
withString:@] longLongValue];


NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterNoStyle];
[numberFormatter setPositiveFormat:@###,###,###,###];
[numberFormatter setGroupingSize:3];
[numberFormatter setSecondaryGroupingSize:3];
[numberFormatter setGroupingSeparator:@.];
[numberFormatter setUsesGroupingSeparator:YES];

	textField.text = [numberFormatter stringFromNumber:[NSNumber  
numberWithLongLong:ip]];

[numberFormatter release];
}

- (BOOL)textField:(UITextField *)textField  
shouldChangeCharactersInRange:(NSRange)range replacementString: 
(NSString *)string

{
if (textField.tag == 1)
{
if ([textField.text length] == 15)
return NO;
else if ([textField.text length])
{
			NSString* newString = [textField.text  
stringByReplacingCharactersInRange:range withString:string];


[self formatForIP:textField string:newString];
return NO;
}
}
return YES;
}


On Oct 16, 2009, at 7:26 PM, Alex Kac wrote:

On desktop Cocoa I can put in a custom formatter on a textfield and  
get what I'm looking for. On iPhone, I can say I'm a bit confused as  
to the best way to handle this.


Given a UITextField and my desire to have the user type in an IP  
address, it sounds like it could be simple, but I can't figure it out.


Using

- (BOOL)textField:(UITextField *)textField  
shouldChangeCharactersInRange:(NSRange)range replacementString: 
(NSString *)string


works fine if I'm assuming the user is simply typing in the text  
going forward. The problem is if a user edits the text field then  
they lose their place as I set the text.


So my guess to this is that no I cannot do this (though I'm sure  
I've seen it on the iPhone), but would there be a good way to handle  
this properly?


There will always be death and taxes; however, death doesn't get  
worse every year.

-- Anonymous






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

I am not young enough to know everything.
--Oscar Wilde




___

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


Any way to see all AppleEvents being sent in system?

2009-10-16 Thread Rick Mann
I've heard reports of a 16-bit overflow bug in AppleEvent replies that  
might be causing the horrible SPODs I'm seeing. However, I'd like to  
get an idea of how many AppleEvents are being sent on my system during  
normal use. Is there a utility that allows me to see every event as  
it's sent? Just log-style output is fine.


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: Any way to see all AppleEvents being sent in system?

2009-10-16 Thread Sean McBride
On 10/16/09 5:57 PM, Rick Mann said:

I've heard reports of a 16-bit overflow bug in AppleEvent replies that
might be causing the horrible SPODs I'm seeing. However, I'd like to
get an idea of how many AppleEvents are being sent on my system during
normal use. Is there a utility that allows me to see every event as
it's sent? Just log-style output is fine.

AEDebugSends?

http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html#SECAE

--

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: Any way to see all AppleEvents being sent in system?

2009-10-16 Thread Rick Mann


On Oct 16, 2009, at 18:33:38, Sean McBride wrote:


On 10/16/09 5:57 PM, Rick Mann said:

I've heard reports of a 16-bit overflow bug in AppleEvent replies  
that

might be causing the horrible SPODs I'm seeing. However, I'd like to
get an idea of how many AppleEvents are being sent on my system  
during

normal use. Is there a utility that allows me to see every event as
it's sent? Just log-style output is fine.


AEDebugSends?

http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html#SECAE 



That seems to require a specific process to debug, and therefore seems  
like it would be only for that process. Is there something that will  
catch all sends across all processes?


--
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: Any way to see all AppleEvents being sent in system?

2009-10-16 Thread Dave Keck
Are you seeing the spinner for every application or just one? If it's
just one, you could use AEDebugReceives.

/Developer/Applications/Performance Tools/Spin Control.app might also
be of interest.
___

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: Any way to see all AppleEvents being sent in system?

2009-10-16 Thread Rick Mann
It often starts with one, then spreads to others. There is speculation  
online that that 65,535th event results in a long hang/timeout. I want  
to get an idea of how many events are really being sent during normal  
use (that is, not during heavily scripted use, etc).


http://db.tidbits.com/article/10643


On Oct 16, 2009, at 18:42:21, Dave Keck wrote:


Are you seeing the spinner for every application or just one? If it's
just one, you could use AEDebugReceives.

/Developer/Applications/Performance Tools/Spin Control.app might also
be of interest.


___

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


File Encryption / Decription

2009-10-16 Thread Chunk 1978
what is the best way to encrypt and then decrepit a file in Cocoa?
___

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: File Encryption / Decription

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 10:05 PM, Chunk 1978 wrote:


what is the best way to encrypt and then decrepit a file in Cocoa?


  I suppose you could burn the encrypted file to a disk then neglect  
said disk. Bit rot would make the file quite decrepit. ;-)


  But seriously folks*, there are a few categories on NSData on cocoadev.com 
 that can help.


--
I.S.

* I'm here all night. Remember to tip your waitresses.


___

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: Slider with tag?

2009-10-16 Thread Sean McBride
On 10/14/09 10:24 PM, Gabriel Zachmann said:

Could someone please explain to me how I can present a little tag to
the user that moves along with a slider's handle (above or below), in
which I can give some feedback to the user about the current value of
the slider?

I'm afraid I couldn't find an example, but I think I have seen such a
thing somewhere ...

You have to do it yourself.  You can create a borderless NSWindow for
the 'little tag'.  You can use knobRectFlipped to get the thumb's
position.  You'll probably also want to use addChildWindow:ordered: to
keep your floating window linked to the slider's window.  You can use an
NSTimer to close the window after a short delay.

--

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: Slider with tag?

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 10:33 PM, Sean McBride wrote:


On 10/14/09 10:24 PM, Gabriel Zachmann said:


Could someone please explain to me how I can present a little tag to
the user that moves along with a slider's handle (above or below), in
which I can give some feedback to the user about the current value of
the slider?

I'm afraid I couldn't find an example, but I think I have seen such a
thing somewhere ...


You have to do it yourself.


  ... MAAttachedWindow is a good starting point:

http://mattgemmell.com/source

--
I.S.


___

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

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

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

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


Re: How to retrieve the font information from TrueType font file?

2009-10-16 Thread XiaoGang Li
Yes, it is really strange feature, this is used internal. My application is
distributed with bundles of document templates. These templates should be
designed by your graphic designers before being distributed, using the
limited fonts installed in the  bundle.  Anyway, user can use other fonts
from  the system and third parties.

Your solution is good. At first, I think it is simple to list all the
limited fonts in the plist file, and it is easy to enumerate these fonts.
But, I think, when other font files are added to the bundle by other
engineer, I will update my plist file at the same time. this solution seems
unrobust.

Thanks again for your feedback.

On Fri, Oct 16, 2009 at 11:57 PM, Jens Alfke j...@mooseyard.com wrote:


 On Oct 16, 2009, at 3:31 AM, XiaoGang Li wrote:

  other uncontained fonts which come from the system or third party
 application will be invalid in my application. when the users use my
 application to draw text, only the fonts contained in the bundle should be
 valid. This is the backgroud of my question.


 I don't know what your applications does, but that seems like a really
 strange feature. I have a lot of fonts installed, and when I use an app I
 expect to be able to use them. If the app only let me use a couple of fonts
 that were bundled with it, I'd call that a bug.

 (Also, do you have permission to bundle these fonts? Most fonts can't be
 re-distributed without a commercial license from the owner.)

After getting the font name from the font used by the user, need to
 check whether this font is valid, so, how to get the font information from
 my font files.


 Isn't the set of bundled fonts hard-coded? Just make a list of their names
 (maybe in a plist file) and read that. I think trying to extract the names
 out of the font files themselves would be much too difficult since there's
 no API for it.

 —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


Simulating webpage clicks

2009-10-16 Thread Charles Burnstagger
I have a Cocoa app with a WebKit browser. My app navigates to a default URL on 
startup.

I need to parse the content of the default page, find specific links I am 
looking for, then simulate clicks on those links in the page just as if the 
user was clicking it normally - and I need to do all this in Objective-C 
without any JavaScript.

Is there a way to do this using WebKit?

Thanks,

Chuck



  
___

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


correctly Controlling Garbage Collection

2009-10-16 Thread WareTo Development
I saw a couple posting regarding this when Garbage Collection was  
originally introduced, but have not seen any discussion since. I do  
not believe the issue was ever resolved.


Our application uses Garbage Collection under 10.5 (and now 10.6). We  
have several custom views with custom mouse tracking while dragging  
(mouse click down event, move move events, then mouse up event).  We  
track this information in order to implement a pencil drawing tool in  
our application. Normally this works smoothly. The tracking is done  
often enough so the pencil draws a smooth line. If the user moves his  
mouse VERY fast, the mouse move events are greater then a pixel  
across, and we draw a line from old point to the new point. This is  
acceptable for most case.


We discovered during testing that is some special cases, the mouse  
moved events were not being tracked fast enough. This caused what  
should of been a smooth line (drawing pixel to pixel) to be drawn as a  
straight line (not enough mouse tracking).


Using our development tools, we discovered this was due to garbage  
collection.


Ever once in awhile, based on memory usage, the system does a deep  
garbage collection operation. If it happens when the pencil is being  
drawn, we get badly drawn lines.


Looking at this problem, we could perform better memory management, so  
deep garbage collection does not happen that often. This reduces the  
problem, but can never eliminate it, since sooner or later the garbage  
clean operation must be done.


So we thought the best thing would be to force a garbage collection  
operation at a time of our choosing.  Normally, this occurs at Mouse  
up, after the user has finished his drawing. A split second of garbage  
collection then would be barely noticeable by the user.


So, we looked for a call, and thanks to this list we found
objc_collect (OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE);
.
Unfortunately, this does not solve our problem. That call does not  
insure a garbage collection operation synchronously, nor shortly after  
one returns to the main event loops. It does seem to cause one a short  
time later, but by then the user might be drawing with the pen again.


We saw that a couple other people complained about this call not doing  
what they expected, but this was a while back, and we have not seen  
any new discussions about it.


Has anyone else conquered similar Garbage Collection issues? It would  
appear to me, that unless there are better controls then we now know  
about, this type of slow down issue would make Garbage Collection  
useless for any application that does animation or smooth mouse  
tracking.


Thank you!

Steve Sheets
___

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


OK/Cancel buttons on NSColorPanel

2009-10-16 Thread Kevin Barnes
I'm porting an app from Carbon to Cocoa. I notice that when I use the
carbon function PickColor to get a color dialog, the dialog has OK and
Cancel buttons, but when using NSColorPanel the dialog does not have
those buttons. Is there a way to get OK and Cancel buttons in the
Cocoa version of my code?

-Kevin
___

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


Sqlite and Core Data

2009-10-16 Thread Thomas Hart
These may have been asked before, if so just point me in the right  
direction.


I'm trying to build what I hope is a relatively small program that  
will keep track of authors and books. I've got databases in Postgres  
and MySql, and I ported the data over to sqlite yesterday.


Now I'm just fooling around at this point, and am trying to learn  
XCode. I tried building a couple of Core Data apps based on examples  
in one of the Cocoa for Dummies books, and like the ease of using Core  
Data.


Can I use Core Data to access the sqlite database that I've created?  
Are there any files I need to add, or code I need to write?


If I can't use Core Data to access sqlite, do I need to migrate the  
data to be a persistent store, and are there tools to do that? Xcode  
doesn't seem to like a straight XML export from sqlite, and tells me  
that it's the wrong type.


I've tried using Google to find articles, but everything seems to be  
four or five years old. If there are any pointers to recent articles,  
it would be appreciated.


Thanks for any help you can give.

Tom Hart


___

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: OK/Cancel buttons on NSColorPanel

2009-10-16 Thread Graham Cox


On 17/10/2009, at 3:07 AM, Kevin Barnes wrote:


I'm porting an app from Carbon to Cocoa. I notice that when I use the
carbon function PickColor to get a color dialog, the dialog has OK and
Cancel buttons, but when using NSColorPanel the dialog does not have
those buttons. Is there a way to get OK and Cancel buttons in the
Cocoa version of my code?



NSColorPanel is very much a self-contained class that offers little  
customisation in itself (though you can add custom pickers to it). Its  
design is quite different from the old modal color picker in Carbon.


Where possible, at those places in your interfaces that you need to  
pick a colour (e.g. a Color... button in a dialog, say), replace  
those with NSColorWells which will interact with the floating modeless  
color panel automatically. This will make your app much more standard  
as a Cocoa app rather than trying to emulate the old way of doing  
things.


If you really have no option, note that NSColorPanel subclasses  
NSPanel, so it might be possible to run it modally or as a document  
modal sheet though I've never tried it so I don't know if it's  
possible. I see no built-in way to add OK/Cancel buttons but if you  
can persuade it to run modally in some fashion you'll probably be able  
to add these programatically to the panel.


--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: Sqlite and Core Data

2009-10-16 Thread Jerry Krinock


On 2009 Oct 16, at 19:43, Thomas Hart wrote:


Can I use Core Data to access the sqlite database that I've created?


Anything can be done, given infinite design and product-maintenance  
resources.  Let me re-phrase your question:


Question:  Is there any chance that this might be a practical approach?

Answer:  No.

If I can't use Core Data to access sqlite, do I need to migrate the  
data to be a persistent store, and are there tools to do that?


You said that your databases are in Postgres and MySQL, and then later  
sqlite.  You will need a library of functions to read these databases,  
extracting the records and their field values -- strings, numbers,  
etc.  I've never used Postgres and MySQL on the Mac, but I have used  
the sqlite3 that ships in Mac OS X.  You can call sqlite3 library  
functions to create, read, and write sqlite databases.


However, sqlite and Core Data are not practically interoperable at any  
level lower than the records and their field values.


___

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: File Encryption / Decription

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 7:05 PM, Chunk 1978 wrote:


what is the best way to encrypt and then decrepit a file in Cocoa?


Look at CommonCrypto/CommonCryptor.h. It's a plain C API.

Warning: Encryption is only useful if you know what you're doing. If  
you're planning to do anything serious (certainly anything you want  
other people to use) I highly recommend reading a good overview like  
Schneier and Ferguson's Practical Cryptography.


—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: Simulating webpage clicks

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 7:20 PM, Charles Burnstagger wrote:

I need to parse the content of the default page, find specific links  
I am looking for, then simulate clicks on those links in the page  
just as if the user was clicking it normally - and I need to do all  
this in Objective-C without any JavaScript.


Look at the DOM API (WebKit/DOMDocument.h, etc.)

—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: Sqlite and Core Data

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 7:43 PM, Thomas Hart wrote:

Can I use Core Data to access the sqlite database that I've created?  
Are there any files I need to add, or code I need to write?


Not directly. Core Data does use SQLite to store data, but it uses  
very specific conventions for names and relations, and it isn't  
capable of working with any database or table that it didn't create  
itself. It's not a generalized ORM, but an object persistence API that  
just happens to use a SQL database as a backing store.


If I can't use Core Data to access sqlite, do I need to migrate the  
data to be a persistent store, and are there tools to do that?


Yes; and not as far as I know. You'll need to write code that reads  
data from your existing SQLite database, and then adds it to your  
CoreData object model.


SQLite's raw C API isn't too hard to use, and there are a couple of  
Cocoa libraries (like FMDB and QuickLite) that make working with it in  
a Cocoa app easier.


—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: Extract plain text content from a Text View

2009-10-16 Thread Jens Alfke


On Oct 16, 2009, at 3:42 PM, Ian Piper wrote:

The Text View is simply used as a place for the user to put any rich  
text and or images. Is there a way either to search or to get all of  
the plain text out from such a Text View? It's probably a simplistic  
question and I rather suspect that ultimately the answer is no!


NSTextView (and its parent class NSText) have methods for doing find  
and replace, which is what the commands in the Find submenu are wired  
up to. They even select the target text, scroll to it and blink it for  
you.


If that's too high level, just get the string property of the  
NSTextStorage and use NSString methods for searching for substrings.


—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: UITextField formatting for IP Address

2009-10-16 Thread Andrew Farmer

On 16 Oct 2009, at 17:54, Alex Kac wrote:
Here is my code, btw. It works OK, but it still has the issue of  
moving the cursor to the end. Perhaps there is no way to do this on  
the iPhone - I just don't want to bang my head for hours.


- (void)formatForIP:(UITextField*)textField string:(NSString*)string
{
	long long ip = [[string stringByReplacingOccurrencesOfString:@.  
withString:@] longLongValue];


	NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc]  
init];

[numberFormatter setNumberStyle:NSNumberFormatterNoStyle];
[numberFormatter setPositiveFormat:@###,###,###,###];
[numberFormatter setGroupingSize:3];
[numberFormatter setSecondaryGroupingSize:3];
[numberFormatter setGroupingSeparator:@.];
[numberFormatter setUsesGroupingSeparator:YES];

	textField.text = [numberFormatter stringFromNumber:[NSNumber  
numberWithLongLong:ip]];

[numberFormatter release];
}


This isn't a valid approach to formatting IP addresses - it considers  
12.34.56.78 to be equal to 12.345.678, which isn't even a valid  
address, let alone equivalent.

___

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 retrieve the font information from TrueType font file?

2009-10-16 Thread Mike Wright
The third-party TrueType fonts that I own have a variety of  
structures. Here are the ones I've found:


1. Single Fonts with the .ttf file extension have only a data fork,  
and the name of the file seems to be the name of the font.


2. I've found two styles of font suitcase files:

	a. One style has a resource fork that includes one or more 'FOND'  
resources -- one per font. The names of the 'FOND' resources seem to  
be the names of the font familes. They also include 'sfnt' resources,  
the names of which are the individual fonts.
	  For example, Times New Roman has a single 'FOND' resource called  
Times New Roman, and four 'sfnt' resources: Times New Roman, Times  
New Roman Bold, Times New Roman Italic, and Times New Roman Bold  
Italic.


	b. The other style has a resource fork that includes a 'FOND'  
resource for each individual font, with the 'FOND' resource names  
being the names of the fonts. They also include 'sfnt' resources, but  
the 'sfnt' resources do not have names. (They just have resource IDs  
that match the resource IDs of the corresponding 'FOND' resources.)
	  For example, Stones Sans ITC TT contains three 'FOND' resources:  
Stones Sans ITC TT-Bold, Stones Sans ITC TT-SemiIta, and Stones  
Sans ITC TT-Semi.


It shouldn't be too hard to see whether one or more of these  
categories apply to all of the fonts that might be bundled with your  
application. If they do, you should be able to programmatically check  
the 'FOND' and 'sfnt' resources of each font file and build a list of  
your bundled fonts each time the app is launched. It's probably slower  
than just reading in a single plist, but may be a bit more flexible.  
Of course, font file formats are notoriously variable, so some odd  
format might cause an error at some point in the future.


If you aren't familiar with getting resources out of resource forks,  
the process goes a bit like this. (But don't try to use this code.  
Read through the Resource Manager documentation to make sure you  
understand what the routines are doing.)


NSString *filename; /* probably from -contentsOfDirectoryAtPath:error:  
*/

FSRef theFsRef;
ResID theID;
ResType theType;
Str255 name;  /* a Pascal string -- length byte followed by string --  
typedef unsigned char Str255[256]; */

unsigned index;
Handle theResource;

[fileName getFSRef:theFsRef];

SInt16 refNum = FSOpenResFile(theFsRef,fsRdPerm); /* read-only, so  
you don't accidentally change it */


unsigned resCount = Count1Resources('sfnt');

for (index = 1;index = resCount;index++)  /* NOTE: not zero-based */
{
theResource = Get1IndResource('sfnt',index);

if (theResource)
{
HLock(theResource);

GetResInfo(theResource, theID, theType, name);

/* If it has a name, add the name to an array, or something. */
/* If it has no name, set a flag that tells you to run the */
/* same kind of loop on the 'FOND' resources. */
}
}

/* when all is done */
CloseResFile(refNum);

It should be fun if it doesn't get too crazy. Good luck.

--Mike Wright

On Oct 16, 2009, at 22:55 PM, XiaoGang Li andrew.mac...@gmail.com  
wrote:


Yes, it is really strange feature, this is used internal. My  
application is
distributed with bundles of document templates. These templates  
should be

designed by your graphic designers before being distributed, using the
limited fonts installed in the  bundle.  Anyway, user can use other  
fonts

from  the system and third parties.

Your solution is good. At first, I think it is simple to list all the
limited fonts in the plist file, and it is easy to enumerate these  
fonts.

But, I think, when other font files are added to the bundle by other
engineer, I will update my plist file at the same time. this  
solution seems

unrobust.

Thanks again for your feedback.

On Fri, Oct 16, 2009 at 11:57 PM, Jens Alfke j...@mooseyard.com  
wrote:




On Oct 16, 2009, at 3:31 AM, XiaoGang Li wrote:

other uncontained fonts which come from the system or third party

application will be invalid in my application. when the users use my
application to draw text, only the fonts contained in the bundle  
should be

valid. This is the backgroud of my question.



I don't know what your applications does, but that seems like a  
really
strange feature. I have a lot of fonts installed, and when I use an  
app I
expect to be able to use them. If the app only let me use a couple  
of fonts

that were bundled with it, I'd call that a bug.

(Also, do you have permission to bundle these fonts? Most fonts  
can't be

re-distributed without a commercial license from the owner.)

  After getting the font name from the font used by the user, need to
check whether this font is valid, so, how to get the font  
information from

my font files.



Isn't the set of bundled fonts hard-coded? Just make a list of  
their names
(maybe in a plist file) and read that. I think trying to