Code Example: FunTextField

2008-09-01 Thread Yung-Luen Lan
FunTextField is provided as an example of NSTextInput protocol.
Moreover, it also shows how to lay text along arbitrary path. (Thanks
to Brad Cox's DrawKit.)

Download:
http://yllan.org/code/

What is FunTextField:
http://yllan.org/blog/archives/285

My article on NSTextInput:
http://yllan.org/blog/archives/231

Regards,
yllan
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Image in NSOutlineView

2008-09-01 Thread chaitanya pandit
The right place to change the image of the cell would be in the  
outlineView's delegate method:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell: 
(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item


 try [[cell image] name] to get the name of the image
-chaitanya

On 29-Aug-08, at 5:41 PM, [EMAIL PROTECTED] wrote:


Hi all,
I'm trying to develop an application that uses an OutlineView in  
which it
displays items like a disclosure triangle, then one checkbox, then a  
text

field int the same column. For that I gone through the
DragNDropOutlineview example provided with Xcode. Then I copied the
ImageAndTextCell class and uses two images, one is checked and other  
is

unchecked. Now the application works with  showing one image.I want to
change the image when clicking on it. How can I do that ?. In which  
method

I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it  
faild.

When I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
id info = [cell image];
NSLog(@ %@,info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click  
Size={13,

13} Reps=(
   NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13
Alpha=NO Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?

Thanks in advance

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Code Example: FunTextField

2008-09-01 Thread Uli Kusterer

On 01.09.2008, at 10:23, Yung-Luen Lan wrote:

(Thanks to Brad Cox's DrawKit.)



 That would be Graham Cox. Brad Cox is someone else entirely :-)

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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

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

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

This email sent to [EMAIL PROTECTED]


Help!

2008-09-01 Thread Michael Robinson

Hi

I need to use a NSTableView to control data input by the user.  The  
table has two columns, labeled Title and Content.  The number of  
columns is fixed.


I've read what I can find on the internet, but a lot of it goes way  
over my head (I'm fairly new at ObjC and xCode -- coming from Java).


I understand (from assorted hints I've seen online) that one may use a  
NSDictionaryController to handle data input/output/display/saving etc  
from a table.


I really have no idea how to do this, and haven't found a tutorial  
that speaks to my tiny brain.


I was hoping one of you Cocoa masters would have a tip or two?

This is what I've got:

a bunch of code that works (it creates html for a webpage based on  
user selection/input).  a NSTextArea, NSTextField and NSTableView that  
are currently inert.


A NSDictionaryController sitting idle.

I want it to store data in key(title)value(content) pairs.  Initially  
there are no key/vals, until the user creates a new entry.  This  
should be handled by a little '+' button that I've placed below the  
NSTableview.  Removal of the entries should be handled buy the '-'  
button at its side.


I feel confident that I could do all this, if I had any idea where to  
start.  How do I link the NSDict... to my *.m *.h files so that I  
can save/load/ otherwise manipulate the data?  How do I shove data  
into the nsdict?  Is it even an instance of nsdictionary?  Do I  
need to make an NSMutableDictionary and somehow introduce them to each  
other?


Any help would be appreciated, I'm stuck in a bit of a hole here.

Thanks,

Mike


We build our computer (systems) the way we build our cities: over  
time, without a plan, on top of ruins


-- Ellen Ullman

___

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

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

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

This email sent to [EMAIL PROTECTED]


how to delete the current user's directory?

2008-09-01 Thread XiaoGang Li
hi, list, I have an uninstaller application , which is used to delete
the files installed; and also i have a file which located in the current
user's directory, like the ~/Library/LaunchAgents/com..plist. and how
can i delete this kind of file, i have tried the
AuthorizationExecuteWithPrivileges
API, it seems not workable, do i give a wrong flag value or something else?
here is my code piece, any comments will be appreciated.

AuthorizationRef myAuthorizationRef;

AuthorizationFlags myFlags = kAuthorizationFlagDefaults;

AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,myFlags,
myAuthorizationRef);

AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};

AuthorizationRights myRights = {1, myItems};



myFlags = kAuthorizationFlagDefaults |

  kAuthorizationFlagInteractionAllowed |

  kAuthorizationFlagPreAuthorize |

  kAuthorizationFlagExtendRights;

AuthorizationCopyRights (myAuthorizationRef, myRights, NULL, myFlags, NULL);


char *fileDir = ~/Library/LaunchAgents/com.hp.printerAgent.plist;

char* args[3];

args[0]= -Rf;

args[1]= fileDir;

args[2]= NULL;


myFlags = kAuthorizationFlagDefaults;

OSStatus res = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
/bin/rm,myFlags,args,NULL);

AuthorizationFree(myAuthorizationRef, myFlags);


and the res value is -60032. and by the way, how can i get the current
user's name string? which cocoa API can get it?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Increasing NSTextView's height

2008-09-01 Thread Graham Cox


On 1 Sep 2008, at 7:52 pm, chaitanya pandit wrote:

But even if i change the textView's frame by increasing it's height  
so that it occupies the bottom most subview, i don't see the  
vertical scroller. Am i missing something?



NSTextView doesn't have a vertical scroller on its own. If you put it  
inside an NSScrollView then it could do. (IB does set it up this way  
by default, did you create the view this way or programatically?).


Increasing frame height doesn't force a hidden scrollbar to show -  
having more text than can be shown in the frame does though, which  
implies that making the frame *smaller* would be the more likely way  
to go there.


Remember: frame size = area occupied in the parent view. bounds = area  
logically occupied by the text + any subviews. So it's the bounds you  
need to increase to ensure that any subviews are properly covered by  
it. If the bounds  frame, the scrollbars will show if there are any  
there that can be shown.


hth,

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 [EMAIL PROTECTED]


QTCaptureConnectionEnabledAudioChannelsAttribute read only

2008-09-01 Thread Bram Loogman
Hi,

Currently I'm working with a DV camera to capture video using the
QTCapture class. Now I have a problem with processing the audio. When
I check the movie properties of the recorded movie in Quicktime it
tells me it contains 4 audio channels, 2 of them 'unused'. Now the
problem is that the movie converter I'm using, doesn't support movies
with 4 audio channels. I tried different DV cameras but they just act
normal, they output just a common stereo track. Apparently it has
something to do with this model, but I will have to use it anyway
since we already bought a couple of them.

So I was looking for a way to limit the the audio to two channels. I
found the QTCaptureConnectionEnabledAudioChannelsAttribute for a
QTCaptureConnection, but when I try

[connection 
attributeIsReadOnly:QTCaptureConnectionEnabledAudioChannelsAttribute]

it tells me that it is read only. I tried this for the
QTCaptureDeviceInput connections and the QTCaptureMovieFileOutput
connections, but none of them works. Although in the
QTCaptureConnection Reference it says: This attribute allows
applications to selectively disable certain audio channels from being
sent rhough the connection.
So I would like to know if there is a simple solution for my problem.

Thanks,
Bram Loogman
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: I know this is a Studio question .. but I really need some help

2008-09-01 Thread John Love

Please check out this link that I just this second found:

http://lists.apple.com/archives/applescript-studio/2008/Aug/msg2.html

.. and I just confirmed what this link stipulates .. nothing to do  
with length:


end script

on -- crash after the space following on

John Love
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help!

2008-09-01 Thread Joshua Pennington


On Sep 1, 2008, at 4:38 AM, Michael Robinson wrote:
I need to use a NSTableView to control data input by the user.  The  
table has two columns, labeled Title and Content.  The number of  
columns is fixed.


I understand (from assorted hints I've seen online) that one may use  
a NSDictionaryController to handle data input/output/display/saving  
etc from a table.



I would use an NSArrayController that stores instances of  
NSDictionary. Each NSDictionary object will have a title key and a  
content key.


Then, bind your first table column to the array controller's  
arrangedObjects.title key  the second column to the array  
controller's arrangedObjects.content key.


Check out this tutorial for more information on setting up a table  
view - it first walks through using the traditional, non-bindings  
method, and then shows you how to use Cocoa Bindings for the task.  
While the tutorial there uses a mail application as an example, it  
*should* be close enough to point you in the right direction:


http://cocoadevcentral.com/articles/80.php

For more information on Bindings, read:

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/20002373 



Cheers,
Joshua
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Image in NSOutlineView

2008-09-01 Thread chaitanya pandit
As per the initial description of your problem, you just want to  
change the image of the cell when it is clicked(selected) right?


If thats the case then you don't have to deal with checking the image  
name etc. neither u have to do the setImage stuff in  
outlineviewSelectionDidChange
What you do is in the willdisplayCell method, check if the cell being  
displayed is for the selectd (clicked) row, if it is then change it's  
image else set the default image

here is the code snippet for the same

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell: 
(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

{
if ([[tableColumn identifier] isEqualToString:@firstColumn])
{
		// If the cell being displayed is for the selected row, change it's  
image

if ([outlineView itemAtRow:[outlineView selectedRow]] == item)
			[(ImageAndTextCell *)cell setImage:[NSImage  
imageNamed:checkbox_click.gif]];

// Else display the default image
else
			[(ImageAndTextCell *)cell setImage:[NSImage  
imageNamed:@checkbox_none.gif]];

}
}

hth,
Chaitanya

On 01-Sep-08, at 5:59 PM, [EMAIL PROTECTED] wrote:


Thanks for your consideration,
In the willDisplayCell i did like:
if ([[tableColumn identifier] isEqualToString:@firstColumn])
{
   NSString *imageName = nil;
NSImage *image = nil;
   imageName = @checkbox_none.gif;
   image = [NSImage imageNamed:imageName];
ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
   [imageAndTextCell setImage:image];
}

And in the outlineViewSelectionDidChange method Idid like:

 id cell = [[[OutlineView tableColumns] objectAtIndex:0]
  dataCellForRow:[OutlineView selectedRow]];
NSString *imageName = nil;
NSImage *image = nil;
id Name = [[cell image]name];
if([Name isEqualToString:@checkbox_none.gif])
{
  imageName = @checkbox_click.gif;
  image = [NSImage imageNamed:imageName];
  ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
  [imageAndTextCell setImage:image];
}
else
{ imageName = @checkbox_none.gif;
  image = [NSImage imageNamed:imageName];
  ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
  [imageAndTextCell setImage:image];

}
[OutlineView reloadData];

But it only work for root nodes.When I clicking on child nodes,image  
is

changing in root node. Where I got wrong ? How can I implement it in
willDisplay method ?

Thanks in advance.






The right place to change the image of the cell would be in the
outlineView's delegate method:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:
(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

 try [[cell image] name] to get the name of the image
-chaitanya

On 29-Aug-08, at 5:41 PM, [EMAIL PROTECTED] wrote:


Hi all,
I'm trying to develop an application that uses an OutlineView in
which it
displays items like a disclosure triangle, then one checkbox, then a
text
field int the same column. For that I gone through the
DragNDropOutlineview example provided with Xcode. Then I copied the
ImageAndTextCell class and uses two images, one is checked and other
is
unchecked. Now the application works with  showing one image.I  
want to

change the image when clicking on it. How can I do that ?. In which
method
I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it
faild.
When I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
id info = [cell image];
NSLog(@ %@,info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click
Size={13,
13} Reps=(
  NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13
Alpha=NO Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?

Thanks in advance

___

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

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

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

This email sent to [EMAIL PROTECTED]








___

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

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

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

This email sent to [EMAIL PROTECTED]


Mapping SyncServices properties to CoreData properties

2008-09-01 Thread Clinton Shaw
I have a CoreData application that I would like to use with Sync  
Services to sync with Address Book (using the  
com.apple.contacts.Contact schema).


I have got everything working when using properties from  
com.apple.contacts.Contact that have no spaces in the name (such as  
'nickname').  The problem arises when using properties that contain  
spaces, such as 'first name'.


When syncing sync services tries to set the managed object using the  
key 'first name' .  Being that attributes in my CoreData model can't  
have spaces I have called my attribute 'firstName'.


My question is, how do I map the 'first name' attribute used in  
com.apple.contacts.Contact to the CoreData attribute called  
'firstName' in my model?


Regards

Clinton Shaw
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to delete the current user's directory?

2008-09-01 Thread Michael Ash
On Mon, Sep 1, 2008 at 6:46 AM, XiaoGang Li [EMAIL PROTECTED] wrote:
 hi, list, I have an uninstaller application , which is used to delete
 the files installed; and also i have a file which located in the current
 user's directory, like the ~/Library/LaunchAgents/com..plist. and how
 can i delete this kind of file, i have tried the
 AuthorizationExecuteWithPrivileges
 API, it seems not workable, do i give a wrong flag value or something else?
 here is my code piece, any comments will be appreciated.

 AuthorizationRef myAuthorizationRef;

 AuthorizationFlags myFlags = kAuthorizationFlagDefaults;

 AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,myFlags,
 myAuthorizationRef);

 AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};

 AuthorizationRights myRights = {1, myItems};



 myFlags = kAuthorizationFlagDefaults |

  kAuthorizationFlagInteractionAllowed |

  kAuthorizationFlagPreAuthorize |

  kAuthorizationFlagExtendRights;

 AuthorizationCopyRights (myAuthorizationRef, myRights, NULL, myFlags, NULL);


 char *fileDir = ~/Library/LaunchAgents/com.hp.printerAgent.plist;

 char* args[3];

 args[0]= -Rf;

 args[1]= fileDir;

 args[2]= NULL;


 myFlags = kAuthorizationFlagDefaults;

 OSStatus res = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
 /bin/rm,myFlags,args,NULL);

 AuthorizationFree(myAuthorizationRef, myFlags);


 and the res value is -60032. and by the way, how can i get the current
 user's name string? which cocoa API can get it?

There should be no need to use AuthorizationExecuteWithPrivileges. You
should have permission to delete any file within the user's home
directory.

As for why you're failing, you'll want to look at this page:

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

It talks about NSTask, but the same principle applies to
AuthorizationExecuteWithPrivileges or NSFileManager (which is what I
recommend you use). That ~ character is not something that they know
about, which is why you're seeing the problem.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Code Example: FunTextField

2008-09-01 Thread Yung-Luen Lan
Ouch... You're right!

Regards,
yllan

On Mon, Sep 1, 2008 at 5:12 PM, Uli Kusterer
[EMAIL PROTECTED] wrote:
 On 01.09.2008, at 10:23, Yung-Luen Lan wrote:

 (Thanks to Brad Cox's DrawKit.)


  That would be Graham Cox. Brad Cox is someone else entirely :-)

 Cheers,
 -- Uli Kusterer
 The Witnesses of TeachText are everywhere...
 http://www.zathras.de






___

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

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

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

This email sent to [EMAIL PROTECTED]


array segment

2008-09-01 Thread James Maxwell

Hello All,

Is there an obj-C equivalent to Java's System.arraycopy() which will  
allow me to easily copy a segment of an NSArray into a new array?


If so, a one-liner example would be very much appreciated.

I looked at -getObjects:range:, but I'm not sure if this is the right  
thing since it returns void... Do I provide an array to use as  
aBuffer?


J.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: array segment

2008-09-01 Thread Shawn Erickson
On Mon, Sep 1, 2008 at 8:37 AM, James Maxwell
[EMAIL PROTECTED] wrote:
 Hello All,

 Is there an obj-C equivalent to Java's System.arraycopy() which will allow
 me to easily copy a segment of an NSArray into a new array?

 If so, a one-liner example would be very much appreciated.

-[NSArray subarrayWithRange:]

-Shawn
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: array segment

2008-09-01 Thread Greg Titus

Hi James,

It sounds like you want -subarrayWithRange:

Hope this helps,
- Greg

On Sep 1, 2008, at 8:37 AM, James Maxwell wrote:


Hello All,

Is there an obj-C equivalent to Java's System.arraycopy() which will  
allow me to easily copy a segment of an NSArray into a new array?


If so, a one-liner example would be very much appreciated.

I looked at -getObjects:range:, but I'm not sure if this is the  
right thing since it returns void... Do I provide an array to use as  
aBuffer?


J.

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: array segment

2008-09-01 Thread James Maxwell

Yup, that's the one... cheers.

J.


On 1-Sep-08, at 8:48 AM, Greg Titus wrote:


Hi James,

It sounds like you want -subarrayWithRange:

Hope this helps,
- Greg

On Sep 1, 2008, at 8:37 AM, James Maxwell wrote:


Hello All,

Is there an obj-C equivalent to Java's System.arraycopy() which  
will allow me to easily copy a segment of an NSArray into a new  
array?


If so, a one-liner example would be very much appreciated.

I looked at -getObjects:range:, but I'm not sure if this is the  
right thing since it returns void... Do I provide an array to use  
as aBuffer?


J.

___

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

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

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

This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: array segment

2008-09-01 Thread Brian Stern




Is there an obj-C equivalent to Java's System.arraycopy() which will  
allow me to easily copy a segment of an NSArray into a new array?




subarrayWithRange:
Returns a new array containing the receiver’s elements that fall  
within the limits specified by a given range.




http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/Reference/Reference.html#/ 
/apple_ref/occ/instm/NSArray/subarrayWithRange:


There is an example in the docs.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-09-01 Thread Brad Gibbs

You might find the discussion here helpful:

http://deusty.blogspot.com/search/label/NSURLRequest

After getting NSURL's to work, I decided I'd be better off with TCP  
sockets.  If you find yourself in the same position, you might try  
AsyncSockets (also available at the link above).  It's non-blocking,  
fast, easy and reliable.


Todd Ditchendorf also created some very useful tools for working with  
XMLRPC and SOAP servers, available here:


http://scan.dalo.us/


Brad


On Aug 31, 2008, at 9:30 AM, Sam Schroeder wrote:


Hi all,

I'm new to Cocoa development and I'm trying to learn the basics of
sending HTTP GETs and POSTs from Cocoa.  I've been reading up on NSURL
and searching for decent sample code.  However, I've been unable to
find something simple that _just_ explains how to send a GET and
capture the returned results.  My google_fu is weak.  My ultimate goal
is to send and receive XML (or maybe JSON) requests over HTTP, but
first I want to understand simple GETs and POSTs.

Any links or sample code would be greatly appreciated.

--
Thanks,

Sam
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie question: What does no-op mean?

2008-09-01 Thread Dale Jensen

On Aug 30, 2008, at 9:31 PM, Jon Davis wrote:

So do no-ops exist solely for the sake of being there for  
convention, i.e. do this if you're implemented, ignore if not?



In this case, that's what it's being used for.  Initially (back when  
we coded in assembly language,) NOP was most often used for timing and  
aligning memory.  Additionally, if you had to modify a live binary  
without source (legitimately, think Y2K,) NOPs can be used to modify  
the code directly without fluxoring up the jump tables.


I'm not sure that a NOP would actually show up in the resultant code  
of a NSAutoReleasePool call, I guess the compiler could substitute it,  
but it could also make the call and return nothing with the same  
result.  Or just skip the line altogether.  The documentation may be  
just using an old, but conventional, term, to let you know that  
nothing would happen.



dale

--
Dale Jensen, CEO
Ntractive, LLC
[EMAIL PROTECTED]
http://www.ntractive.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 [EMAIL PROTECTED]


Best 'native' formats for NSImage and NSSound?

2008-09-01 Thread Matt
I am building an app that uses NSImage to repeatedly draw subrects from a
set of large .PNG files. I am also using NSSound to play sound effects. I
have been using .WAV files for the NSSound's.

In running Shark on my app recently I noticed that by far, my app spent most
of its time in: CGSConvertBGR888toRGBA.

I'm having trouble understanding what this means. It appears that
CoreGraphics is having to convert some of my non-alpha channel images to
have an alpha, and perhaps re-order the bytes? But shouldn't these
conversions only occur once, when CG realizes it needs this additional
channel? My app is re-using the same NSImages each frame, simply compositing
various sub-rects from the original large images.

This leads me to my question, which is two-part: can I optimize my graphics
files or manipulate NSImage into avoiding this (CGSConvertBGR888toRGBA)
processing? Or this an unavoidable part of the drawing?

And also, seeing how much work NSImage is having to do, it got me wondering,
are there any image/sound file formats which require 'less work' on the part
of NSImage and NSSound? In terms of loading the initial data, unpacking the
bytes, etc.

I was wondering if switching to .TIFF or .AIFF (or any other formats) could
possibly provide a performance boost?

Thank you in advance for any help/advice,
-Matt
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to delete the current user's directory?

2008-09-01 Thread Graff

On Mon, 1 Sep 2008 18:46:41 +0800, XiaoGang Li wrote:

hi, list, I have an uninstaller application , which is used to  
delete
the files installed; and also i have a file which located in the  
current
user's directory, like the ~/Library/LaunchAgents/com..plist.  
and how

can i delete this kind of file, i have tried the
AuthorizationExecuteWithPrivileges
API, it seems not workable, do i give a wrong flag value or  
something else?

here is my code piece, any comments will be appreciated.



It would probably be a lot easier to use the NSFileManager method  
removeItemAtPath:error:


NSFileManager *defaultManager = [NSFileManager defaultManager];
NSArray *searchPaths;
searchPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,

  NSUserDomainMask,

  TRUE);
NSString *libraryPath = [searchPaths lastObject];
NSString *itemDirectory;
NSString *itemPath;

itemDirectory = [libraryPath stringByAppendingPathComponent:
 @LaunchAgents];
itemPath = [itemDirectory stringByAppendingPathComponent:
@com.hp.printerAgent.plist];

if([defaultManager fileExistsAtPath:itemPath]){
NSError *theError;
[defaultManager removeItemAtPath:itemPath error:theError];
}

Note that I avoided hard-coded paths by using  
NSSearchPathForDirectoriesInDomains.  This is important because hard- 
coded paths can break in many ways, such as when the user is on a non- 
english system.  By using the proper function for finding standardized  
directories you avoid as much hard-coded paths as possible.


In general I try to avoid using terminal commands in an application  
when there is a Cocoa or Carbon method that does the same thing.  By  
using the library methods you are likely to have a solution which is  
more portable and less fragile than by using terminal commands.


- Ken Bruno
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSArray as a static

2008-09-01 Thread Richard Good
I'm just learning Objective C and need to understand how to declare  
and use a static NSArray.
I think I may be confusing  the Java concept of static and Objective  
C's concept.



What I want is how to use the Java idea of a class static  variable in  
Objective C


Here's the code I'm trying to use:

//class name is Person
static  NSMutableArray* relationshipMatch;

-(id)init {
[super init];
if (relationshipMatch==nil) 
[Person initRelationshipMatch];
return self;
}
+ (void) initRelationshipMatch  {
relationshipMatch = [NSArray arrayWithObjects:
@abc,@def,@hig,nil] ;   
}


When I try to access the array using
NSString* aString = [relationshipMatch objectAtIndex:1];

I get
 *** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: '***


Any help would be appreciated.

Richard Good

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie question: What does no-op mean?

2008-09-01 Thread Andy Lee

On Aug 30, 2008, at 10:31 PM, Jon Davis wrote:
So do no-ops exist solely for the sake of being there for  
convention, i.e. do this if you're implemented, ignore if not?


I'd adjust two things about your wording.

First, a no-op method *is* implemented.  It has an implementation that  
happens to do nothing.  This is a perfectly valid method implementation:


- (void)myBoringMethod
{
// Does nothing.
}

Second, I wouldn't say no-ops are there by convention.  Rather,  
they're part of the explicit design of how the program is supposed to  
behave.  If a method does nothing, why was it created at all?  The  
typical answer is either (a) it's a fallback behavior under certain  
conditions (so it's only a no-op under those conditions), or (b) it's  
a default behavior which can optionally be overridden by a subclass.


The case you saw, -[NSAutoreleasePool release], is an example of (a).   
If you're using retain/release for memory management, the method does  
something; it's not a no-op.  If you recompile your code to use GC, - 
release becomes a no-op.  You can keep calling it in your code -- you  
don't have to go remove all your calls to it -- but it will simply do  
nothing.


As an example of case (b), there is a class called NSColorPicker with  
a method called -attachColorList: that does nothing.  The method will  
get called and it will do nothing for a regular instance of  
NSColorPicker.  You can create a custom subclass of NSColorPicker  
whose -attachColorList: method does something.


To see more examples of this second kind of no-op, you can Google for  
this (enter the stuff inside the square brackets): [does nothing  
override site:developer.apple.com].


Hope this helps,
--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 [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Jean-Daniel Dupas

Unlike java, Obj-C does not have the concept of class variable.
Your static variable is a classic C variable, and C variable are not  
automatically initialized to NULL.
The first time you call init, relationshipMatch may contains anything  
and may not be NULL, and so it will never be properly initialized.


Second error, you do not retain you variable. You create it using a  
convenient initializer wich returns an autoreleased array. At the end  
of the event loop, your array is released, and as you never retained  
it, it is deallocated.




Le 1 sept. 08 à 20:29, Richard Good a écrit :

I'm just learning Objective C and need to understand how to declare  
and use a static NSArray.
I think I may be confusing  the Java concept of static and Objective  
C's concept.



What I want is how to use the Java idea of a class static  variable  
in Objective C


Here's the code I'm trying to use:

//class name is Person
static  NSMutableArray* relationshipMatch;

-(id)init {
[super init];
if (relationshipMatch==nil) 
[Person initRelationshipMatch];
return self;
}
+ (void) initRelationshipMatch  {
relationshipMatch = [NSArray arrayWithObjects:
@abc,@def,@hig,nil] ;   
}


When I try to access the array using
NSString* aString = [relationshipMatch objectAtIndex:1];

I get
*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: '***


Any help would be appreciated.

Richard Good

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with Info.plist in 10.5 [RESOLVED]

2008-09-01 Thread Frédéric Testuz

Le 27 août 08 à 21:14, Frédéric Testuz a écrit :


Hi,

I'm writing a Leopard-target application. Therefore I'm willing to  
use UTI and the new-style for the Info.plist. I red the AppKit  
release notes and I thought I didn't forget something. But when I'm  
calling the save panel I get this error message on the console:


2008-08-27 14:12:52.522 MyApp[23412:813] An NSDocumentController  
returned nil when sent -displayNameForType:@ch.ftestuz.MyApp.rgbd.  
See the info about new support for UTIs in the Leopard AppKit  
release notes.
2008-08-27 14:12:52.523 MyApp[23412:813] An NSDocumentController  
returned nil when sent - 
displayNameForType:@ch.ftestuz.MyApp.rgbdx. See the info about new  
support for UTIs in the Leopard AppKit release notes.


I resolved the problem. I'm not exactly sure about what cause the  
resolution. I took the Info.plist of the Sketch exemple, changed it's  
data with mine. Rebuild and launched the app. At this time, the  
problem was not resolved.


Then I deleted all the keys which are obsolete in 10.5, rebuild and  
launched the app. And the problem was resolved.


I don't know if the Info.plist parser is too sensible with mix of 10.4  
and 10.5 infos. It can also be that the new infos was not immediately  
take into account by the system (LaunchService I think?).


Frédéric___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Kyle Sluder
On Mon, Sep 1, 2008 at 2:29 PM, Richard Good [EMAIL PROTECTED] wrote:
 What I want is how to use the Java idea of a class static  variable in
 Objective C

Because Objective-C doesn't have class variables (as Jean-Daniel
noted), you have to use a global variable.  The static keyword in C
means that the variable has file-level scope.  So in your Person.m
file, you would do something like this:

static NSMutableArray *relationshipMatch;
@implementation Person

+ (NSMutableArray *)relationshipMatch
{
return relationshipMatch;
}

@end

This will expose the file-scoped array using a class method.  If you
want to have direct access to the variable (violating encapsulation,
but often useful for things like constants) then you can put an extern
declaration in your Person.h like so:

extern NSMutableArray *relationshipMatch;

Then any source file that #imports Person.h will know of the existence
of an NSMutableArray *relationshipMatch, which will be defined when
Person.m is compiled.  The linker will resolve all references to this
variable.

This is how constants are usually implemented.  For example, the
NSPasteboard class uses constants to retrieve different
representations of data on the pasteboard.  An application can put a
plain-text representation and an RTF representation on the pasteboard
so other apps can consume the more appropriate representation.  The
consumer then gets the data from the pasteboard using -[NSPasteboard
dataForType:], passing in NSRTFPboardType for the RTF representation,
or NSStringPboardType for an NSString.  These constants are declared
as externs, like so:

extern NSString *NSRTFPboardType;
extern NSString *NSStringPboardType;

You get these declarations by #importing AppKit.h.  The actual
definitions of these constants happens somewhere in the AppKit source
code, which we don't have access to.  They look something like this
(the contents of the strings doesn't matter):

static NSString *NSRTFPboardType = @RTF Pasteboard Type Identifier;
static NSString *NSStringPboardType = @String Pasteboard Type Identifier;

At link time, the linker is able to resolve your code's references to
either of these constants to their definition in the AppKit library.
This is a good pattern to adopt for constants, but for implementing
things like class variables, you might not want to expose the variable
with an extern declaration, but instead by using a class method
accessor.

Hope that explains the concept well enough for you.

--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 [EMAIL PROTECTED]


Re: Problem with NSUserDefaultsController

2008-09-01 Thread Kyle Sluder
On Sun, Aug 31, 2008 at 12:13 PM, Mark Allan
[EMAIL PROTECTED] wrote:
 For what it's worth, I also get these compiler warnings for the line with
 [sharedUserDefaultsController save:]

 warning: multiple methods named '-save:' found
 warning: using '-(void)save:(id)sender'
 warning: also found '-(BOOL)save:(NSError **)error'

The compiler doesn't know which method you're trying to invoke,
because +[NSUserDefaultsController sharedUserDefaultsController] is
typed to return id.  You need to cast the return value of this method
call as an NSUserDefaultsController to satisfy the compiler.  Also,
you aren't storing the value of [super init] in self, which is
incorrect.  Your -init method needs to look like this:

 -(id)init
 {
if(self = [super init]) // one = is intentional
{
NSUserDefaultsController *shared = [NSUserDefaultsController 
 sharedUserDefaultsController];
[shared setAppliesImmediately:NO];
myPrefs = [NSUserDefaults standardUserDefaults];
[self readPrefs];
}

return self;
 }

This probably won't address your problem, but it's important.

--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 [EMAIL PROTECTED]


Re: QTCaptureConnectionEnabledAudioChannelsAttribute read only

2008-09-01 Thread Kyle Sluder
You should ask the QuickTime list.
http://lists.apple.com/mailman/listinfo/quicktime-api

--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 [EMAIL PROTECTED]


Objective-C and AppleScript

2008-09-01 Thread John Love
I am trying to convert as much as I can of my former Studio code over  
to Obj-C and thanks to this Mailing List I have been successful so  
far .. but here's a stumper or two:


Here are 2 AppleScript statements that work in Studio:

-- #1 works in Obj-C, so my question is = isn't there a more *direct*  
Obj-C call to do the same thing,
-- rather than call NSAppleScript's executeAndReturnError method?  It  
just seems that a one or two

-- system calls should effect the same result?

1) tell application System Events to return (name of every  
application process contains Microsoft Excel) -- see ExcelAppActive  
below


=

-- If I hard-code the actual name of the file  
stringByAppendingString:@some title (see theWorkbookActive method  
below),

-- everything works dandy.
--
-- But ... this name is actually a instance parameter, NSString*  
itsFileName, defined in my .h file, and dynamically set in my .m file.
-- So, I type stringByAppendingString:itsFileName -- but then my app  
crashes.


2) tell application Microsoft Excel to return (name of every window  
contains some title)


Here is the standard (I believe) method to execute the passed Script:

- (NSAppleEventDescriptor*) ExecAppleScript:(NSString*)theScript {

NSAppleScript *scriptObject;
NSDictionary *errorInfo;
NSAppleEventDescriptor *execResult;

scriptObject = [[NSAppleScript alloc] initWithSource:theScript];
errorInfo = [[NSDictionary alloc] init];
execResult = [scriptObject executeAndReturnError:errorInfo];

return execResult;   // success = (execResult != nil)

}


- (BOOL) ExcelAppActive {

BOOL ExcelActive = FALSE;
NSAppleEventDescriptor *execResult;

NSArray *ExcelActiveScriptArray = [NSArray arrayWithObjects:
@tell application \System Events\,
	@return (name of every application process contains  
\Microsoft Excel\),

@end tell,
nil];
NSString *ExcelActiveScriptString =
   [ExcelActiveScriptArray componentsJoinedByString:@\n];
 /*
tell application System Events
return (name of every application process contains Microsoft Excel)
end tell
 */

execResult = [self ExecAppleScript:ExcelActiveScriptString];
if (execResult != nil) {   // success
ExcelActive = [execResult booleanValue];
}

if (!ExcelActive) {
// do something here
}

return ExcelActive;

}


- (BOOL) theWorkbookActive {

BOOL wbActive = FALSE;
NSAppleEventDescriptor *execResult;

if ([self ExcelAppActive]) {
NSString *WorkbookActiveScript =
		   @tell application \Microsoft Excel\ to return (name of every  
window contains \;
		WorkbookActiveScript = [WorkbookActiveScript  
stringByAppendingString:itsFileName];
		WorkbookActiveScript = [WorkbookActiveScript  
stringByAppendingString:@\)];

 /*
		tell application Microsoft Excel to return (name of every window  
contains some title)

 */
NSLog(WorkbookActiveScript);

execResult = [self ExecAppleScript:WorkbookActiveScript];
if (execResult != nil) {   // success
wbActive = [execResult booleanValue];
}

if (!wbActive) {
// do something here
}
}
else {
// [self ExcelAppActive] sets and displays Error
}

return wbActive;

}


John Love


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with NSUserDefaultsController

2008-09-01 Thread Mark Allan

  I've been playing around with bindings to NSUserDefaultsController in

 a very simple app to test saving preferences, but the
 [sharedUserDefaultsController save:self] method seems to return 
immediately

 without waiting for the save operation to complete.

 The save does actually take place, which I can see if I open the 
plist file

 in Property List Editor, but if the very next line after sending the save
 message is one which reads a property from the plist, it's the old value
 which gets returned rather than the newly saved one.


 The -save: method is unintuitive in name. It does not, as you may  think,
 save changes to disk. It simply commits any changes to the  NSUserDefaults
 object. It's a no-op if appliesImmediately is YES. The only way to  force a
 save is to call -synchronize on NSUserDefaults.


 Thanks but the problem is actually the exact opposite. The file IS  being
 saved - it's the userdefaults object which doesn't contain the  right value
 unless there's some short delay between the save and  objectForKey messages.


Sorry, I misread your post. We will need to see some code to determine the
issue.


 Calling -synchronize on the userDefaults object makes no difference.

 I'm already setting appliesimmediately to YES so that I can have
 Cancel and OK buttons, and in terms of saving/reverting the plist file
 it's working fine. Do I need to perform some action to connect the
 userdefaults object to the userDefaultsController object?


Well, not other than binding it to the shared user defaults (unless you are
creating it programmatically, where it is set on creation). My understanding
is that the NSUserDefaults object is responsible for writing to disk, so if
you get the disk commit, it must be in the shared defaults.


Exactly!  That's my understanding too, which is why I'm confused.

The complete Xcode project is available here:
http://idisk.mac.com/markallan-Public/TestingNSUserDefaultsController.zip

If anyone has time to cast an eye over it, I'd really appreciate it.

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 [EMAIL PROTECTED]


Re: Problem with NSUserDefaultsController

2008-09-01 Thread Brian Stern
Apparently NSUserDefaults delays its saving until the next time  
through the event loop, perhaps by using one of the  
performSelector:afterDelay calls, or something like that.  Is it  
possible that this is what's causing your issues?


I ran into this problem when trying to save user defaults at app  
terminate time, when afterDelay never comes.



On Sep 1, 2008, at 4:07 PM, Mark Allan wrote:

 I've been playing around with bindings to  
NSUserDefaultsController in

a very simple app to test saving preferences, but the
[sharedUserDefaultsController save:self] method seems to return  
immediately

without waiting for the save operation to complete.

The save does actually take place, which I can see if I open the  
plist file
in Property List Editor, but if the very next line after sending  
the save
message is one which reads a property from the plist, it's the  
old value

which gets returned rather than the newly saved one.


The -save: method is unintuitive in name. It does not, as you  
may  think,
save changes to disk. It simply commits any changes to the   
NSUserDefaults
object. It's a no-op if appliesImmediately is YES. The only way  
to  force a

save is to call -synchronize on NSUserDefaults.


Thanks but the problem is actually the exact opposite. The file  
IS  being
saved - it's the userdefaults object which doesn't contain the   
right value
unless there's some short delay between the save and  objectForKey  
messages.


Sorry, I misread your post. We will need to see some code to  
determine the

issue.


Calling -synchronize on the userDefaults object makes no difference.

I'm already setting appliesimmediately to YES so that I can have
Cancel and OK buttons, and in terms of saving/reverting the plist  
file

it's working fine. Do I need to perform some action to connect the
userdefaults object to the userDefaultsController object?


Well, not other than binding it to the shared user defaults (unless  
you are
creating it programmatically, where it is set on creation). My  
understanding
is that the NSUserDefaults object is responsible for writing to  
disk, so if

you get the disk commit, it must be in the shared defaults.


Exactly!  That's my understanding too, which is why I'm confused.

The complete Xcode project is available here:
http://idisk.mac.com/markallan-Public/TestingNSUserDefaultsController.zip

If anyone has time to cast an eye over it, I'd really appreciate it.

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 [EMAIL PROTECTED]


AppleScript on a Context Menu

2008-09-01 Thread David Orriss Jr

OK, it's not Cocoa, per se... but I thought someone here might know.

I want to create an AppleScript that is on the Context (Ctrl+Click/ 
Right Click) menu.  I've seen ways to do it with Automator - but that  
puts the script in the automator menu.  I want it top-level.  Anyone  
have an example on how to do this that doesn't involve Automator and  
will still create an AppleScript plugin?


--
David Orriss Jr.

My blog: http://www.codethought.com/blog






___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Richard Good
Very cogent description, but I'm not trying to access the array from  
outside of the class.
I'm trying to create an array of string constants to be used inside  
the Person class.
So let me rephrase the question How do I create an array of constant  
strings such that I have only one instance for the entire class,
or is that just not possible.  If its not possible how do you approach  
the problem in Objective C.


I tried  Jean_Daniel's suggestion as to incrementing the retain count  
to no avail.
I have traced the code and am sure that the initial init is being  
called.


I think that for some reason even after changing the retain count the  
strings are being freed.


On Sep 1, 2008, at 12:18 PM, Kyle Sluder wrote:

On Mon, Sep 1, 2008 at 2:29 PM, Richard Good [EMAIL PROTECTED]  
wrote:
What I want is how to use the Java idea of a class static  variable  
in

Objective C


Because Objective-C doesn't have class variables (as Jean-Daniel
noted), you have to use a global variable.  The static keyword in C
means that the variable has file-level scope.  So in your Person.m
file, you would do something like this:

static NSMutableArray *relationshipMatch;
@implementation Person

+ (NSMutableArray *)relationshipMatch
{
   return relationshipMatch;
}

@end

This will expose the file-scoped array using a class method.  If you
want to have direct access to the variable (violating encapsulation,
but often useful for things like constants) then you can put an extern
declaration in your Person.h like so:

extern NSMutableArray *relationshipMatch;

Then any source file that #imports Person.h will know of the existence
of an NSMutableArray *relationshipMatch, which will be defined when
Person.m is compiled.  The linker will resolve all references to this
variable.

This is how constants are usually implemented.  For example, the
NSPasteboard class uses constants to retrieve different
representations of data on the pasteboard.  An application can put a
plain-text representation and an RTF representation on the pasteboard
so other apps can consume the more appropriate representation.  The
consumer then gets the data from the pasteboard using -[NSPasteboard
dataForType:], passing in NSRTFPboardType for the RTF representation,
or NSStringPboardType for an NSString.  These constants are declared
as externs, like so:

extern NSString *NSRTFPboardType;
extern NSString *NSStringPboardType;

You get these declarations by #importing AppKit.h.  The actual
definitions of these constants happens somewhere in the AppKit source
code, which we don't have access to.  They look something like this
(the contents of the strings doesn't matter):

static NSString *NSRTFPboardType = @RTF Pasteboard Type Identifier;
static NSString *NSStringPboardType = @String Pasteboard Type  
Identifier;


At link time, the linker is able to resolve your code's references to
either of these constants to their definition in the AppKit library.
This is a good pattern to adopt for constants, but for implementing
things like class variables, you might not want to expose the variable
with an extern declaration, but instead by using a class method
accessor.

Hope that explains the concept well enough for you.

--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 [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Jean-Daniel Dupas


Le 1 sept. 08 à 21:18, Kyle Sluder a écrit :

On Mon, Sep 1, 2008 at 2:29 PM, Richard Good [EMAIL PROTECTED]  
wrote:
What I want is how to use the Java idea of a class static  variable  
in

Objective C


Because Objective-C doesn't have class variables (as Jean-Daniel
noted), you have to use a global variable.  The static keyword in C
means that the variable has file-level scope.  So in your Person.m
file, you would do something like this:

static NSMutableArray *relationshipMatch;
@implementation Person

+ (NSMutableArray *)relationshipMatch
{
   return relationshipMatch;
}

@end

This will expose the file-scoped array using a class method.  If you
want to have direct access to the variable (violating encapsulation,
but often useful for things like constants) then you can put an extern
declaration in your Person.h like so:

extern NSMutableArray *relationshipMatch;

Then any source file that #imports Person.h will know of the existence
of an NSMutableArray *relationshipMatch, which will be defined when
Person.m is compiled.  The linker will resolve all references to this
variable.

This is how constants are usually implemented.  For example, the
NSPasteboard class uses constants to retrieve different
representations of data on the pasteboard.  An application can put a
plain-text representation and an RTF representation on the pasteboard
so other apps can consume the more appropriate representation.  The
consumer then gets the data from the pasteboard using -[NSPasteboard
dataForType:], passing in NSRTFPboardType for the RTF representation,
or NSStringPboardType for an NSString.  These constants are declared
as externs, like so:

extern NSString *NSRTFPboardType;
extern NSString *NSStringPboardType;

You get these declarations by #importing AppKit.h.  The actual
definitions of these constants happens somewhere in the AppKit source
code, which we don't have access to.  They look something like this
(the contents of the strings doesn't matter):

static NSString *NSRTFPboardType = @RTF Pasteboard Type Identifier;
static NSString *NSStringPboardType = @String Pasteboard Type  
Identifier;


At link time, the linker is able to resolve your code's references to
either of these constants to their definition in the AppKit library.



It will not compile:

extern int bar;
static int bar = 5;

foo.c:2: error: static declaration of ‘bar’ follows non-static  
declaration

foo.c:1: error: previous declaration of ‘bar’ was here

To be able to access globals from an other file, they have to be  
global variables and not static variables, and should be defined like  
this (without the static keyword):


NSString *NSRTFPboardType = @RTF Pasteboard Type Identifier;
NSString *NSStringPboardType = @String Pasteboard Type Identifier;












___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Clark Cox
On Mon, Sep 1, 2008 at 11:38 AM, Jean-Daniel Dupas
[EMAIL PROTECTED] wrote:
 Unlike java, Obj-C does not have the concept of class variable.
 Your static variable is a classic C variable, and C variable are not
 automatically initialized to NULL.

Note, for static variables, this is not true. All static variables are
initialized to zero.

 The first time you call init, relationshipMatch may contains anything and
 may not be NULL, and so it will never be properly initialized.

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTableView/NSOutlineView variable row height

2008-09-01 Thread Kevin Meaney

Hi,

I'm new to NSTableView and more specifically NSOutlineView. I want to  
have variable height rows in the outline view, and I need to keep  
Tiger compatibility.


Tiger provides the informal protocol method heightOfRowByItem that  
looks like it can do the job I want. However it does not seem to  
provide a way of obtaining the cell for the item. I would like to ask  
the cell (NSTextFieldCell) what its cell size is by calling cellSize  
or cellSizeForBounds since it should know how big it needs to be when  
I have set the text for the text field cell.


Since I could not find a way to make this work I've been looking for a  
workaround. I have come across RowResizableViews which looks like it  
might be able to do what I want, however when I ran the sample app it  
looks quite buggy running in Leopard.


I feel like I am missing something that should be obvious. Pointers  
would be helpful or a suggestion for something else to try.


Many thanks.

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 [EMAIL PROTECTED]


CGEventTap locks up entire system

2008-09-01 Thread Erik Aigner

Hi,

im using CGEventTap to prevent iTunes from getting the media key  
events. This works all fine, but however... when i click something on  
the UI of my application the entire system UI freezes - game over.


Why is this happening?

(the event tap callback seems not to be called when i click on a ui  
control of my app. threading issue?)


-- Erik
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Adam R. Maxwell


On Sep 1, 2008, at 11:38 AM, Jean-Daniel Dupas wrote:


Unlike java, Obj-C does not have the concept of class variable.
Your static variable is a classic C variable, and C variable are not  
automatically initialized to NULL.
The first time you call init, relationshipMatch may contains  
anything and may not be NULL, and so it will never be properly  
initialized.


Are you sure about that?  I believe C static variables are initialized  
to zero, although I prefer to initialize them explicitly.


Second error, you do not retain you variable. You create it using a  
convenient initializer wich returns an autoreleased array. At the  
end of the event loop, your array is released, and as you never  
retained it, it is deallocated.


Additionally, I'd use +initialize in a case like this, so you're  
guaranteed that it's initialized before your class is used, and do  
away with the +initRelationshipMatch method.  Using alloc/init avoids  
the memory management problem that Jean-Daniel pointed out.


+ (void)initialize
{
if (nil == relationshipMatch)
		relationshipMatch = [[NSArray allocWithZone:[self zone]]  
initWithObjects:@one, @two, @three, nil];

}


--
Adam

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Reflexive Many-to-Many in Core Data?

2008-09-01 Thread Sam Krishna

Is a reflexive many-to-many relationship possible in Core Data?

Here's what I'm thinking:

I have a table (Verse) and it needs to have a to-many relationship  
back to itself. The relationship name will be crossReferences. Is this  
possible or will I need to come up with some contortion for Core Data.


This was fairly doable (just took some mind-bending at the EOModel  
level) back in the hoary old days of EOF.


TIA!

Live Playfully,

Sam

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Kyle Sluder
On Mon, Sep 1, 2008 at 4:47 PM, Jean-Daniel Dupas
[EMAIL PROTECTED] wrote:
 It will not compile:

*facepalm*

Code written in e-mail, yada yada...

--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 [EMAIL PROTECTED]


Re: Objective-C and AppleScript

2008-09-01 Thread has

John Love wrote:

I am trying to convert as much as I can of my former Studio code  
over to Obj-C and thanks to this Mailing List I have been successful  
so far .. but here's a stumper or two:


Here are 2 AppleScript statements that work in Studio:

-- #1 works in Obj-C, so my question is = isn't there a more  
*direct* Obj-C call to do the same thing,
-- rather than call NSAppleScript's executeAndReturnError method? It  
just seems that a one or two

-- system calls should effect the same result?

1) tell application System Events to return (name of every  
application process contains Microsoft Excel) -- see  
ExcelAppActive below


If you use objc-appscript (I won't suggest the sdef/sdp/Scripting  
Bridge toolchain as an alternative as I know it has problems with  
Excel), you can check if Excel is running by calling the MEApplication  
object's -isRunning method:


// To create glue:  osaglue  -o MEGlue  -p ME  Microsoft\ Excel

	MEApplication *microsoftExcel = [MEApplication  
applicationWithBundleID: @com.microsoft.excel];

if ([microsoftExcel isRunning]) {
// do stuff here...
}

-- If I hard-code the actual name of the file  
stringByAppendingString:@some title (see theWorkbookActive method  
below),

-- everything works dandy.
--
-- But ... this name is actually a instance parameter, NSString*  
itsFileName, defined in my .h file, and dynamically set in my .m file.
-- So, I type stringByAppendingString:itsFileName -- but then my app  
crashes.


Code generation is fundamentally evil; if you need to pass values to a  
script, pack them into an NSAppleEventDescriptor and pass them to a  
handler in a compiled script via -[NSAppleScript  
executeAppleEvent:error:].


That said, appscript should suffice for general Apple event IPC, so  
the only time you should need to mess about with NSAppleScript is if  
you need to execute user-supplied scripts (appscript is pretty handy  
for that too, btw).




2) tell application Microsoft Excel to return (name of every  
window contains some title)



I would suggest doing:

	tell application Microsoft Excel to return (exists window some  
title)


as it's a bit clearer in meaning. The objc-appscript equivalent would  
be:


MEReference *ref = [[microsoftExcel windows] byName: @some title];
id result = [[ref exists] send];
BOOL windowExists = [result boolValue];

The ASTranslate tool on the appscript website is very handy if you  
need help translating application commands from AppleScript to ObjC  
syntax; there's also ASDictionary for exporting application  
dictionaries in appscript format.


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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 [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-09-01 Thread Tito Ciuro

Hi Brad,

I'm just curious... having NSURLConnection and friends working, is  
there a specific reason you decided to switch to sockets? Is there  
something in Cocoa that you think is missing?


Cheers,

-- Tito

On Sep 1, 2008, at 9:02, Brad Gibbs [EMAIL PROTECTED] wrote:


You might find the discussion here helpful:

http://deusty.blogspot.com/search/label/NSURLRequest

After getting NSURL's to work, I decided I'd be better off with TCP  
sockets.  If you find yourself in the same position, you might try  
AsyncSockets (also available at the link above).  It's non-blocking,  
fast, easy and reliable.


Todd Ditchendorf also created some very useful tools for working  
with XMLRPC and SOAP servers, available here:


http://scan.dalo.us/


Brad


On Aug 31, 2008, at 9:30 AM, Sam Schroeder wrote:


Hi all,

I'm new to Cocoa development and I'm trying to learn the basics of
sending HTTP GETs and POSTs from Cocoa.  I've been reading up on  
NSURL

and searching for decent sample code.  However, I've been unable to
find something simple that _just_ explains how to send a GET and
capture the returned results.  My google_fu is weak.  My ultimate  
goal

is to send and receive XML (or maybe JSON) requests over HTTP, but
first I want to understand simple GETs and POSTs.

Any links or sample code would be greatly appreciated.

--
Thanks,

Sam
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to delete the current user's directory?

2008-09-01 Thread Michael Ash
On Mon, Sep 1, 2008 at 1:29 PM, Graff [EMAIL PROTECTED] wrote:
 Note that I avoided hard-coded paths by using
 NSSearchPathForDirectoriesInDomains.  This is important because hard-coded
 paths can break in many ways, such as when the user is on a non-english
 system.

Actually this is not true. The directory names remain the same no
matter what language you use. It's still a good idea to use the
function rather than hard coding the names, because the names could
conceivably change in the future, but on current Mac OS X system
you'll find that Library is always called Library at the UNIX path
level.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Steven Noyes


On Sep 1, 2008, at 1:38 PM, Jean-Daniel Dupas wrote:


Unlike java, Obj-C does not have the concept of class variable.
Your static variable is a classic C variable, and C variable are not  
automatically initialized to NULL.
The first time you call init, relationshipMatch may contains  
anything and may not be NULL, and so it will never be properly  
initialized.


Note: In C, all static and global variables are initialized to zeros  
(or NULL pointers).  Local variables (auto variables  from the stack)  
are not initialized.


Steven

___

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

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

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

This email sent to [EMAIL PROTECTED]


re:Core Data: Instantiating linked entities

2008-09-01 Thread Ben Trumbull

- (void) awakeFromInsert
{
[super awakeFromInsert];

_rect = [NSEntityDescription insertNewObjectForEntityForName:@Rect
inManagedObjectContext:[self managedObjectContext]];
[_rect retain];

	_color = [NSEntityDescription  
insertNewObjectForEntityForName:@Color

inManagedObjectContext:[self managedObjectContext]];
[_color retain];
}


This code is not KVO compliant, which is required for Core Data to  
maintain object relationships.  Add calls to will/didChangeValueForKey:


- 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 [EMAIL PROTECTED]


Re: CGEventTap locks up entire system

2008-09-01 Thread Bill Cheeseman
on 2008-09-01 3:05 PM, Erik Aigner at [EMAIL PROTECTED] wrote:

 im using CGEventTap to prevent iTunes from getting the media key
 events. This works all fine, but however... when i click something on
 the UI of my application the entire system UI freezes - game over.
 
 Why is this happening?
 
 (the event tap callback seems not to be called when i click on a ui
 control of my app. threading issue?)

It's very easy to freeze up your entire system while developing an
application that uses event taps to intercept global hardware events. If
you're intercepting events then passing them along only if a test is
satisfied, I recommend creating a passive event tap until you're sure you've
got everything else working right. Then turn the tap into an active event
tap and hope for the best. Try to leave some kinds of events untapped during
development, so you can still, for example, press Command-Q to quit your app
-- which should automatically uninstall the tap and bring your machine back
to life.

Playing with my free Event Taps Testbench might help you figure out what the
issue is. Let me know privately if it does help -- or better yet if it
doesn't help and you can tell me why not. I would like to make it as useful
as possible to developers working with event taps.
http://prefabsoftware.com/eventtapstestbench.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.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 [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Shawn Erickson
On Mon, Sep 1, 2008 at 1:47 PM, Richard Good [EMAIL PROTECTED] wrote:

 I'm trying to create an array of string constants to be used inside the
 Person class.
 So let me rephrase the question How do I create an array of constant strings
 such that I have only one instance for the entire class,
 or is that just not possible.

@interface
+ (NSArray*) strings;
@end

@implementation
+ (NSArray*) strings {
static NSArray* strings = nil;
if (strings == nil) {
strings = [[NSArray alloc] init...];
}
return strings;
}
@end

Doing the above hides the static var inside of the method so it
doesn't pollute the file scoped/global name space.

-Shawn
___

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

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

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

This email sent to [EMAIL PROTECTED]


HFS Path To POSIX Path

2008-09-01 Thread J. Todd Slack

HI All,

What is the proper way to convert an HFS Path to a POSIX path?

So take: Husband:Users:slack:Music:iTunes:iTunes  
Music:Adult:Resucitation:03 - Minors at night.mp3


and convert to: /Users/slack/Music/iTunes:/Tunes Music/Adult/ 
Resucitation/03 - Minors at night.mp3


I thought there was an NSFileManager Command.

-Jason

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray as a static

2008-09-01 Thread Graham Cox


On 2 Sep 2008, at 6:47 am, Richard Good wrote:

So let me rephrase the question How do I create an array of constant  
strings such that I have only one instance for the entire class,
or is that just not possible.  If its not possible how do you  
approach the problem in Objective C.


for example:


+ (NSArray*)myListOfStringConstants
{
static NSArray* constants = nil;

if( constants == nil )
constants = [[NSArray arrayWithObjects:@constant1,  
@constant2, @constant3, nil] retain];


return constants;
}



hth,

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 [EMAIL PROTECTED]


Re: HFS Path To POSIX Path

2008-09-01 Thread James W. Walker


On Sep 1, 2008, at 5:27 PM, J. Todd Slack wrote:


What is the proper way to convert an HFS Path to a POSIX path?

So take: Husband:Users:slack:Music:iTunes:iTunes  
Music:Adult:Resucitation:03 - Minors at night.mp3


and convert to: /Users/slack/Music/iTunes:/Tunes Music/Adult/ 
Resucitation/03 - Minors at night.mp3


I thought there was an NSFileManager Command.



I don't know of a completely Cocoa approach, but you could use  
CFURLCreateWithFileSystemPath to convert the HFS path to a CFURLRef,  
and then typecast the CFURLRef as NSURL*.  A possible gotcha is that I  
don't know what character encoding would be used in an HFS path.

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: NSTableView/NSOutlineView variable row height

2008-09-01 Thread Graham Cox


On 2 Sep 2008, at 3:58 am, Kevin Meaney wrote:

I'm new to NSTableView and more specifically NSOutlineView. I want  
to have variable height rows in the outline view, and I need to keep  
Tiger compatibility.


Tiger provides the informal protocol method heightOfRowByItem that  
looks like it can do the job I want. However it does not seem to  
provide a way of obtaining the cell for the item. I would like to  
ask the cell (NSTextFieldCell) what its cell size is by calling  
cellSize or cellSizeForBounds since it should know how big it needs  
to be when I have set the text for the text field cell.


Since I could not find a way to make this work I've been looking for  
a workaround. I have come across RowResizableViews which looks like  
it might be able to do what I want, however when I ran the sample  
app it looks quite buggy running in Leopard.


I feel like I am missing something that should be obvious. Pointers  
would be helpful or a suggestion for something else to try.



Bear in mind that each row does not have its own cell, therefore  
asking the cell for its height isn't going to help you.


The cell is moved from row to row as the table is drawn, so presumably  
its height is set on the fly by asking either the delegate or the view  
what its row height should be. If your delegate implements - 
outlineView:heightOfRowByItem: then this is the source of this  
information - it can't ask the cell for the height because that's bass- 
ackwards - the cell is asking *this* method for its height. The  
delegate will supply this information from some other source, which  
you'll have to arrange. Other information such as the column width,  
content for the row and so on can be found by asking the view or  
column, and so the area bounded by a given row can be determined and  
returned by the delegate. In other words, until you calculate it, the  
table doesn't know how much height to reserve for each row beyond the  
initial fixed height set for the table as a whole.


hth,


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 [EMAIL PROTECTED]


Re: HFS Path To POSIX Path

2008-09-01 Thread Gregory Weston

J. Todd Slack wrote:


HI All,

What is the proper way to convert an HFS Path to a POSIX path?


The proper way is to make whatever effort you can to avoid having an  
HFS path to worry about in the first place. So if you have any  
control over that end of things, I'd say avoid it. In particular, if  
you're storing a file reference for any length of time, prefer aliases.


If that's not an option, I think the quickest route is through  
CFURLCreateWithFileSystemPath and CFURLCopyFileSystemPath.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to delete the current user's directory?

2008-09-01 Thread Chris Hanson

On Sep 1, 2008, at 3:46 AM, XiaoGang Li wrote:

hi, list, I have an uninstaller application , which is used to  
delete
the files installed; and also i have a file which located in the  
current
user's directory, like the ~/Library/LaunchAgents/com..plist.  
and how

can i delete this kind of file, i have tried the
AuthorizationExecuteWithPrivileges
API, it seems not workable, do i give a wrong flag value or  
something else?


NEVER use AuthorizationExecuteWithPrivileges like that.

That is not what AuthorizationExecuteWithPrivileges is for.

There is a large amount of documentation on the Apple Developer  
Connection web site describing how to perform privileged operations  
correctly and securely.  AuthorizationExecuteWithPrivileges is not how  
to do so.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: HFS Path To POSIX Path

2008-09-01 Thread Alex Heinz

You could try:

set myPath to get the location of the current track
set myPOSIXPath to POSIX path of myPath

(or perhaps combine into one statement, which I think should work.)

Alex

On Sep 1, 2008, at 6:00 PM, J. Todd Slack wrote:


Hi Gregory,


What is the proper way to convert an HFS Path to a POSIX path?


The proper way is to make whatever effort you can to avoid having  
an HFS path to worry about in the first place. So if you have any  
control over that end of things, I'd say avoid it. In particular,  
if you're storing a file reference for any length of time, prefer  
aliases.


It is an Option is AS can do it.

I do:

tell application iTunes
set myTrack to get the name of the current track
set myArtist to get the artist of the current 
track
set myAlbum to get the album of the current 
track
set myPath to get the location of the current 
track
end tell

'myPath' is an HFS path. I know when using the choose file dialog I  
can do this:


set selectedFile to POSIX file (choose file)

but I am not sure when I get the information directory from iTunes.

I then take the 'myPath' and pass to Objective-C for working with it.

-Jason


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aheinz2%40johnshopkins.edu

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to delete the current user's directory?

2008-09-01 Thread Chris Suter
Hi Chris,

On Tue, Sep 2, 2008 at 11:00 AM, Chris Hanson [EMAIL PROTECTED] wrote:
 On Sep 1, 2008, at 3:46 AM, XiaoGang Li wrote:

 hi, list, I have an uninstaller application , which is used to delete
 the files installed; and also i have a file which located in the current
 user's directory, like the ~/Library/LaunchAgents/com..plist. and how
 can i delete this kind of file, i have tried the
 AuthorizationExecuteWithPrivileges
 API, it seems not workable, do i give a wrong flag value or something
 else?

 NEVER use AuthorizationExecuteWithPrivileges like that.

 That is not what AuthorizationExecuteWithPrivileges is for.

Perhaps you could expand on that? Whilst it may not be what's required
in this case, the documentation specifically states that for
installers should use AuthorizationExceuteWithPrivileges to perform
privileged tasks, such as copying files (and by implication, removing
files) from restricted directories.

http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/02authconcepts/chapter_2_section_8.html#//apple_ref/doc/uid/TP3995-CH205-TPXREF23

On a separate note, I'm aware that the best practice for implementing
privileged helper tools has changed recently and the documentation
appears to be out of date. I believe there's a sample somewhere that
illustrates the new procedure. I had assumed that Apple would be on
the case with updating the documentation; I'll post a bug report at
some point.

-- Chris
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data: Instantiating linked entities

2008-09-01 Thread Chris Hanson

On Sep 1, 2008, at 3:15 AM, Renaud Céroce wrote:


I read somewhere in Apple's doc that an object was responsible for
instantiating the other objects it depends on. It don't find it  
logical

because I've already defined the relationships in the xcdatamodel


The reason it is logical is that your data model declares the  
relationships that may exist between any Shape, any Color, and any  
Rect.  Not just between a specific Shape, a specific Color, and a  
specific Rect.


Furthermore, each of your entities is a peer in your data model, not  
subordinate to some main entity. Thus you might actually want to set  
up your relationships such that the relationship from Color to Shape  
is to-many; that would let you have one Color that's shared among  
multiple Shapes.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


basic Core Data scaling question

2008-09-01 Thread Michael B Johnson

quick question:

Let's say I have 100,000 ManagedObjects of type A.  Each has a one-to- 
one relationship to a ManagedObject of type B, which has a reciprocal  
one-to-many relationship with all the As.


Assuming I have all 100,000 As around (I've just created them in the  
ManagedStore) - what's the most efficient way to set up the  
relationships between all those As and B?


'cause doing the things that seem obvious to me (either looping over  
the As setting their B or setting B to point to the collection of As)  
is taking way, way too freakin' long...


--
longer background:

So I've dabbled with Core Data the past few years, but it never really  
mapped well on to the kinds of apps I've been writing.  Recently,  
though,  I finally have an application that I started writing that I  
think maps really well on to it, but I'm having some initial scaling  
problems that I'm trying to understand.



Loosely, here's the scenario:

You have a Project.
Each Project has some set of Albums and Artists.
Each Artist makes some set of Images, many of which get collected in  
one more more Albums.
Each Image can have some set of ImageVersions, but most only have 1 or  
2.


For a given Project, you'll probably have 50 or so Artists, 100 or so  
Albums, 80,000 or so Images, and a total of 150,000 or so ImageVersions.


Eventually, I expect to have dozens of Projects, maybe more, so that  
the eventually database of ImageVersions would be in the low millions.


Other than the actual image data (and its corresponding proxy and  
thumbnails), all the data you need to keep around is pretty simple,  
and maps nicely on to CoreData (strings, dates, Integers of various  
sizes, etc.)


But to start reasonable (but non-trivial), let's take a Project that  
has 91K ImageVersions of 80K Images.  There 162 Albums and 29 Artists.  
I have a simple .csv file with all the info in it, and I iterate over  
it to build up an array of dictionaries of all the info.


Then taking that array of dictionaries (building those from the 91K  
line csv takes a few 10s of seconds), I then start iterating over  
them, making the appropriate MangedObjects.  I first pull out the  
Project(s) from the file (there's only 1 in this example, but there  
could be multiple), and then I make the Artist and Album objects.  For  
each of the Artist and Album objects I find the Project instance and  
wire them up.


All of that runs at a reasonable speed.

The problem comes when I start adding the Images to the managed  
store.  I time how long it takes to add 100 at a time.  The first 100  
go in 0.022 seconds, but by the time I've inserted 4,200 of them, it's  
taking 1 second/100, at 20,000 it's taking 6sec/100, and by the time  
I'm up to 90,000, it's taking over 20sec/100.  It literally takes  
hours to chew through.


After much spelunking, I've found that it's when I set the project  
relationship on the Image that is taking up all the time.  If I bring  
in all the Projects, Artists, Albums and Images without wiring up the  
Images to the Project (although I do do it for the Albums), the whole  
thing runs in about 30 seconds.


This must be a common idiom - what idiotic thing am I doing wrong?

Thanks for any help.


-- Michael B. Johnson, PhD
-- http://homepage.mac.com/drwave (personal)
-- http://xenia.media.mit.edu/~wave (alum)
-- MPG Lead
-- Pixar Animation Studios




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Objective-C and AppleScript

2008-09-01 Thread Mike Fischer


Am 01.09.2008 um 22:49 schrieb John Love [EMAIL PROTECTED]:


I am trying to convert as much as I can of my former Studio code over
to Obj-C and thanks to this Mailing List I have been successful so
far .. but here's a stumper or two:

Here are 2 AppleScript statements that work in Studio:

-- #1 works in Obj-C, so my question is = isn't there a more  
*direct*  
Obj-C call to do the same thing,
-- rather than call NSAppleScript's executeAndReturnError method?   
It  
just seems that a one or two

-- system calls should effect the same result?

1) tell application System Events to return (name of every
application process contains Microsoft Excel) -- see ExcelAppActive
below


You could use something like this:

NSArray *result = NSWorkspace sharedWorkspace]  
launchedApplications] filteredArrayUsingPredicate:[NSPredicate  
predicateWithFormat:@%K contains %@, @NSApplicationName,  
@Microsoft Excel]] valueForKey:@NSApplicationName];


Or even better (assuming Excel has the bundle ID com.microsoft.excel):

NSArray *result = NSWorkspace sharedWorkspace]  
launchedApplications] filteredArrayUsingPredicate:[NSPredicate  
predicateWithFormat:@%K = %@, @NSApplicationBundleIdentifier,  
@com.microsoft.excel]] valueForKey:@NSApplicationName];


Both result in an array of running application names matching the  
criteria just like the AppleScript code above.


(Typed in Mail.app)




=

-- If I hard-code the actual name of the file  
stringByAppendingString:@some title (see theWorkbookActive method

below),
-- everything works dandy.
--
-- But ... this name is actually a instance parameter, NSString*  
itsFileName, defined in my .h file, and dynamically set in my .m file.
-- So, I type stringByAppendingString:itsFileName -- but then my app  
crashes.


Sounds like a memory management problem. How are you defining and  
initializing itsFileName exactly?





2) tell application Microsoft Excel to return (name of every window
contains some title)

Here is the standard (I believe) method to execute the passed Script:

- (NSAppleEventDescriptor*) ExecAppleScript:(NSString*)theScript {

NSAppleScript *scriptObject;
NSDictionary *errorInfo;
NSAppleEventDescriptor *execResult;

scriptObject = [[NSAppleScript alloc] initWithSource:theScript];
errorInfo = [[NSDictionary alloc] init];


You don't allocate any errorInfo object here. That is done for you if  
an error occurs. Your code would leak the NSDictionary. In any case  
an NSDictionary would do no good as it isn't mutable. You might want  
to initialize errorInfo to nil though.




execResult = [scriptObject executeAndReturnError:errorInfo];


Where are you releasing scriptObject? You're not? That's a memory leak!



return execResult;   // success = (execResult != nil)

}


- (BOOL) ExcelAppActive {

BOOL ExcelActive = FALSE;


Cocoa uses YES and NO as constants for the BOOL type.



NSAppleEventDescriptor *execResult;

NSArray *ExcelActiveScriptArray = [NSArray arrayWithObjects:
@tell application \System Events\,
@return (name of every application process contains
\Microsoft Excel\),
@end tell,
nil];


No AppleScript necessary, see above.

And AppleScript allows this syntax: tell application xyz to blah

Instead of: tell application xyz
  blah
end tell

That would have saved you the trouble of assembling a string fron an  
array. Or you could have used \n to assemble the string in one go  
like this:


 NSString *ExcelActiveScriptString = @tell application  
\System Events\\n
	return (name of every application process contains  
\Microsoft Excel\)\n

  end tell;



NSString *ExcelActiveScriptString =
   [ExcelActiveScriptArray componentsJoinedByString:@\n];
  /*
tell application System Events
return (name of every application process contains Microsoft Excel)
end tell
  */

execResult = [self ExecAppleScript:ExcelActiveScriptString];
if (execResult != nil) {   // success
ExcelActive = [execResult booleanValue];
}


If you use the pure Cocoa method described above you would check the  
result array for count  0 like this:


 ExcelActive = ([result count]  0) ? YES : NO;


if (!ExcelActive) {
// do something here
}

return ExcelActive;

}


- (BOOL) theWorkbookActive {

BOOL wbActive = FALSE;
NSAppleEventDescriptor *execResult;

if ([self ExcelAppActive]) {
NSString *WorkbookActiveScript =
   @tell application \Microsoft Excel\ to return (name of 
every
window contains \;
WorkbookActiveScript = [WorkbookActiveScript

Re: HFS Path To POSIX Path

2008-09-01 Thread J. Todd Slack

HI Alex,

Yes that does work for me in two steps, but I cannot get it to work in  
one.


Thank You!

-Jason

On Sep 1, 2008, at 6:14 PM, Alex Heinz wrote:


You could try:

set myPath to get the location of the current track
set myPOSIXPath to POSIX path of myPath

(or perhaps combine into one statement, which I think should work.)

Alex

On Sep 1, 2008, at 6:00 PM, J. Todd Slack wrote:


Hi Gregory,


What is the proper way to convert an HFS Path to a POSIX path?


The proper way is to make whatever effort you can to avoid having  
an HFS path to worry about in the first place. So if you have any  
control over that end of things, I'd say avoid it. In particular,  
if you're storing a file reference for any length of time, prefer  
aliases.


It is an Option is AS can do it.

I do:

tell application iTunes
set myTrack to get the name of the current track
set myArtist to get the artist of the current 
track
set myAlbum to get the album of the current 
track
set myPath to get the location of the current 
track
end tell

'myPath' is an HFS path. I know when using the choose file dialog I  
can do this:


set selectedFile to POSIX file (choose file)

but I am not sure when I get the information directory from iTunes.

I then take the 'myPath' and pass to Objective-C for working with it.

-Jason


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aheinz2%40johnshopkins.edu

This email sent to [EMAIL PROTECTED]





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: basic Core Data scaling question

2008-09-01 Thread Quincey Morris

On Sep 1, 2008, at 18:52, Michael B Johnson wrote:

The problem comes when I start adding the Images to the managed  
store.  I time how long it takes to add 100 at a time.  The first  
100 go in 0.022 seconds, but by the time I've inserted 4,200 of  
them, it's taking 1 second/100, at 20,000 it's taking 6sec/100, and  
by the time I'm up to 90,000, it's taking over 20sec/100.  It  
literally takes hours to chew through.


After much spelunking, I've found that it's when I set the project  
relationship on the Image that is taking up all the time.  If I  
bring in all the Projects, Artists, Albums and Images without wiring  
up the Images to the Project (although I do do it for the Albums),  
the whole thing runs in about 30 seconds.


First of all, make sure you set the managed object context's undo  
manager to nil while you import all the data.


Second, find out if it's a virtual memory problem or something within  
Core Data that's slowing things down. Activity Monitor is fine for  
this, because you don't need exactness. Watch your app's real and  
virtual memory allocation while it imports, and see if it goes up  
without limit. If so (which is my guess), it's likely only a memory  
footprint problem.


Third, read the section of the Core Data programming guide about  
importing data efficiently. Keep in mind that if you just keep adding  
objects to a managed object context, they (and their properties) are  
all kept in memory PLUS whatever caches Core Data keeps internally.


Generally, the approach for importing large amounts of data is  
approximately this:


-- import some data, let's say 50-500MB, depending on how much RAM you  
expect to have to play with


-- do a [NSManagedObjectContext save:error] to get everything that's  
dirty written to disk


-- fault out everything you no longer need with  
[NSManagedObjectContext refreshObject:mergeChanges:] (or release the  
managed object context and create a new one)


-- drain the autorelease pool (if doing old-fashioned memory  
management) or force garbage collection


Repeat for each successive batch of data.


___

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

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

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

This email sent to [EMAIL PROTECTED]


acceptsFirstMouse with NSTableView

2008-09-01 Thread Ron Wagner
I am trying to get an NSTableView to change it's selection when  
clicking on one if it's cells when it's window is not active. I have  
subclassed NSTableView, overridden acceptsFirstMouse: and return YES  
unconditionally, and verified that it is getting called. Can't seem to  
get it to change behavior. Still takes once click to activate the  
window and a second click to select the clicked on cell. What is the  
trick to getting this to work?


I've googled for the answer and found a few other people asking, but  
no answers.


Thanks
Ron Wagner
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSDateFormatter and Display Value bindings

2008-09-01 Thread Jamie Phelps
I have a label that I want to display the date range for which I am  
displaying data. So, the label would say July 1, 2008 to September 1,  
2008 for my QTD numbers. That is simple enough, but when I set the  
display value binding to my startDate and endDate objects' values,  
they display without any formatting. Is it possible to apply an  
NSDateFormatter to a label that utilizes display values? I found this  
message asking the same thing, so it must not be too uncommon a  
question.


Thanks,
Jamie
___

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

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

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

This email sent to [EMAIL PROTECTED]


Creating movie on background thread

2008-09-01 Thread Roger Herikstad
Hi lists,
 Sorry for the cross-posting, but I thought my issue to relevant for
both lists. I need to create an image sequence of some plots from a
graphing application that i'm writing, and I would like to be able to
do this on a background thread. Basically, I ask my app to plot some
signals on screen (~1000 individual signals) and once I'm happy with
how the signals look, I'd like to create an image sequence so that if
I want to look at those signals again, I have only to load up the
movie instead of plotting them again. I'm using an NSOperation object
for constructing my movie. The relevant code is

- (void)createMovieInRect:(NSRect)aRect
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSError *error = [NSError errorWithDomain: @thisDomain code: 1
userInfo: nil];
QTMovie *movie = [[QTMovie alloc] initToWritableFile: output_file
error: error];
//QTMovie *movie = [QTMovie movie];

//NSImage *image = NULL;
QTTime duration = QTMakeTime(1,10);

NSDictionary *attribs = nil;
attribs = [NSDictionary dictionaryWithObjectsAndKeys:@avc1,
   QTAddImageCodecType,
   [NSNumber numberWithLong:codecHighQuality],
   QTAddImageCodecQuality,
   nil];
QTTime dur;
BOOL success = NO;
int i;
NSLog([NSString stringWithFormat: @Creating movie of %d
frames\n,num_waves ]);

for(i=0;i num_waves;i++)
{
[_image release];
_image = NULL;
[self setdrawWaves: [NSIndexSet indexSetWithIndex: i]];
[self drawInRect: aRect];
[movie addImage: [self image] forDuration: duration
withAttributes: attribs];
success = [movie updateMovieFile];
CGContextRestoreGState(context);

}

[movie release];
[_image release];
[pool release];
}

When I create my operation object and add it to the queue, the process
of creating the movie seems exceedingly slow, 1 hour+ to create a
movie consisting of 1,000 images. My question is, is there something
in the QTKit that prevents it from working properly on a background
thread? There are probably other issues with my code that could be
optimised, but I just wanted to rule out multi-threading problems.
Thanks!

~ Roger
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating movie on background thread

2008-09-01 Thread James Chen
Hi,

Despite thread issue, I think there's a memory management issue which is
mentioned in Apple's document,Memory Management Programming Guide for
Cocoa(http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Concepts/AutoreleasePools.html).

If you write a loop that creates many temporary objects, you may create an
autorelease pool inside the loop to dispose of those objects before the next
iteration. This can help reduce the maximum memory footprint of the
application.

Hope this help.

Best Regards, 
James Chen
Presentation Product Division
TEL: +886-2-2226-3630ext 8538
FAX: +886-2-2226-8751
Mailto: [EMAIL PROTECTED]
http://www.avermedia.com
AVerMedia Information, Inc.
  
簡報產品事業單位: 陳銘崧
圓展科技股份有限公司
This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive messages for the
addressee), you cannot use, copy or disclose to any third party or any
information contained in the message. If you have received the message in
error, please advise the sender by reply e-mail and delete the message.
Nothing in this message should be interpreted as a digital or electronic
signature that can be used to authenticate a contract or to other legal
document. Thank you very much.


 From: Roger Herikstad [EMAIL PROTECTED]
 Date: Tue, 2 Sep 2008 12:50:19 +0800
 To: Cocoa cocoa-dev@lists.apple.com, Quicktime QuickTIme
 [EMAIL PROTECTED]
 Subject: Creating movie on background thread
 
 Hi lists,
  Sorry for the cross-posting, but I thought my issue to relevant for
 both lists. I need to create an image sequence of some plots from a
 graphing application that i'm writing, and I would like to be able to
 do this on a background thread. Basically, I ask my app to plot some
 signals on screen (~1000 individual signals) and once I'm happy with
 how the signals look, I'd like to create an image sequence so that if
 I want to look at those signals again, I have only to load up the
 movie instead of plotting them again. I'm using an NSOperation object
 for constructing my movie. The relevant code is
 
 - (void)createMovieInRect:(NSRect)aRect
 {
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 NSError *error = [NSError errorWithDomain: @thisDomain code: 1
 userInfo: nil];
 QTMovie *movie = [[QTMovie alloc] initToWritableFile: output_file
 error: error];
 //QTMovie *movie = [QTMovie movie];
 
 //NSImage *image = NULL;
 QTTime duration = QTMakeTime(1,10);
 
 NSDictionary *attribs = nil;
 attribs = [NSDictionary dictionaryWithObjectsAndKeys:@avc1,
QTAddImageCodecType,
[NSNumber numberWithLong:codecHighQuality],
QTAddImageCodecQuality,
nil];
 QTTime dur;
 BOOL success = NO;
 int i;
 NSLog([NSString stringWithFormat: @Creating movie of %d
 frames\n,num_waves ]);
 
 for(i=0;i num_waves;i++)
 {
 [_image release];
 _image = NULL;
 [self setdrawWaves: [NSIndexSet indexSetWithIndex: i]];
 [self drawInRect: aRect];
 [movie addImage: [self image] forDuration: duration
 withAttributes: attribs];
 success = [movie updateMovieFile];
 CGContextRestoreGState(context);
 
 }
 
 [movie release];
 [_image release];
 [pool release];
 }
 
 When I create my operation object and add it to the queue, the process
 of creating the movie seems exceedingly slow, 1 hour+ to create a
 movie consisting of 1,000 images. My question is, is there something
 in the QTKit that prevents it from working properly on a background
 thread? There are probably other issues with my code that could be
 optimised, but I just wanted to rule out multi-threading problems.
 Thanks!
 
 ~ Roger
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jam.chen%40avermedia.com
 
 This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Bindings - newbie question

2008-09-01 Thread Oleg Krupnov
I have two objects: a MyDocument (NSDocument subclass) and a custom
MyController controller (NSObject subclass). In the MyDocument there
is currMode property. The controller class also has the currMode
property. I want these two properties to be bound to each other
two-way, so that when either of the properties changes, the other
updates respectively.

What I do:
From within MyDocument's windowControllerDidLoadNib message:

[myController bind: @currMode toObject: self withKeyPath:@currMode
options:nil];

I do not override bind, unbind etc. of MyController relying on the
default implementation of bindings in NSObject.

Now when the myController's currMode properties changes by its view,
nothing happens in MyDocument. It's setCurrMode is not sent.

What am I doing wrong?

I have two accompanying questions:
1) Should I send the bind message to myDocument to observe
myController as well? I used to think that bindings are two-way
inherently, i.e. the object whose bind message is invoked, stores
its observed object and when the observer's property changes, it
updates the observed object automatically. Am I wrong?

2) Am I allowed to send [myController setCurrMode:] in order for the
binding to fire, or am I obliged to always send [myController
setValue:... forKey:@currMode] for this?
___

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

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

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

This email sent to [EMAIL PROTECTED]