re: Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Ben Trumbull

Specifically my entity has a 'transformable' attribute for which the
values are a custom object class, and this object class has an ivar
that is an NSMutableDictionary.  The user can modify entries in this
dictionary, and I would like this to cause the context to be flagged
as dirty and to have the custom object flagged to be updated in the
persistent store.


Attributes can only be effectively immutable value types.  While it's  
fine to use any kind of NSDictionary with transformable properties,  
once it is assigned, we expect it to act immutable.  We expect  
transfer of ownership, not side effects occurring out from underneath  
us.  NSManagedObject owns all its attribute properties.  The same  
thing is true for NSMutableString.  There are no KVO notifications for  
hacking on its characters after setting it as a modeled property value.


This pattern is usually a flawed model design.  If the properties are  
to be this independently mutable, then there should be a relationship,  
and/or the complex attribute should be decomposed into several  
attributes.  This is, after all, a gross violation of encapsulation.


Issuing calls to will/didChange manually won't help since the property  
didn't change.  will/didChange calls need to bracket the actual  
change.  In theory, you could add a transient "generation count", and  
have every client who hacks on the mutable dictionary out from  
underneath your managed object increment it.


Hard to see what that buys you over, say, writing proper setters and  
getters for the sub-properties stored in the dictionary, and stop  
clients mutating the dictionary directly.  Restore clean encapsulation.


For arbitrary keys, some people override -valueForUndefinedKey:   
Personally, I think that's rather skanky, but it appears to satisfy  
many.  It would certainly work better than your current approach.


If you had intended it to work as a value type, mark the property as  
copy and use the dynamic setters, or make your custom setters perform  
a copy.


- Ben

___

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

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

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

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


Possible to load window from nib in thread from Finder CM plugin

2009-05-28 Thread Aaron London
I'm working on a Finder CM plugin that needs a more complex UI for  
some menu item commands than CFUserNotificationCreate provides. All  
menu item commands for this CM perform work via an NSObject derived  
class on a thread so as not to block the Finder. Is it possible from  
that thread to load a NSWindow from a nib and be able to have that  
window respond to UI events?


Thanks,
A
___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-28 Thread Justin Palmer
I had to do this recently.  I needed to convert an NSXMLDocument to an
NSDictionary.  If you're interested, you can find the code on GitHub:

http://github.com/Caged/aixmlserialize/blob/5322baec2f075d6f4f3bf9cab53b6a606c48ad76/src/AIXMLElementSerialize.m

Justin Palmer
http://alternateidea.com | http://entp.com


On Wed, May 27, 2009 at 1:14 PM, McLaughlin, Michael P. wrote:

> In reviewing the NSXML documents, I found no really simple way to traverse
> a
> subtree of an NSXMLDocument.  That is, traverse from the root until you hit
> the node with the right name then pretend that that node is the root of a
> smaller tree and traverse just the latter.  [Everything I found talked only
> about sibs and (immediate) children, not grandchildren, etc.]
>
> Since this is such a common thing to do, I'm guessing that I must have
> misread the docs somehow.
>
> Could someone clue me in as to the preferred method to do a subtraversal?
>
> TIA.
>
> --
> Mike McLaughlin
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/encytemedia%40gmail.com
>
> This email sent to encyteme...@gmail.com
>
___

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

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

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

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


NSNotificationCenter CPU usage problem

2009-05-28 Thread Mike Crowe
Hi all,
I'm running into a CPU usage problem with my Cocoa application. Basically
once the app has been running for a few hours it starts, all of a sudden, to
steadily consume an increasing amount of CPU.

On further investigation with Instruments, it seems that object allocations
seem to be the cause:

#Object AddressCategoryCreation TimeSizeResponsible
LibraryResponsible Caller
263190x9b23e5002:34.281Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263200x9b23e6002:34.285Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263210x9b23e7002:34.290Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263220x9b23e8002:34.295Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263230x9b23e9002:34.299Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263240x9b23ea002:34.302Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263250x9b23eb002:34.306Foundation-[NSNotificationCenter
addObserver:selector:name:object:]
263260x9b23ec002:34.309Foundation-[NSNotificationCenter
addObserver:selector:name:object:]

The screenshot below from Instruments shows the graph steadily increasing as
more and more observers are added:
http://jottle.net/Instruments.png


I am not using NSNotificationCenter directly anywhere in my application.
I've also noticed that when the app is hidden with [mainWindow
orderOut:nil]; and shown again, that the CPU usage returns to normal.


I've looked through the NSNotificationCenter docs, but haven't found
anything obvious.
I'm a novice Cocoa developer so apologies if I have overlooked something
simple.

Any help is much appreciated,
Mike.
___

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

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

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

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


issue porting resource files code from 10.4 to 10.5

2009-05-28 Thread Victor Bovio

Hello everyone,

I'm porting an Application from 10.4 to 10.5 at 64 bit, and I have a  
problem with resource files,

in the Tiger app I have this code to read some resource files:

FSSpec spec;
FSRef ref;
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath: myPathString];
if (CFURLGetFSRef(url, &ref))
{
	OSStatus result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL,  
&spec, NULL);

if (result == noErr)
{
SInt16 refNum = FSpOpenResFile(&spec, fsRdPerm);
// do stuff
}
}


that works fine, but now in Leopard, FSSpec is deprecated as well as  
FSpOpenResFile, the docs say

to use FSOpenResourceFile instead, so I tried this:

ResFileRefNum ref;
FSRef fileRef;
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath: myPathString];
if (CFURLGetFSRef(url, &fileRef))
{
OSErr err = FSOpenResourceFile(&fileRef, 0, NULL, fsRdPerm, &ref);
if (err == noErr)
{
// do stuff...
}
}

err returns -39 which is eofErr.. I also tried this:

ResFileRefNum ref;
HFSUniStr255 forkName;
FSRef fileRef;
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath: myPathString];
if (CFURLGetFSRef(url, &fileRef))
{
	FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, &forkName, NULL,  
NULL);
	OSErr err = FSOpenResourceFile(&fileRef, forkName.length,  
forkName.unicode, fsRdPerm, &ref);

if (err == noErr)
{
// do stuff...
}
}

err returns -1402 which is errFSBadForkName

I'm lost on how I should port this from Tiger to Leopard, any ideas or  
hints how this has to be done ???


Many Thanks.


___

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

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

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

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


multiple windows (dialogs) per nib (.xlib) file

2009-05-28 Thread John Yeh
How do I open a specific window in a nib file? I tried to use the following 
code, but it displays ALL the windows in that nib file.
DialogController
-[id]init
{
self = [super initWithWindowNibName:@"MyNibName"];
}
DialogController *dialogController = [[DialogController alloc] init];
[NSApp runModalForWindow: [dialogController window];

This is sure to open all the windows. If I name the windows as "MyDialog1", 
"MyDialog2", and so on, how to render "MyDialog1" exclusively?
Thanks.
-John
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Sean McBride
On 5/28/09 11:25 AM, Ben Trumbull said:

>> Specifically my entity has a 'transformable' attribute for which the
>> values are a custom object class, and this object class has an ivar
>> that is an NSMutableDictionary.  The user can modify entries in this
>> dictionary, and I would like this to cause the context to be flagged
>> as dirty and to have the custom object flagged to be updated in the
>> persistent store.
>
>Attributes can only be effectively immutable value types.

Rick,

Once you understand Ben's comments, something else follows: mutating a
ManagedObject's attribute wreaks havoc with undo.  Undo after all keeps
a history of changed attributes, and if you go mutating them, well...

--

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


___

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

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

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

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


Re: multiple windows (dialogs) per nib (.xlib) file

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 11:36 AM, John Yeh  wrote:
> How do I open a specific window in a nib file? I tried to use the following 
> code, but it displays ALL the windows in that nib file.

Typically, you only have one window per nib file.  There's usually a
one-to-one correspondence between nib files and NSWindowController
subclasses, with each subclass knowing how to control a certain "kind"
of window (which is loaded from its corresponding nib).

That's not your immediate problem, though.  Your immediate issue is
that your windows have "Visible when Launched" checked in Interface
Builder.

--Kyle Sluder
___

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

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

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

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


Re: How to get the selected popupmenu item with core data

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 11:16 AM, Michael Süssner
 wrote:
> Now I have the problem how I can read the index of the currently selected
> object of the popupmenu.

This is typically indicative of a flawed design.  You shouldn't be
asking the UI for this; bind one of the selection bindings to a
property of your controller and use that value.

--Kyle Sluder
___

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

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

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

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


Re: Clarification on the purpose of NSUserDefaults (newbie)

2009-05-28 Thread Fritz Anderson

On 26 May 2009, at 6:34 PM, Diego Rey Mendez wrote:

I'm new to development on the iPhone.  I have been reading for a  
while now
the official docs, and some tutorials and posts online explaining  
the use

of NSUserDefaults.
My questions:

1) It sounds to me as if this is the preferred class for storing the  
user

preferences for my application, right?


Right.

2) What's the preferred class/method for storing larger chunks of  
data?  Is

it NSFileManager?


That depends on what you're storing, how much, and what you're  
comfortable with. Here are the methods I can think of in two minutes  
at the keyboard:


1) If it's less than a few thousand Cocoa objects, implement  
 and use NSKeyedArchiver and NSKeyedUnarchiver. You get a  
lot for free.


2) If it's a lot of data, use the SQLite3 database library.

3) Use POSIX I/O primitives, if your code already relies on them or  
you're most comfortable with them.


4) There are content-reading and -writing methods in NSFileManager, if  
it's practical to work with NSData as the input and output.


5) NSString, NSDictionary, NSData, and NSArray all  
have ...WithContentsOfFile or ...URL methods, and symmetric writers.  
The container classes have to contain only NSCoding-compliant objects.


You have lots of options. You might get better answers if you can tell  
us what you're trying to accomplish.


See "iPhone Application Programming Guide," chapter "Files and  
Networking;" and "Archives and Serializations Programming Guide for  
Cocoa."


— F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- 


___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Rick Hoge


Ben, Quincey, Sean, thanks for the comments.  Maybe there are some  
lower level design issues to rethink.


This pattern is usually a flawed model design.  If the properties  
are to be this independently mutable, then there should be a  
relationship, and/or the complex attribute should be decomposed into  
several attributes.  This is, after all, a gross violation of  
encapsulation.


Issuing calls to will/didChange manually won't help since the  
property didn't change.  will/didChange calls need to bracket the  
actual change.  In theory, you could add a transient "generation  
count", and have every client who hacks on the mutable dictionary  
out from underneath your managed object increment it.


Hard to see what that buys you over, say, writing proper setters and  
getters for the sub-properties stored in the dictionary, and stop  
clients mutating the dictionary directly.  Restore clean  
encapsulation.


The core data app I'm working on manages a database of images, and is  
also supposed to allow construction of a sequence of image processing  
operations.  A processing operation is implemented as an instance of  
an 'operation' class (loaded as plugins which must be shared with non- 
core-data apps), which has a dictionary of input parameters and output  
values (similar to an Image Unit).  In general, the core data app does  
not know what kind of input parameters will be supported by the  
'operation' objects it has to represent, although these are always  
contained in a mutable dictionary. This means that the core data app  
can't really provide getters and setters because the actual parameter  
names (dictionary keys) are not known until run time.


In the core data app, I am creating an entity to represent an  
operation, with the actual operation object as a custom attribute (as  
per the docs).  The user can change the input parameters in the  
object's dictionary of inputs, and this should be reflected in the  
persistent store of corresponding to the custom attribute on disk.  I  
realize this is ugly, but I can't think of any other way to do it  
given that the available operation classes are loaded as plugins at  
run time.


It is almost working, but I need a way to tell the persistent store  
coordinator to re-archive the custom attribute even though only the  
contents and not the actual object have changed.


One thing I could do, I suppose, is to add a set of parameter entities  
as a to-many relationship of the operation entity.  This could be  
populated when the operation object is 'loaded' (added to the  
sequence), and the user would edit the parameter entities.  Just  
before the operation object is to be run, I could update its 'inputs'  
dictionary based on the core data entities.  This creates other  
difficulties however (for example the operation objects can manage a  
user interface view used to visualize the configuration settings).


It would be nice if undo/redo worked, although for this small  
component of the application it would not be the end of the world if  
it didn't.


Again, if anyone has ideas on how to approach this design I'd be very  
grateful.


Rick

___

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

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

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

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


Re: Possible to load window from nib in thread from Finder CM plugin

2009-05-28 Thread Nick Zitzmann


On May 28, 2009, at 7:37 AM, Aaron London wrote:

Is it possible from that thread to load a NSWindow from a nib and be  
able to have that window respond to UI events?



No; it is a bad idea to load nibs in threads other than the main  
thread. You can't count on both the AppKit and instantiated objects  
with -awakeFromNib methods to be thread-safe.


Nick Zitzmann


___

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

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

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

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


How to activate Find and Replace for Textview?

2009-05-28 Thread archana udupa
Hi lists
   Thanks in advance for those who can help me..:)I have subclass of
textview. I want to add find and replace menu items.How can i do that?
-- 
With Regards,
  -
  Archiez...:0)
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 11:59 AM, Rick Hoge  wrote:
>  The user can change the input parameters in the object's dictionary of
> inputs, and this should be reflected in the persistent store of
> corresponding to the custom attribute on disk.  I realize this is ugly, but
> I can't think of any other way to do it given that the available operation
> classes are loaded as plugins at run time.

This is where you violate Core Data's assumptions.  Instead of
mutating the dictionary, you need to provide a new one every time.

Or, you could have a "Parameter" entity, with two attributes: "key" and "value".

--Kyle Sluder
___

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

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

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

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


Re: How to get the selected popupmenu item with core data

2009-05-28 Thread Michael Süssner

I have found a solution.
By adding a property to the File's Owner I have been able to bind the  
attribute to the PopupMenu and now it works fine.


I think that this implementation is according to the MCV-pattern,  
isn't it.


Thanks, for the help

Am 28.05.2009 um 20:49 schrieb Kyle Sluder:


On Thu, May 28, 2009 at 11:16 AM, Michael Süssner
 wrote:
Now I have the problem how I can read the index of the currently  
selected

object of the popupmenu.


This is typically indicative of a flawed design.  You shouldn't be
asking the UI for this; bind one of the selection bindings to a
property of your controller and use that value.

--Kyle Sluder



___

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

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

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

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


Re: Bindings and core data

2009-05-28 Thread Michael Süssner

Thanks for the hint


Am 28.05.2009 um 01:23 schrieb Shlok Datye:

The reason why IB complains is that the dot accessor only returns a  
regular set. You should therefore use "IBOutlet NSSet  
*selParticipants" instead.


For the same reason, you cannot add a participant to  
selection.participants using addObjects. Instead, you should either  
(1) use mutableSetValueForKey:@"participants" to get a genuine  
mutable set and then add your object(s) to that set; or (2) use the  
addParticipantsObject: or addParticipants: methods after properly  
declaring them.


For more information, you can read the "To-many relationships"  
subsection on this page:


http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html

Shlok Datye
Coding Turtle
http://codingturtle.com


On 27.05.2009, at 21:18, Michael Süssner wrote:


Hi
I am experimenting with core data and bindings.

I have a core data table with a one to-many relationship named  
"participants"


I have in the same view another table displaying a list of  
participants. I want to add additional participants using a  
Popuplist with contacts and a participant is related to contacts.


So, when I have selected a contact entry, I press a button which  
calls method of the PopUpMenu Controller Object, which reads the  
selected Object by


vContact = [[self selectedObjects] objectAtIndex:0];


I have defined in the PopupMenu Controller Object
IBOutlet NSMutableSet *selParticipants;

which I have bound to the table.selection.participants

(I do not understand that IB complains that it is not NSMutableSet)


Then I want to add the vContact to the selection.participants using  
addObjects but the table of participants displays invalid values.


I am not sure what is the mistake.

Michael




Mit freundlichem Gruß

Michael Süssner Dipl.-Ing.
Wimbergergasse 10-44
1070 Wien
Tel: +43 (1) 5268251
Mobil: +43 (676) 7955229



___

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

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

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

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


remove object from one-to-many relationship

2009-05-28 Thread Michael Süssner
I have a master-detail view, where the detail contains another table  
with a one-to-many relationship.


I have added a Remove Button which I have linked to the corresponding  
controller object.


Although the list is not empty, I cannot remove any relationship. Then  
I have bound the canRemove key and learned that the Remove button  
remains disabled (???)


In the master view I have also got a remove Button with no problems.

I don't see the difference.
Besides no errors, etc.

Any suggestion?

Michael
___

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

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

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

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


Re: How to get the selected popupmenu item with core data

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 12:36 PM, Michael Süssner
 wrote:
> I think that this implementation is according to the MCV-pattern, isn't it.

Yes, that's correct.

--Kyle Sluder
___

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

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

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

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


Re: How to activate Find and Replace for Textview?

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 12:11 PM, archana udupa  wrote:
>   Thanks in advance for those who can help me..:)I have subclass of
> textview. I want to add find and replace menu items.How can i do that?

Look at the default Edit:Find:Find… menu item.  It's wired up to First
Responder's -performFindPanelAction: method.  The documentation for
this (NSTextView) method describes how it works.  Basically, when you
send an NSTextView -performFindPanelAction:, it asks the sender for
its tag.  This tag must be one of the NSFindPanelAction constants
(listed in the documentation), and its value determines what the text
view does.

--Kyle Sluder
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Rick Hoge


Just a follow-up.  It's not perfect, and I'll revisit the design, but  
it does what I need for now.



Specifically my entity has a 'transformable' attribute for which the
values are a custom object class, and this object class has an ivar
that is an NSMutableDictionary.  The user can modify entries in this
dictionary, and I would like this to cause the context to be flagged
as dirty and to have the custom object flagged to be updated in the
persistent store.


I got this all to work the way I need using the following strategy:

1)  I used the dual representation (transient object + persistent  
transformable data) for my custom object attribute, as described in  
the Core Data docs on Non-Standard Persistent Attributes.


2)  When the entity is fetched I create the transient object  
representation from the persistent data attribute.  When the entity is  
fetched or inserted I add an observer for every entry in the  
dictionary of the custom object.


3)  If one of the observers is triggered, I invoke will/ 
didChangeValueForKey: for the persistent data attribute.  This causes  
the context to be flagged as dirty if a dictionary entry is changed.


4)  I implement -willSave in the entity's class, and here assign the  
persistent data attribute as shown in the Core Data doc example for  
the "Delayed-Update Set Accessor".  This assignment causes the data to  
be rewritten to the disk store.  The objects themselves are pretty  
light-weight, so the fact that they will be re-written on every save  
is not a huge deal.


This is a relatively small part of the whole app, so I can live for  
now with the fact that changes to these dictionary entries won't  
benefit from undo/redo.  In fact the objects in question are shared  
with a number of other apps that don't have undo/redo, so this will  
not be too shocking to the users (although it would have been nice).







___

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

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

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

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


Re: Send Keyboard Events

2009-05-28 Thread Dave Keck
Check out CGPostKeyboardEvent.
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Ben Trumbull


On May 28, 2009, at 11:59 AM, Rick Hoge wrote:



Ben, Quincey, Sean, thanks for the comments.  Maybe there are some  
lower level design issues to rethink.


This pattern is usually a flawed model design.  If the properties  
are to be this independently mutable, then there should be a  
relationship, and/or the complex attribute should be decomposed  
into several attributes.  This is, after all, a gross violation of  
encapsulation.


Issuing calls to will/didChange manually won't help since the  
property didn't change.  will/didChange calls need to bracket the  
actual change.  In theory, you could add a transient "generation  
count", and have every client who hacks on the mutable dictionary  
out from underneath your managed object increment it.


Hard to see what that buys you over, say, writing proper setters  
and getters for the sub-properties stored in the dictionary, and  
stop clients mutating the dictionary directly.  Restore clean  
encapsulation.


The core data app I'm working on manages a database of images, and  
is also supposed to allow construction of a sequence of image  
processing operations.  A processing operation is implemented as an  
instance of an 'operation' class (loaded as plugins which must be  
shared with non-core-data apps), which has a dictionary of input  
parameters and output values (similar to an Image Unit).  In  
general, the core data app does not know what kind of input  
parameters will be supported by the 'operation' objects it has to  
represent, although these are always contained in a mutable  
dictionary. This means that the core data app can't really provide  
getters and setters because the actual parameter names (dictionary  
keys) are not known until run time.


In the core data app, I am creating an entity to represent an  
operation, with the actual operation object as a custom attribute  
(as per the docs).  The user can change the input parameters in the  
object's dictionary of inputs, and this should be reflected in the  
persistent store of corresponding to the custom attribute on disk.   
I realize this is ugly, but I can't think of any other way to do it  
given that the available operation classes are loaded as plugins at  
run time.



In your description, there still doesn't seem to be any reason to  
avoid copying the dictionary and setting a new immutable one.   
Dictionary copies are shallow, so it's just the dictionary itself that  
is a new copy.  So even if the values were gigantic images, this is  
still light weight.


That's your best bet.  As I mentioned previously, you could also use  
KVC and its undefined key support to add custom handling for keys not  
known until run time.


Or as Kyle suggested, you could model this  formally with a Parameter  
entity.


- Ben

___

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

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

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

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


Re: Bluetooth serial examples

2009-05-28 Thread Daniel Pasco
If you have Xcode installed, you can find the sample code in / 
Developer/Examples/Bluetooth.


RFCOMMClientSample and RFCOMMServerSample show how to implement a  
Bluetooth serial service and client and are a great starting point.   
It should show you enough to address both issues.


-Daniel Pasco, CEO
Black Pixel
http://blackpixel.com

On May 28, 2009, at 12:14 AM, Allen Curtis wrote:


Hello,

I can not find any Bluetooth examples on the developer website.  
There was a link but it was broken.


I have two problems that I am trying to solve:
1. The correct way to communicate with a Bluetooth serial port. The  
documentation indicated that there is a new method that provides  
better error handling.


2. Howto make a connection to a "connectable" device vs. a  
"discoverable" device


TIA

- Allen
___

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

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

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

This email sent to dan...@blackpixel.com


___

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

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

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

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


Re: Send Keyboard Events

2009-05-28 Thread Dave DeLong
>From the docs:

"This function is not recommended for general use because of undocumented 
special cases and undesirable side effects. The recommended replacement for 
this function is CGEventCreateKeyboardEvent, which allows you to create a 
keyboard event and customize the event before posting it to the event system."

Once you create the CGEvent, you can then post it using CGEventPost or 
CGEventPostToPSN.

Cheers,

Dave
 
On Thursday, May 28, 2009, at 02:27PM, "Dave Keck"  wrote:
>Check out CGPostKeyboardEvent.
___

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

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

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

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


Hiding process list app icon for GUI apps

2009-05-28 Thread Erg Consultant
Is there a way to hide a GUI app's icon in the process/switch list as can be 
done for faceless background apps?

I've tried several of the Info.plist settings but nothing seems to do this.

Thanks,

Erg



  
___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-28 Thread Martin Wierschin

BOOL isInTrash(NSString* path) {
FSRef fsRef;
Boolean result = false ;
OSStatus err = FSPathMakeRef(
 (UInt8*)[path UTF8String],
 &fsRef,
 NULL) ;
if (err == noErr) {
FolderType folderType ;
FSDetermineIfRefIsEnclosedByFolder (
kOnAppropriateDisk,
kTrashFolderType,
&fsRef,
&result
) ;
}

return (result == true) ;
}


This is a nice trick, I wasn't aware of that function, thanks.  
Perhaps a minor improvement (one call instead of two):


- (BOOL) isTrashedFileAtPath:(NSString*)path
{
Boolean inTrash = false;
const UInt8* utfPath = (UInt8*)[path UTF8String];
	OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk,  
kTrashFolderType, utfPath, false, &inTrash);

return (noErr == err) ? (true == inTrash) : NO;
}

Probably it does the same thing behind the scenes, but why not.

~Martin

___

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

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

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

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


CABasicAnimation leaking?

2009-05-28 Thread Mike Manzano

Hi all,

I have some animation code that looks like this:

	CABasicAnimation *theAnimation = [CABasicAnimation  
animationWithKeyPath:@"position.x"] ;

NSLog( @"ANIMATION: started %x" , theAnimation ) ;
theAnimation.removedOnCompletion = YES ;
theAnimation.duration = 0.125f ;
theAnimation.repeatCount = 1 ;
theAnimation.autoreverses = NO ;
	theAnimation.fromValue = [NSNumber  
numberWithFloat:self.currentlySlidingCell.layer.position.x] ;
	theAnimation.toValue = [NSNumber  
numberWithFloat:self.currentlySlidingCell.layer.position.x -  
self.currentlySlidingCell.frame.origin.x] ;

theAnimation.delegate = self ;
self.superview.userInteractionEnabled = NO ;
	[self.currentlySlidingCell.layer addAnimation:theAnimation  
forKey:@"slideResetAnimation"] ;


When I run the program (in the iPhone simulator) with Instruments  
running, I get several CABasicAnimation leaks of 16 bytes. How could I  
possibly getting this leak if addAnimation:forKey: always replaces the  
previous animation for the key? I would expect any animation that is  
replaced for that key would be released by the layer.


There is a possibility in my code for the animation to be removed  
before it finishes. This method is called from willRemoveSubview of my  
animating layer's superlayer. it may occur while animating:


- (void) cleanupSliding
{
NSLog( @"ANIMATION cleaning up sliding" ) ;
	NSAssert( self.currentlySlidingCell != nil , @"_currentlySlidingCell  
is nil" ) ;


	[self.currentlySlidingCell.layer  
removeAnimationForKey:@"slideResetAnimation"] ;

…

Could this somehow cause the animation to not get released?

Regardless of whether I remove the animation or not, simply replacing  
it by setting a new animation with the same key should suffice to  
release the previous animation, right?


Thanks,

Mike

___

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

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

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

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


-init never gets sent

2009-05-28 Thread Erg Consultant
I have an object which I initialize like this:

gReg = [ [ Registry alloc ] init ];

Problem is, my init method never receives any message.

Does anyone know what can cause this?

Thanks,

Erg



  
___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread David Blanton

what is the result of [ Registry alloc ] ?

On May 28, 2009, at 5:34 PM, Erg Consultant wrote:


I have an object which I initialize like this:

gReg = [ [ Registry alloc ] init ];

Problem is, my init method never receives any message.

Does anyone know what can cause this?

Thanks,

Erg




___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.net




___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread Erg Consultant
Oddly, the object returned is non-nil.

I should mention that the pointer being returned is a hack global declared at 
the top of the file like this:

static Registry *gReg = nil;

but that shouldn't matter. And I've checked that that global is never set to 
nil or created twice anywhere else in the code.

Erg





From: David Blanton 
To: Erg Consultant 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 4:38:42 PM
Subject: Re: -init never gets sent

what is the result of [ Registry alloc ] ?

On May 28, 2009, at 5:34 PM, Erg Consultant wrote:

> I have an object which I initialize like this:
>
> gReg = [ [ Registry alloc ] init ];
>
> Problem is, my init method never receives any message.
>
> Does anyone know what can cause this?
>
> Thanks,
>
> Erg
>
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net
>
> This email sent to aired...@tularosa.net
>
>


  
___

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

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

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

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


Re: performSelectorOnMainThread problem

2009-05-28 Thread Erg Consultant
Either your main thread doesn't implement the selector requested, or else it's 
an issue with the runloop never processing the request. If you have code that 
alters the runloop or modifies its input sources, check that code first.

Erg





From: Ben Einstein 
To: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 9:11:42 AM
Subject: performSelectorOnMainThread problem

Does anyone know of any issue that would cause performSelectorOnMainThread to 
not actually perform the selector but not report any kind of error? I use 
threads very often and have never had a problem like this, but when I call:

[aControllerObject performSelectorOnMainThread:@selector(doSomething:) 
withObject:anObject waitUntilDone:NO];

absolutely NOTHING happens. No log messages, doesn't pause on break points, and 
certainly no exceptions. But if I do this:

[aControllerObject performSelector:@selector(doSomething:) withObject:anObject];

it works every time. I'm completely baffled. Has anyone seen anything like this 
before?

Thanks,
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/erg_consultant%40yahoo.com

This email sent to erg_consult...@yahoo.com



  
___

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

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

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

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


Performance, Efficiency - Coding practice

2009-05-28 Thread John Ku
I have this original class with the following method:
- (void) update {
NSString *title = [[NSString alloc] init];
title = @"TEST";

NSPoint drawAtOrigin;
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;

[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Here, I updated it trying to be efficient:

*.h header file has:*
NSString *title;
NSPoint drawAtOrigin;

*.m file has:*
- (id) init {
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;
}

-(void) update {
[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Is this a more efficient way to code? Which coding practice is better in
terms of efficiency, memory, performance?
The update method will get called often. So Im thinking there is no need to
create 'NSPoint drawAtOrigin' everytime.
Your thoughts?

Thanks,
John
___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread David Blanton

what does the declaration of init look like?
On May 28, 2009, at 5:46 PM, Erg Consultant wrote:


Oddly, the object returned is non-nil.

I should mention that the pointer being returned is a hack global  
declared at the top of the file like this:


static Registry *gReg = nil;

but that shouldn't matter. And I've checked that that global is  
never set to nil or created twice anywhere else in the code.


Erg





From: David Blanton 
To: Erg Consultant 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 4:38:42 PM
Subject: Re: -init never gets sent

what is the result of [ Registry alloc ] ?

On May 28, 2009, at 5:34 PM, Erg Consultant wrote:


I have an object which I initialize like this:

gReg = [ [ Registry alloc ] init ];

Problem is, my init method never receives any message.

Does anyone know what can cause this?

Thanks,

Erg




___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.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/airedale%40tularosa.net

This email sent to aired...@tularosa.net




___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Graham Cox


On 29/05/2009, at 9:57 AM, John Ku wrote:


I have this original class with the following method:
- (void) update {
NSString *title = [[NSString alloc] init];
title = @"TEST";


This is incorrect for a start. You are leaking an empty string. You  
allocate and initialise it, then reassign its pointer to a new string,  
the constant @"TEST". The first one leaks.


This code suggests you aren't really grokking the difference between a  
string object you allocate and a constant string. You just need:


NSString* title = @"TEST";



NSPoint drawAtOrigin;
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;

[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Here, I updated it trying to be efficient:

*.h header file has:*
NSString *title;
NSPoint drawAtOrigin;

*.m file has:*
- (id) init {
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;
}

-(void) update {
[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Is this a more efficient way to code? Which coding practice is  
better in

terms of efficiency, memory, performance?


Who can say? Only a profiler.

However, wringing your hands over this sort of minutiae is pointless.  
In practice, there is not going to be any significant difference. In  
the latter case, you've used a little more memory for your object's  
ivars on the heap versus the same amount of memory temporarily on the  
stack. Typical coding practice is just to go with your first approach,  
most likely using the convenience function NSMakePoint().



The update method will get called often. So Im thinking there is no  
need to

create 'NSPoint drawAtOrigin' everytime.
Your thoughts?


Rasterizing text is a complex and difficult process, which is  
extremely hidden by the high-level drawAtPoint: method. The time it  
takes is aeons in comparison to assigning the NSPoint structure. Don't  
sweat it, it will make no difference whatsoever. Assigning on an as- 
needed basis is a more typical pattern, doesn't clutter your object  
with extraneous ivars and is likely to be a teeny-weeny bit faster  
though probably immeasurably so.


General point here: don't optimise at this stage. Write the simplest,  
clearest, most readable, most correct code you can, get it working,  
then if you appear to run into performance problems later, profile it,  
find out where the bottlenecks really are, work on those.


If you are drawing many text elements a lot, setting up and reusing a  
NSLayoutManager can be fruitful, along with other text-caching  
techniques may yield some improvements in performance. "Optimising"  
the setting of the NSPoint will not.


--Graham







___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Andrew Farmer

On 28 May 2009, at 16:57, John Ku wrote:

Is this a more efficient way to code? Which coding practice is  
better in

terms of efficiency, memory, performance?
The update method will get called often. So Im thinking there is no  
need to

create 'NSPoint drawAtOrigin' everytime.
Your thoughts?


NSPoint is a structure, not an object, so creating it is practically  
free - there is literally no measurable difference in performance  
between the two approaches.


However, you have an unrelated but serious problem in your original  
class:



NSString *title = [[NSString alloc] init];
title = @"TEST";


This leaks a NSString object. Also, it's almost never correct to call  
NSString's init method, as the object created is immutable.

___

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

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

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

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


Re: performSelectorOnMainThread problem

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 4:53 PM, Erg Consultant
 wrote:
> Either your main thread doesn't implement the selector requested, or else 
> it's an issue with the runloop never processing the request. If you have code 
> that alters the runloop or modifies its input sources, check that code first.

Threads don't implement selectors.  And if it were a problem with an
unimplemented message, -doesNotRecognizeSelector: would be called.

--Kyle Sluder
___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Kyle Sluder
On Thu, May 28, 2009 at 4:57 PM, John Ku  wrote:
> NSString *title = [[NSString alloc] init];
> title = @"TEST";

NSString is immutable, and Objective-C doesn't have operator
overloading.  So what you're doing here is creating an empty NSString,
assigning a pointer to it to your title variable, then immediately
assigning a different pointer-to-NSString-constant to the same
variable.  = always does assignment in Objective-C; it never means
"tell this object to change its value to what's on the right side of
the equals sign."

--Kyle Sluder
___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread Mike Manzano

How is your init defined?


Mike Manzano
Sent while mobile

On May 28, 2009, at 4:34 PM, Erg Consultant   
wrote:



I have an object which I initialize like this:

gReg = [ [ Registry alloc ] init ];

Problem is, my init method never receives any message.

Does anyone know what can cause this?

Thanks,

Erg




___

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

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

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

This email sent to m...@instantvoodoomagic.com

___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread John Ku
Thank you all for the explanation. After reading over and experiment, I kind
of get what you all are saying.I've probably confused myself too much with
the dot syntax to use title = @"fdsfd".

So if i have:

NSMutableString *title = [[NSString alloc] init];
[title setString: @"test"];

That would be correct and safe?

Thank!!
John

On Thu, May 28, 2009 at 5:30 PM, Kyle Sluder  wrote:

> On Thu, May 28, 2009 at 4:57 PM, John Ku  wrote:
> > NSString *title = [[NSString alloc] init];
> > title = @"TEST";
>
> NSString is immutable, and Objective-C doesn't have operator
> overloading.  So what you're doing here is creating an empty NSString,
> assigning a pointer to it to your title variable, then immediately
> assigning a different pointer-to-NSString-constant to the same
> variable.  = always does assignment in Objective-C; it never means
> "tell this object to change its value to what's on the right side of
> the equals sign."
>
> --Kyle Sluder
>
___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Shawn Erickson
On Thu, May 28, 2009 at 4:57 PM, John Ku  wrote:
> I have this original class with the following method:
> - (void) update {
> NSString *title = [[NSString alloc] init];

You create an empty string instance in the above and make title point at it.

> title = @"TEST";

You then make title point a the NSString constant "TEST" blowing away
your pointer to the empty string you created above.

If you are using GC then why bother with creating the empty string? If
you aren't using GC then you are leaking the empty string instance
(granted likely only one of those would ever exist given the
implementation but...).

> NSPoint drawAtOrigin;
> drawAtOrigin.x = 0;
> drawAtOrigin.y = 10;

Consider using NSMakePoint.

> [title drawAtPoint: drawAtOrigin withAttributes: nil];
> }
>
>
> Here, I updated it trying to be efficient:
>

...snip...

> Is this a more efficient way to code?

No not likely

> Which coding practice is better in terms of efficiency, memory, performance?

Ignoring the unneeded creation of an empty string in your first
example no difference really exits, well... actually your "efficient"
example uses more memory and has less theoretical performance.

First example (omitting the unneeded empty string creation)...

- (void) update {
NSString* title = @"TEST"; << string constant compiled into
application binary
NSPoint origin = { 0.0, 10.0 }; << point struct compiled into
application binary
[title drawAtPoint:origin withAttributes:nil];
}

Second example...

- (id) init {
title = @"TEST"; << string constant compiled into application binary
origin = { 0.0, 10.0 }; << point struct compiled into application binary
}

- (void) update {
[title drawAtPoint:origin withAttributes:nil];
}

... sure it looks like less it taking place in update however title
and origin are now instance vars of an object allocated on the heap.
That takes up space in the heap (granted infinitesimally small amount
of memory compared to everything else likely in your application) in
addition to the space that are exists in your compiled binary for the
string constant and initial values for origin. Additionally in order
to send the message drawAtPoint the title pointer and origin struct
need to be loaded from the heap instead of being more "immediate" on
the stack.

> The update method will get called often.

Stepping back a little... drawing should normally only be done under
drawRect: for NSView subclasses and by under I mean in the
implementation of drawRect: or in a method it calls. Anyway make sure
you understand the Cocoa view/drawing system before going to far with
this.

> Your thoughts?

Write good clean code with well designed algorithms (yet simple as
possible) and then profile it under real-world situations before
attempting performance optimizations.

-Shawn
___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Graham Cox


On 29/05/2009, at 10:42 AM, John Ku wrote:


NSMutableString *title = [[NSString alloc] init];
[title setString: @"test"];

That would be correct and safe?



Yes, but pointless.

If the string is a constant, use a constant.

NSString* string = @"whatever";



--Graham


___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Shawn Erickson
On Thu, May 28, 2009 at 5:42 PM, John Ku  wrote:
> Thank you all for the explanation. After reading over and experiment, I kind
> of get what you all are saying.I've probably confused myself too much with
> the dot syntax to use title = @"fdsfd".
>
> So if i have:
>
> NSMutableString *title = [[NSString alloc] init];
> [title setString: @"test"];
>
> That would be correct and safe?

Assuming you meant [[NSMutableString alloc] init] and someplace later
release it... then yes but why?

Do you want a mutable string or just @"test"?

If you are always going to draw the string "test" you can simply do
the following...

[@"test" drawAtPoint:origin withAttributes:nil];

-Shawn
___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread John Ku
Yeah sorry everyone, in the original example i am using a constant.My
working app is actually using a mutable string. So I've got both mixed up.

And yeah, NSMutableString will be initialized else where and released later.

*hits myself in the head* Im not processing correctly today..

Thanks,
John

On Thu, May 28, 2009 at 5:50 PM, Shawn Erickson  wrote:

> On Thu, May 28, 2009 at 5:42 PM, John Ku  wrote:
> > Thank you all for the explanation. After reading over and experiment, I
> kind
> > of get what you all are saying.I've probably confused myself too much
> with
> > the dot syntax to use title = @"fdsfd".
> >
> > So if i have:
> >
> > NSMutableString *title = [[NSString alloc] init];
> > [title setString: @"test"];
> >
> > That would be correct and safe?
>
> Assuming you meant [[NSMutableString alloc] init] and someplace later
> release it... then yes but why?
>
> Do you want a mutable string or just @"test"?
>
> If you are always going to draw the string "test" you can simply do
> the following...
>
> [@"test" drawAtPoint:origin withAttributes:nil];
>
> -Shawn
>
___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Andrew Farmer

On 28 May 2009, at 17:48, Graham Cox wrote:

On 29/05/2009, at 10:42 AM, John Ku wrote:

NSMutableString *title = [[NSString alloc] init];
[title setString: @"test"];

That would be correct and safe?


Yes, but pointless.


Nope, that'd be assigning a NSString instance to a NSMutableString  
variable (throwing a compile-time warning) and expecting it to receive  
a setString: method, which it won't know what to do with.


The first line should be:


NSMutableString *title = [[NSMutableString alloc] init];



This, however, is much better advice:


If the string is a constant, use a constant.

NSString* string = @"whatever";

___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Roland King


So if i have:

NSMutableString *title = [[NSString alloc] init];
[title setString: @"test"];

That would be correct and safe?

Thank!!
John




No. I hope it would emit warnings on compilation too. That would set 
title to an NSString instance, then you go calling setString: on it and 
that's an NSMutableString member function, so it would crash with an 
unimplemented selector.


If you want title to be an NSMutableString* then you need to alloc and 
init an NSMutableString for 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 arch...@mail-archive.com


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Graham Cox


On 29/05/2009, at 10:56 AM, Andrew Farmer wrote:

Nope, that'd be assigning a NSString instance to a NSMutableString  
variable



oops, missed that ;-)

--Graham
___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread Greg Guerin

Erg Consultant wrote:


Oddly, the object returned is non-nil.

I should mention that the pointer being returned is a hack global  
declared at the top of the file like this:


static Registry *gReg = nil;

but that shouldn't matter.


Post your code for alloc and -init.

Your question can only be answered by seeing the actual code.   
Without actual code, everyone is just guessing.



And I've checked that that global is never set to nil or created  
twice anywhere else in the code.


If your intention is to always return a singleton Registry, you need  
to follow the pattern for "Creating a Singleton Instance" in the  
Cocoa-Fundamentals docs.


http://developer.apple.com/documentation/Cocoa/Conceptual/ 
CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/ 
TP40002974-CH4-SW32


If it is not your intention to always return a singleton Registry,  
then returning "a hack global" is probably doing it wrong.


  -- GG

___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread John Ku
Better than making mistake one after another.

But good lesson for me.

Cheers,
John

On Thu, May 28, 2009 at 6:01 PM, Graham Cox  wrote:

>
> On 29/05/2009, at 10:56 AM, Andrew Farmer wrote:
>
>  Nope, that'd be assigning a NSString instance to a NSMutableString
>> variable
>>
>
>
> oops, missed that ;-)
>
> --Graham
>
___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread Erg Consultant
The object's -init looks like this:

- (id)init
{
   if( !gReg )
{
if( ( self = [ super init ] ) )
{
// Zero out members...

keys = nil;

lastFlushTime = nil;
}
}

return self;
}


Oddly, I just ran the exact same source file in another app and it all works 
fine. Must be a stack blow or something.




From: David Blanton 
To: Erg Consultant 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 5:21:55 PM
Subject: Re: -init never gets sent

what does the declaration of init look like?
On May 28, 2009, at 5:46 PM, Erg Consultant wrote:

> Oddly, the object returned is non-nil.
>
> I should mention that the pointer being returned is a hack global  
> declared at the top of the file like this:
>
> static Registry *gReg = nil;
>
> but that shouldn't matter. And I've checked that that global is  
> never set to nil or created twice anywhere else in the code.
>
> Erg
>
>
>
>
> 
> From: David Blanton 
> To: Erg Consultant 
> Cc: cocoa-dev@lists.apple.com
> Sent: Thursday, May 28, 2009 4:38:42 PM
> Subject: Re: -init never gets sent
>
> what is the result of [ Registry alloc ] ?
>
> On May 28, 2009, at 5:34 PM, Erg Consultant wrote:
>
>> I have an object which I initialize like this:
>>
>> gReg = [ [ Registry alloc ] init ];
>>
>> Problem is, my init method never receives any message.
>>
>> Does anyone know what can cause this?
>>
>> Thanks,
>>
>> Erg
>>
>>
>>
>>
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net
>>
>> This email sent to aired...@tularosa.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/airedale%40tularosa.net
>
> This email sent to aired...@tularosa.net
>
>


  
___

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

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

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

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


Re: Hiding process list app icon for GUI apps

2009-05-28 Thread Peter Ammon


On May 28, 2009, at 1:57 PM, Erg Consultant wrote:

Is there a way to hide a GUI app's icon in the process/switch list  
as can be done for faceless background apps?


I've tried several of the Info.plist settings but nothing seems to  
do this.


Thanks,

Erg


Hi Erg,

The LSUIElement key prevents the app from appearing in the Dock or  
Force Quit dialog, but still allows these apps to show windows.  Is  
that what you want?

___

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

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

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

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


Re: -init never gets sent

2009-05-28 Thread Graham Cox


On 29/05/2009, at 11:19 AM, Erg Consultant wrote:


- (id)init
{
  if( !gReg )
   {
   if( ( self = [ super init ] ) )
   {
   // Zero out members...

   keys = nil;

   lastFlushTime = nil;
   }
   }

   return self;
}



This is a little broken.

-init must always be allowed to run, so testing for the existence of  
gReg is wrong. I know you're trying to create a kind of singleton, but  
this isn't the way to do it.


Also, initialising members to zero isn't necessary, as alloc does that.

So, removing the unnecessary and incorrect things here, you end up with:

return [super init];

Hmmm... looks like you can dispose of init altogether. I assume your  
object inherits from NSObject?



A good way to make a singleton that avoids a global is to use a class  
method like so:


+ (MyObject*)   singleton
{
static MyObject* sSingle = nil;

if( sSingle == nil )
sSingle = [[self alloc] init];

return sSingle;
}
___

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

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

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

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


Re: Hiding process list app icon for GUI apps

2009-05-28 Thread Erg Consultant
That is exactly what I want - my app is a standard Cocoa app with a few windows 
and a menu bar but it's used to launch other apps - so I don't want it showing 
up in the Command-Tab switch list, the Dock, or the Force Quit window. Mainly, 
I need my windows and menubar to still be visible.

Thanks,

Erg





From: Peter Ammon 
To: Erg Consultant 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 6:22:20 PM
Subject: Re: Hiding process list app icon for GUI apps


On May 28, 2009, at 1:57 PM, Erg Consultant wrote:

> Is there a way to hide a GUI app's icon in the process/switch list as can be 
> done for faceless background apps?
> 
> I've tried several of the Info.plist settings but nothing seems to do this.
> 
> Thanks,
> 
> Erg

Hi Erg,

The LSUIElement key prevents the app from appearing in the Dock or Force Quit 
dialog, but still allows these apps to show windows.  Is that what you want?



  
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Dave Fernandes


On May 28, 2009, at 2:16 PM, Quincey Morris wrote:

Well, yeah. The problem is that you're using something with the  
behavior of an entity (your custom object) as an attribute. That is,  
you want your object graph to include your custom objects (for the  
purpose of monitoring their changes), but you haven't implemented  
your data model that way. Typically, Core Data *attributes* are  
immutable (like NSNumber or NSString) for exactly that reason. The  
mutability of your custom object suggests that it should be an  
entity, not an attribute. [Sorry, not sure if that's clear. I'm  
trying to say the same thing 3 different ways.]


Is there a reason you can't make your custom object a Core Data  
entity, and expose its properties (the troublesome instance  
variables) as attributes of that entity?


It's not impossible that the willChange/didChange approach can be  
made to work, but this sort of thing tends to really crap out in the  
face of undo. Consider what happens when you change an instance  
variable of a custom object, if the object is already in the undo  
history from a previous change. Suddenly, undoing changes ... won't.


Good point!
___

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

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

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

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


Re: Regarding SavePanel in NSDocument

2009-05-28 Thread Andy Lee

On May 28, 2009, at 11:08 AM, Graham Cox wrote:

On 29/05/2009, at 12:47 AM, Sourabh Sahu wrote:

I created NSDocument which has inbuilt SavePanel, what I want is  
the reference of SavePanel in my class.


What's an inbuilt save panel? Because there isn't one in a normal  
NSDocument



I tried NSSavePanel *panel = [NSDocument savePanel]


Is savePanel an instance method or class method?



But the code crashes.


In what way? Show the stack trace. Show your code. Show something.


Yes.  Don't expect people to guess what you're doing.  SHOW US what  
you're doing and tell us what happened.


--Andy

___

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

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

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

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


Re: Regarding SavePanel in NSDocument

2009-05-28 Thread Graham Cox


On 29/05/2009, at 1:10 PM, Andy Lee wrote:


In what way? Show the stack trace. Show your code. Show something.


Yes.  Don't expect people to guess what you're doing.  SHOW US what  
you're doing and tell us what happened.


And to that list I could have added show some initiative!

--Graham


___

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

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

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

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


Re: Send Keyboard Events

2009-05-28 Thread Mr. Gecko

Seems to be what I needed.

Thanks,
Mr. Gecko

On May 28, 2009, at 3:27 PM, Dave Keck wrote:


Check out CGPostKeyboardEvent.


___

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

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

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

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


Re: NSNotificationCenter CPU usage problem

2009-05-28 Thread Ken Thomases

On May 28, 2009, at 9:51 AM, Mike Crowe wrote:

I'm running into a CPU usage problem with my Cocoa application.  
Basically
once the app has been running for a few hours it starts, all of a  
sudden, to

steadily consume an increasing amount of CPU.

On further investigation with Instruments, it seems that object  
allocations

seem to be the cause:

#Object AddressCategoryCreation TimeSize 
Responsible

LibraryResponsible Caller
263190x9b23e5002:34.281Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263200x9b23e6002:34.285Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263210x9b23e7002:34.290Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263220x9b23e8002:34.295Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263230x9b23e9002:34.299Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263240x9b23ea002:34.302Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263250x9b23eb002:34.306Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]
263260x9b23ec002:34.309Foundation- 
[NSNotificationCenter

addObserver:selector:name:object:]

The screenshot below from Instruments shows the graph steadily  
increasing as

more and more observers are added:
http://jottle.net/Instruments.png


You can show the extended detail view and see the full stack trace for  
those allocations, which should give you a better idea of why it is  
happening.


Regards,
Ken

___

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

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

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

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


Re: Performance, Efficiency - Coding practice

2009-05-28 Thread Michael Ash
On Thu, May 28, 2009 at 8:57 PM, Roland King  wrote:
>>
>> So if i have:
>>
>> NSMutableString *title = [[NSString alloc] init];
>> [title setString: @"test"];
>>
>> That would be correct and safe?
>
> No. I hope it would emit warnings on compilation too.

No warning will be emitted. -init is declared to return id.

Mike
___

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

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

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

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


Re: Recommendations to Reading the Xcode in built Documentation to the fullest effect

2009-05-28 Thread Kevin LaCoste
The fact that AppKiDo isn't built in is one of the reasons I like it. When
you update your docs in Xcode's built-in browser a relaunch of AppKiDo will
cause it to pick up the changes.

Agreed on the loading delay. That's annoying. And it's pretty weak on the
polish side. It does display inherited methods but they're all mixed
together under ALL Instance Methods. Splitting this further into Inherited
from NSObject, Inherited from NSResponder, etc, would be a very nice feature
addition.

Kevin
___

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

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

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

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


Re: Hiding process list app icon for GUI apps

2009-05-28 Thread Eric Schlegel


On May 28, 2009, at 6:31 PM, Erg Consultant wrote:

That is exactly what I want - my app is a standard Cocoa app with a  
few windows and a menu bar but it's used to launch other apps - so I  
don't want it showing up in the Command-Tab switch list, the Dock,  
or the Force Quit window. Mainly, I need my windows and menubar to  
still be visible.


Unfortunately that means that LSUIElement is _not_ what you want,  
because a UIElement app can't have a menubar.


In short, if you have a menubar, you will have a Dock tile. If you  
don't want a Dock tile, you can't have a menubar. The two are bound  
together.


-eric

___

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

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

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

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


Re: Hiding process list app icon for GUI apps

2009-05-28 Thread Erg Consultant
Oddly it worked. I set LSUIElement in the Info.plist and the app UI works 
without the Dock or task list icon.

However, doing that caused another weird problem - now my app launches multiple 
instances of itself every time I double-click it. Remove the LSUIElement key 
and that behavior goes away.

I think the runtime stuff on OS X was never really ready for prime-time.

Erg



From: Eric Schlegel 
To: Erg Consultant 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, May 28, 2009 10:10:36 PM
Subject: Re: Hiding process list app icon for GUI apps


On May 28, 2009, at 6:31 PM, Erg Consultant wrote:

> That is exactly what I want - my app is a standard Cocoa app with a few 
> windows and a menu bar but it's used to launch other apps - so I don't want 
> it showing up in the Command-Tab switch list, the Dock, or the Force Quit 
> window. Mainly, I need my windows and menubar to still be visible.

Unfortunately that means that LSUIElement is _not_ what you want, because a 
UIElement app can't have a menubar.

In short, if you have a menubar, you will have a Dock tile. If you don't want a 
Dock tile, you can't have a menubar. The two are bound together.

-eric


  
___

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

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

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

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


Re: Core data, bindings and multiple view NIB

2009-05-28 Thread Tomaž Kragelj
Ok, I see. The main thing is that now it works and I can setup the  
bindings in IB instead of programatically which is another bonus...


Thanks for all the information,
Tom

On 28.5.2009, at 16:23, Keary Suska wrote:


On May 27, 2009, at 10:07 PM, Tomaž Kragelj wrote:

Thanks Keary, this works, however it requires that the same binding  
is repeated in each nib where the same list should be handled (some  
views may only need to show it while others can also modify it). I  
was thinking of creating a "master" set of controllers in the main  
nib, then bind the "slave" controllers in particular view nib file  
to the values from the corresponding master controller. Is that  
possible, or is it not how bindings should be used?


It is possible, and is within the domain of issues that bindings  
help solve, but I don't see how it would change having multiple  
repeated bindings. In fact, it adds a useless layer onto the problem.


___

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

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

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

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


Re: Hiding process list app icon for GUI apps

2009-05-28 Thread Graham Cox


On 29/05/2009, at 3:28 PM, Erg Consultant wrote:

I think the runtime stuff on OS X was never really ready for prime- 
time.



LOL. That's hilarious! :)

--Graham

___

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

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

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

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


Re: Booleans

2009-05-28 Thread Joel Norvell

John,

I believe the problem is that you're treating the boolean as a pointer.
HTH,

Joel




  
___

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

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

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

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


Laying out superscripted text

2009-05-28 Thread Graham Cox
I have code that lays out text on a path. It essentially boils down to  
the technique given in the Text Layout Programming Guide example code  
(Circle text) of setting up a transform before letting the layout  
manager get on with its normal work, done by calling -[NSLayoutManager  
drawGlyphsForGlyphRange:atPoint:]; where the point is calculated from  
the -locationOfGlyphAtIndex: method (each glyph has to be drawn  
individually for obvious reasons, so the glyph range is always length 1)


This works great for almost everything you can do with an attributed  
string, but doesn't handle superscripts properly. Any super- or  
subscripted glyph always ends up on the baseline.


I have tried two things so far:

a) ask the typesetter, using -[NSTypesetter  
baselineOffsetInLayoutManager:glyphIndex:];


That produces nothing different for the superscripted characters.

b) going back to the original string's superscript attribute. That  
could work, since I have complete control over the baseline for each  
character. However, the superscript attribute is an integer which I  
understand to mean n units of "superscriptness" in proportion to h,  
where h is ??? lineheight? font height? I can't find any information  
on how this value can be turned into a baseline position.


So that would be good to know if anyone can help. That still leaves me  
mystified as to why the layout manager doesn't "just work" though.


--Graham


___

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

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

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

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


Bluetooth serial examples

2009-05-28 Thread Allen Curtis

Hello,

I can not find any Bluetooth examples on the developer website. There  
was a link but it was broken.


I have two problems that I am trying to solve:
1. The correct way to communicate with a Bluetooth serial port. The  
documentation indicated that there is a new method that provides  
better error handling.


2. Howto make a connection to a "connectable" device vs. a  
"discoverable" device


TIA

- Allen
___

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

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

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

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


Clarification on the purpose of NSUserDefaults (newbie)

2009-05-28 Thread Diego Rey Mendez
Hello everyone,

I'm new to development on the iPhone.  I have been reading for a while now
the official docs, and some tutorials and posts online explaining the use
of NSUserDefaults.
My questions:

1) It sounds to me as if this is the preferred class for storing the user
preferences for my application, right?

2) What's the preferred class/method for storing larger chunks of data?  Is
it NSFileManager?

Thanks in advance,
Diego
___

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

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

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

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


Opening a NSPanel in the current virtual desktop instead of the one the app is in

2009-05-28 Thread Stefan Balu
Hey all,

I am trying to open a NSPanel in the current virtual desktop, however,
it moves me to the virtual desktop where the main NSWindow resides.
How can I force a NSPanel to open in the current virtual desktop?

-- 
Ștefan BĂLU
Tel: +40726 252 799
___

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

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

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

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


Re: Opening a NSPanel in the current virtual desktop instead of the one the app is in

2009-05-28 Thread Stefan Balu
Fixed.

[NSApp activateIgnoringOtherApps:YES];
[panel 
setCollectionBehavior:NSWindowCollectionBehaviorDefault|NSWindowCollectionBehaviorMoveToActiveSpace];
[panel makeKeyAndOrderFront:self];


On Wed, May 27, 2009 at 3:16 PM, Stefan Balu  wrote:
> Hey all,
>
> I am trying to open a NSPanel in the current virtual desktop, however,
> it moves me to the virtual desktop where the main NSWindow resides.
> How can I force a NSPanel to open in the current virtual desktop?
>
> --
> Ștefan BĂLU
> Tel: +40726 252 799
>



-- 
Ștefan BĂLU
Tel: +40726 252 799
___

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

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

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

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


Re: Opening a NSPanel in the current virtual desktop instead of the one the app is in

2009-05-28 Thread Stefan Balu
Actually it didn't fix everything. If I close (and not release) the
pannel, go to a different space, when the panel is to be displayed it
will move me to where it previously was.

So, the code below only unties the panel from the main window,
however, if my panel is to be closed, when i call makeKeyAndOrderFront
on it, it will move me to where it previously was befor i closed it.

I don't want to release it on close, just hide, but it must show on
the current space (that is, a different one than where i hide the
pannel)

On Wed, May 27, 2009 at 4:11 PM, Stefan Balu  wrote:
> Fixed.
>
>        [NSApp activateIgnoringOtherApps:YES];
>        [panel 
> setCollectionBehavior:NSWindowCollectionBehaviorDefault|NSWindowCollectionBehaviorMoveToActiveSpace];
>        [panel makeKeyAndOrderFront:self];
>
>
> On Wed, May 27, 2009 at 3:16 PM, Stefan Balu  wrote:
>> Hey all,
>>
>> I am trying to open a NSPanel in the current virtual desktop, however,
>> it moves me to the virtual desktop where the main NSWindow resides.
>> How can I force a NSPanel to open in the current virtual desktop?
>>
>> --
>> Ștefan BĂLU
>> Tel: +40726 252 799
>>
>
>
>
> --
> Ștefan BĂLU
> Tel: +40726 252 799
>



-- 
Ștefan BĂLU
Tel: +40726 252 799
___

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

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

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

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


New Reporting Tool Now in Beta

2009-05-28 Thread Etchasoft Incorporated
NOTE:  Prior notice of this submission was provided to the list
administrator.   To comply with the administrator’s request, please do not
respond to this post via the email list.  We have instead established a
special email for this beta test as follows:
e...@etchasoft.com


May 27, 2009 Announcement

Etchasoft Incorporated is pleased to announce the availability of the beta
test version of its new reporting tool built exclusively for the Mac
Development platform.   We invite interested developers to participate.

The product is Etchasoft Reports and it allows Mac developers to design
reports directly within Interface Builder.

If you are interested in participating in our beta test, please visit us at
http://www.etchasoft.com/etchasoftreports.html

The beta download includes a quick start guide and 3 sample projects to get
you started.

Even if you choose not to participate, you may visit this same site and
watch a short video demonstration of the product (less than 8 minutes).

Thank you for your consideration.

The Etchasoft Development Team
___

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

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

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

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


SQLite/MySQL BLOB-creator application needed.

2009-05-28 Thread Frederick C . Lee

Greetings:
  I'm working within the Cocoa/iPhone environment using SQLite as my  
persistent storage means (albeit, MySQL would be adequate as well).
I want to create a digital library that stores images as BLOBs to be  
incorporated into an SQLite table.


So I need a simple OS X application (either an existing desktop  
application, or a simple command-line application) that can serialize  
a PNG image
into a BLOB (keeping all metadata, etc.) for access by a SQLite (or  
any SQL-type DB) engine (used within a Cocoa/iPhone application).


Regards,

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 arch...@mail-archive.com


How to make our application as default for particular type of file.

2009-05-28 Thread Nikhil Khandelwal
Hi,

I want to make my application as default for file of particular extension 
programmatically.
Please reply as soon as possible.

Thanks,
Nikhil

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

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

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

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


Re: Booleans

2009-05-28 Thread Gregory Weston

John Ku wrote:

I am trying to set an object's boolean, everything works but I get a  
warning

of 'pointer from integer without a cast'.
*//  Here is the Main Class:*
[theObject setActivated: YES];

*//  Here is the Object Class:*
@property(readwrite, assign) BOOL *activated;
@synthesize activated;

- (void) setActivated: (BOOL *) boolean {
 activated = boolean;
}


The weird thing is that if i setActivated: NO, it would not give any  
warning

or error. Only When I setActivated: YES i get this:
"warning: passing argument 1 of 'setActivated:' makes pointer from  
integer

without a cast"

Anyone know what's wrong?


Yes. You're trying to make a pointer from an integer without a cast.  
Specifically, the pointer is the BOOL* argument to setActivated and  
the integer is 1, or -1 or whatever YES is defined is. NO is defined  
to be zero, which by the language definition can be assigned to a  
pointer without a problem. It's just another name for NULL.


Most likely you don't want 'activated' and the argument to  
setActivated: to be pointers.


___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-28 Thread McLaughlin, Michael P.
On 5/27/09 5:02 PM, "Keith Duncan"  wrote:

>> Could someone clue me in as to the preferred method to do a
>> subtraversal?
> 
> Have you looked at XPath, it will save you from having to enumerate
> and perform element-name string comparisons.
> 
> Keith
> 
Yes.  I looked at that but

1. My tree is quite small (about 3 pages) and Xpath seemed like overkill.
2. Different objects will seek out information in different parts of the
tree.  That is, each will do a subtraversal once "their" root node is
located.

I was surprised that there appeared to be no method equivalent to

traverse(subRoot)

since just about every book on data structures discusses it.

Perhaps there is and I just missed it.

-- 
Mike McLaughlin

___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-28 Thread Graham Cox


On 28/05/2009, at 10:10 PM, McLaughlin, Michael P. wrote:


Yes.  I looked at that but

1. My tree is quite small (about 3 pages) and Xpath seemed like  
overkill.
2. Different objects will seek out information in different parts of  
the

tree.  That is, each will do a subtraversal once "their" root node is
located.

I was surprised that there appeared to be no method equivalent to

traverse(subRoot)

since just about every book on data structures discusses it.

Perhaps there is and I just missed it.



OK, I have absolutely no experience of this class, but I took a 2  
second swipe at the docs.


Will -[[NSXMLDocument children] objectEnumerator] not do that?

--Graham
___

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

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

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

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


Re: Laying out superscripted text

2009-05-28 Thread Graham Cox


On 28/05/2009, at 5:19 PM, Graham Cox wrote:

I have code that lays out text on a path. It essentially boils down  
to the technique given in the Text Layout Programming Guide example  
code (Circle text) of setting up a transform before letting the  
layout manager get on with its normal work, done by calling - 
[NSLayoutManager drawGlyphsForGlyphRange:atPoint:]; where the point  
is calculated from the -locationOfGlyphAtIndex: method (each glyph  
has to be drawn individually for obvious reasons, so the glyph range  
is always length 1)

[snip]


So that would be good to know if anyone can help. That still leaves  
me mystified as to why the layout manager doesn't "just work" though.



OK, I made some progress on this. Turns out it does "just work", but  
in my calculations I was inadvertently cancelling out the baseline  
offset for each glyph. However, I'm not quite out of the woods yet, as  
there is one final remaining problem I can't seem to find a simple  
solution to.


I want to lay out my text so that its baseline lies on the path (I can  
also offset it either side, but an offset of 0 means sitting on the  
path). NSLayoutManager positions glyphs based on the origin of the  
line fragment rectangle, which, because the context is flipped, is its  
top left corner. Finding the baseline of any single glyph is trivial (- 
locationOfGlyphAtIndex:) but I can't seem to find an easy way to  
obtain the overall baseline of the entire line of text within the line  
fragment rectangle. How do I do this?


I tried just using the glyph location of the first glyph on the line,  
but it's not right if the first glyph is itself superscripted.


(Note: It sounds easy but doesn't seem to be - a line of text with a  
variety of mixed attributes can have a whole variety of baselines, but  
the layout manager seems to know how to work out where a single  
consistent baseline should be - but it doesn't seem to be telling).


--Graham
___

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

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

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

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


Re: Cocoa-dev Digest, Vol 6, Issue 794

2009-05-28 Thread McLaughlin, Michael P.
On 5/27/09 6:42 PM, "Greg Guerin  wrote:

>> In reviewing the NSXML documents, I found no really simple way to
>> traverse a
>> subtree of an NSXMLDocument.  That is, traverse from the root until
>> you hit
>> the node with the right name then pretend that that node is the
>> root of a
>> smaller tree and traverse just the latter.  [Everything I found
>> talked only
>> about sibs and (immediate) children, not grandchildren, etc.]
>> 
>> Since this is such a common thing to do, I'm guessing that I must have
>> misread the docs somehow.
>> 
>> Could someone clue me in as to the preferred method to do a
>> subtraversal?
> 
> Recursion:
>   http://en.wikipedia.org/wiki/Recursion
> 
> Given any NSXMLNode, if it has children, you can traverse the
> children.  Since each child is itself an NSXMLNode, the "Given any
> NSXMLNode..." sentence at the begining of this paragraph applies.
> The previous two sentences are recursive.
> 
> Start recursion at the root node of the NSXMLDocument.

I'm familiar with recursion; that is what prompted my query.  However, the
tree-traversal documentation at

http://devworld.apple.com/documentation/Cocoa/Conceptual/NSXML_Concepts/Arti
cles/TraversingTree.html#//apple_ref/doc/uid/TP40001257

seems to indicate that the built-in traversal method, nextNode, is
non-recursive (in the usual sense).  This method will return non-nil until
the whole tree is finished.  I was looking for some indicator that I had
finished just a subtree.  [Perhaps level will work.]

-- 
Mike McLaughlin

___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-28 Thread Sean McBride
Jerry Krinock (je...@ieee.org) on 2009-05-27 1:04 AM said:

>At first I thought these FS functions were in Carbon, but the docs say
>that they are in CoreServices, so I guess this is OK for the 64-bit
>future.

It's another example of 'Carbon' being a term with many meanings.  These
APIs have their roots in Classic Mac OS, but they aren't actually in the
Carbon framework proper anymore.

Also, 64 bit is the present, not the future. :)  You can check in
Files.h to see if those API are available in 64 bit (they are).

Sean


___

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

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

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

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


Re: Cocoa-dev Digest, Vol 6, Issue 794

2009-05-28 Thread Graham Cox


On 28/05/2009, at 10:45 PM, McLaughlin, Michael P. wrote:

I'm familiar with recursion; that is what prompted my query.   
However, the

tree-traversal documentation at

http://devworld.apple.com/documentation/Cocoa/Conceptual/NSXML_Concepts/Arti
cles/TraversingTree.html#//apple_ref/doc/uid/TP40001257

seems to indicate that the built-in traversal method, nextNode, is
non-recursive (in the usual sense).  This method will return non-nil  
until
the whole tree is finished.  I was looking for some indicator that I  
had

finished just a subtree.  [Perhaps level will work.]



(Just forwarding this to the list, in case anyone else could make use  
of it, or wants to comment...)


Each child is another node, which in turn has its own children... So  
effectively -children does represent the entire subtree.


You can traverse the whole thing like so:

@implementation NSXMLNode (Traversal)

- (void)traverse
{
   NSObjectEnumerator* iter = [[self children] objectEnumerator];
   NSXMLNode*   node;

   while(( node = [iter nextObject]))
   {
   // do something useful with the node here

   // then recurse

[node traverse];
   }
}


@end

Or have I misunderstood what you want?

--Graham

___

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

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

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

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


Send Keyboard Events

2009-05-28 Thread Mr. Gecko
Hello, I'm trying to find out how to like make a button that will push  
the key h or whatever so I can make an virtual keyboard.


Any tips/help?

Thanks,
Mr. Gecko
___

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

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

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

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


Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Rick Hoge


I have a core data (doc-based) app in which one of the entities  
includes a custom object as a persistent attribute.  The custom object  
class implements NSCoding, and these objects are saved to the core  
data store with no problem (they are read back correctly etc).   
Instance variables of the custom object are exposed in the user  
interface, and can be edited by the user.


The problem I have is that changes to instance variables of these  
custom objects are not reported to the managed object context, so the  
core data document is not flagged as dirty and, even if I force a save  
by adding an entity and invoking save, the modified custom object is  
not saved (if I quit and reload the old ivar values are loaded).


None of this is terribly surprising, since I'm going outside the core  
data world with these custom objects.  However I expect there must be  
a way to tell the managed object context it's dirty when a custom  
object attribute has been modified.  I've been reviewing the  
documentation, but it's not obvious what the preferred/cleanest way  
would be...


I would be most grateful for any suggestions on how to approach this.

Regards,

Rick

___

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

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

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

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


sending continues NSImage data to iPhone

2009-05-28 Thread sheen mac
Hi All,
I am doing a screen sharing app for iPhone and Mac.I captured the Mac Screen as 
NSImage using OpenGL and send it to iPod as Gif data. But sending and restoring 
to UIImage process make delay because of Image size.The image size of capture 
is 320 x 388.
Is any better way available for compressing the Image data?.
Thanks In Advance,Sheen



___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-28 Thread Graham Cox


On 28/05/2009, at 11:56 PM, McLaughlin, Michael P. wrote:


Hello,

I think you’re correct in what you show below.  I was expecting  
that, since an XML document is already a tree, it would already have  
an equivalent to what you describe.  I’ve reinvented the wheel too  
many times and now try to avoid it when possible.


An earlier responder suggested using Xpath and, right now, I’m  
looking to see if that might be easier.  At first, it seemed like  
overkill but perhaps not in my case.



Hi,

Seriously? This is about as easy as I've seen tree traversal get, not  
sure how it could be any easier. Though see below, it's even easier ;-)


Your original post states:

In reviewing the NSXML documents, I found no really simple way to  
traverse a
subtree of an NSXMLDocument.  That is, traverse from the root until  
you hit
the node with the right name then pretend that that node is the root  
of a
smaller tree and traverse just the latter.  [Everything I found  
talked only

about sibs and (immediate) children, not grandchildren, etc.]

Since this is such a common thing to do, I'm guessing that I must have
misread the docs somehow.

Could someone clue me in as to the preferred method to do a  
subtraversal?


Obviously my -traversal method doesn't do anything, but it can  
trivially solve the first part - find the node with a given name. It  
just traverses until it gets a match. At that point your requirements  
are a bit vague. You say "traverse that node as if it were the root of  
a smaller tree". Well, it is. So just do what you have to do.


If the NSXMLMode class doesn't have the exact method you need, just  
add what you need to it in a category, as I showed with -traverse. But  
really, since the children of a node is an array object, its easy to  
iterate. I'm not sure what more you would expect? If you want to pass  
each child node an object (visitor pattern, say) then [NSArray  
makeObjectPerformSelector:withObject:] reduces it to one line. If the  
method in question is one of your category methods you can place this  
inside it and boom - one line of code will visit all subnodes and send  
them a specific additional object. You can do anything you want. In  
one line.


@implementation NSXMLNode (Visitor)

- (void)visitSubnodesWithObject:(id) visitor
{
   // do something useful with the visitor if necessary
   [visitor doSomethingWithNode:self];

   // visit all subnodes
   [[self children] makeObjectPerformSelector:_cmd  
withObject:visitor]; // _cmd is equivalent to @selector()

}

@end

Invoke as -[NSXMLDocument visitSubnodesWithObject:foo]; // will visit  
all subnodes and hand each one to . The visitor can then do what  
it needs to do, including ignoring the node altogether if it's not of  
interest.




--Graham


___

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

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

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

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


Re: Core data, bindings and multiple view NIB

2009-05-28 Thread Keary Suska

On May 27, 2009, at 10:07 PM, Tomaž Kragelj wrote:

Thanks Keary, this works, however it requires that the same binding  
is repeated in each nib where the same list should be handled (some  
views may only need to show it while others can also modify it). I  
was thinking of creating a "master" set of controllers in the main  
nib, then bind the "slave" controllers in particular view nib file  
to the values from the corresponding master controller. Is that  
possible, or is it not how bindings should be used?


It is possible, and is within the domain of issues that bindings help  
solve, but I don't see how it would change having multiple repeated  
bindings. In fact, it adds a useless layer onto the problem.



On 27.5.2009, at 22:43, Keary Suska wrote:


On May 27, 2009, at 12:30 AM, Tomaž Kragelj wrote:


GroupItemsController:
- managed object context ->  
Application.delegate.managedObjectContext

- ???
The question marks are what I'm missing - if I don't bind to  
anything, then the array controller will simply show all items for  
all groups, however I want to bind this to the  
GroupItemsController from the MainMenu.nib (it is accessible  
through the Application.delegate, but I don't know how to bind it  
in order to show only the items selected by the group in  
GroupsView.nib...


Have you tried Application.delegate.GroupController.selection.items  
(the last key os whatever relationship you need to use)?





Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-28 Thread Graham Cox


On 29/05/2009, at 12:21 AM, Graham Cox wrote:


makeObjectPerformSelector


makeObjectsPerformSelector:
  ^

--G.
___

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

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

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

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


Find default application for file of particular extension

2009-05-28 Thread Nikhil Khandelwal
Hi all,

I want to find out which application is the default one for .x extension file 
in my application and to make my application the default one for that extension.
Its an urgent project requirement, so please reply as soon as possible.

Thanks,
NIKHIL

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

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

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

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


Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Keary Suska

On May 28, 2009, at 7:03 AM, Rick Hoge wrote:



I have a core data (doc-based) app in which one of the entities  
includes a custom object as a persistent attribute.  The custom  
object class implements NSCoding, and these objects are saved to the  
core data store with no problem (they are read back correctly etc).   
Instance variables of the custom object are exposed in the user  
interface, and can be edited by the user.


The problem I have is that changes to instance variables of these  
custom objects are not reported to the managed object context, so  
the core data document is not flagged as dirty and, even if I force  
a save by adding an entity and invoking save, the modified custom  
object is not saved (if I quit and reload the old ivar values are  
loaded).


None of this is terribly surprising, since I'm going outside the  
core data world with these custom objects.  However I expect there  
must be a way to tell the managed object context it's dirty when a  
custom object attribute has been modified.  I've been reviewing the  
documentation, but it's not obvious what the preferred/cleanest way  
would be...


I would be most grateful for any suggestions on how to approach this.



http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html#/ 
/apple_ref/doc/uid/TP40001919


Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

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

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

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


Regarding SavePanel in NSDocument

2009-05-28 Thread Sourabh Sahu
Hi All,
I created NSDocument which has inbuilt SavePanel, what I want is the reference 
of SavePanel in my class.
I tried NSSavePanel *panel = [NSDocument savePanel]
But the code crashes.
Any help will be appreciated.
-Sourabh

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-28 Thread Andy Lee
On Wednesday, May 27, 2009, at 11:23PM, "Bill Bumgarner"  wrote:
>On May 27, 2009, at 8:20 PM, Andy Lee wrote:
>> I just noticed an earlier message in this thread that points out  
>> that stringWithString: does in fact do the same optimization as - 
>> copy for constant strings.  So the approach in Apple's sample code  
>> does not protect from the bundle unloading problem.  Aside from the  
>> OTHER_CFLAGS approach Jesper describes, the only solution I can  
>> think of is to use [NSMutableString stringWithString:] instead of  
>> [NSString stringWithString:].
>>
>> But of course this is an odd case, and the vast majority of the time  
>> it's just wasted code to say stringWithString:@"abc".
>
>If you find something that is causing a bundle with Objective-C code  
>to be unloaded, please file a bug via http://bugreport.apple.com/.
>
>It isn't supported and the number of edge cases are both vast and  
>subtle to the point of "it just does not work, don't do it.".
>
>(And it really won't work with GC turned on)

Oh yeah, right -- you've stressed this before.

--Andy


___

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

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

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

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


Re: Find default application for file of particular extension

2009-05-28 Thread Filip van der Meeren


On 28 May 2009, at 16:36, Nikhil Khandelwal wrote:


Hi all,

I want to find out which application is the default one for .x  
extension file in my application and to make my application the  
default one for that extension.


For finding out who is "owning" an extention you should use the Launch  
Services (http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html#/ 
/apple_ref/c/func/LSGetApplicationForInfo). And to make your  
application the default for that extention, it is the same service...  
but another method (http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html#/ 
/apple_ref/c/func/LSSetHandlerOptionsForContentType)




Its an urgent project requirement, so please reply as soon as  
possible.


Thanks,
NIKHIL



Filip van der Meeren
fi...@code2develop.com



DISCLAIMER
==
This e-mail may contain privileged and confidential information  
which is the property of Persistent Systems Ltd. It is intended only  
for the use of the individual or entity to which it is addressed. If  
you are not the intended recipient, you are not authorized to read,  
retain, copy, print, distribute or use this message. If you have  
received this communication in error, please notify the sender and  
delete all copies of this message. Persistent Systems Ltd. does not  
accept any liability for virus infected mails.

___

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

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

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

This email sent to fi...@code2develop.com


___

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

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

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

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


Spotlight importer default plugins?

2009-05-28 Thread Michael Domino

Hi all,

I know this is off-topic, but I posted to the Spotlight list and got  
no replies, and I thought someone here might know this.


Can anyone list the default set of mdimporter filters shipped with Mac  
OS X 10.4? I can figure this out by doing a clean install, but I am  
hoping to avoid that.


Thanks!

Michael Domino
michael.dom...@identityfinder.com





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Regarding SavePanel in NSDocument

2009-05-28 Thread Graham Cox


On 29/05/2009, at 12:47 AM, Sourabh Sahu wrote:

I created NSDocument which has inbuilt SavePanel, what I want is the  
reference of SavePanel in my class.


What's an inbuilt save panel? Because there isn't one in a normal  
NSDocument



I tried NSSavePanel *panel = [NSDocument savePanel]
But the code crashes.


In what way? Show the stack trace. Show your code. Show something.

--Graham


___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-28 Thread Bill Bumgarner

On May 28, 2009, at 7:52 AM, Andy Lee wrote:
On Wednesday, May 27, 2009, at 11:23PM, "Bill Bumgarner"  
 wrote:

If you find something that is causing a bundle with Objective-C code
to be unloaded, please file a bug via http://bugreport.apple.com/.

It isn't supported and the number of edge cases are both vast and
subtle to the point of "it just does not work, don't do it.".

(And it really won't work with GC turned on)


Oh yeah, right -- you've stressed this before.


And I probably will again. :)

Note also that limiting yourself to just using CoreFoundation isn't  
safe, either.   A growing portion of CoreFoundation is implemented in  
Objective-C.


b.bum

___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-28 Thread Jesper Storm Bache
Does your latest statement mean that the following (from http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Tasks/loading.html#/ 
/apple_ref/doc/uid/20001127-124675)

is incorrect/obsolete information:

"You can unload the contents of a CFBundle object using  
CFBundleUnloadExecutable..."


Jesper

On May 28, 2009, at 8:20 AM, Bill Bumgarner wrote:


On May 28, 2009, at 7:52 AM, Andy Lee wrote:

On Wednesday, May 27, 2009, at 11:23PM, "Bill Bumgarner"
 wrote:

If you find something that is causing a bundle with Objective-C code
to be unloaded, please file a bug via http://bugreport.apple.com/.

It isn't supported and the number of edge cases are both vast and
subtle to the point of "it just does not work, don't do it.".

(And it really won't work with GC turned on)


Oh yeah, right -- you've stressed this before.


And I probably will again. :)

Note also that limiting yourself to just using CoreFoundation isn't
safe, either.   A growing portion of CoreFoundation is implemented in
Objective-C.

b.bum



___

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

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

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

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


Re: Cocoa-dev Digest, Vol 6, Issue 794

2009-05-28 Thread Greg Guerin

Mike McLaughlin. wrote:

I'm familiar with recursion; that is what prompted my query.   
However, the

tree-traversal documentation at

http://devworld.apple.com/documentation/Cocoa/Conceptual/ 
NSXML_Concepts/Arti

cles/TraversingTree.html#//apple_ref/doc/uid/TP40001257

seems to indicate that the built-in traversal method, nextNode, is
non-recursive (in the usual sense).


Read beyond Listing 1.

The nextNode method is simply ONE method that can be used for  
traversal.  The rest of the documentation below Listing 1 describes  
ways to perform hierarchical traversal.




This method will return non-nil until
the whole tree is finished.  I was looking for some indicator that  
I had

finished just a subtree.  [Perhaps level will work.]


Your question is vague.  You need to be specific about exactly what  
this traversal will do, and in what order of nodes.  Depth-first is  
easy using any of the hierarchical traversals below Listing 1.


There are 2 steps to your original question:
  1. Find the node that represents a desired subtree.
  2. Traverse that subtree, doing something.

You can use ANY of the methods for step 1.  One may be more efficient  
than others.  Hard to say without knowing exactly what criteria  
you're using to choose the node.


Once you have the node of interest, you can traverse using the  
hierarchical methods.  If you insist on using nextNode, however, it  
may be harder to identify the end of the subtree, because nextNode  
inherently treats the nodes as flat (sequential), not hierarchical.   
It's easy to identify the end of a subtree because the hierarchical  
traversal just naturally ends.  It won't be impossible to identify  
the end of a nextNode-traversed subtree, and as you speculated, using  
level would work.


  -- GG

___

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

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

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

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


performSelectorOnMainThread problem

2009-05-28 Thread Ben Einstein
Does anyone know of any issue that would cause  
performSelectorOnMainThread to not actually perform the selector but  
not report any kind of error? I use threads very often and have never  
had a problem like this, but when I call:


[aControllerObject performSelectorOnMainThread:@selector(doSomething:)  
withObject:anObject waitUntilDone:NO];


absolutely NOTHING happens. No log messages, doesn't pause on break  
points, and certainly no exceptions. But if I do this:


[aControllerObject performSelector:@selector(doSomething:)  
withObject:anObject];


it works every time. I'm completely baffled. Has anyone seen anything  
like this before?


Thanks,
Ben
___

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

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

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

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


Creating strings in a loop - Efficiency Question

2009-05-28 Thread Reza Farhad

Hi

I have a situation where I need to create a new string as I go through  
a loop.
What will be the most efficient way of doing this each time the call  
goes through the loop.


1. To create an auto releasing string.
2. To create a non auto-releasing string at the start of the loop and  
releasing it at the end of the loop.
3. To create a non auto-releasing mutable string before the loop and  
then at the start of the loop delete and reset it content to a new  
value. And obviously delete the string after the loop.


4. An alternative suggestion

Thanks in advance

Reza

 
 
___


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

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

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

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


Re: Creating strings in a loop - Efficiency Question

2009-05-28 Thread Dave Carrigan


On May 28, 2009, at 9:20 AM, Reza Farhad wrote:

I have a situation where I need to create a new string as I go  
through a loop.
What will be the most efficient way of doing this each time the call  
goes through the loop.


1. To create an auto releasing string.
2. To create a non auto-releasing string at the start of the loop  
and releasing it at the end of the loop.
3. To create a non auto-releasing mutable string before the loop and  
then at the start of the loop delete and reset it content to a new  
value. And obviously delete the string after the loop.


4. An alternative suggestion



5. Pick the easiest one of these, and then wait until you start  
profiling your application to decide if this even needs to be optimized.


--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA



PGP.sig
Description: This is a digitally signed message part
___

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

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

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

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

Re: performSelectorOnMainThread problem

2009-05-28 Thread Nick Zitzmann


On May 28, 2009, at 10:11 AM, Ben Einstein wrote:

Does anyone know of any issue that would cause  
performSelectorOnMainThread to not actually perform the selector but  
not report any kind of error?



Are you sure the main thread isn't busy and is running a run loop in  
its default mode?


Nick Zitzmann


___

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

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

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

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


  1   2   >