Re: xcode crashes on adding an embedded framework

2008-05-14 Thread j o a r


On May 14, 2008, at 11:23 AM, Albert Jordan wrote:

I'm having a problem with crashes with xcode.  how can i post the  
problem?


over the week-end I downloaded and used Skype framework in some  
applications.  Then, by accident, I believe I delete the skype  
framework.  I discovered this by noticing the Skype framework was  
highlighted in red.  I deleted the framework in xcode, and attempted  
to add the framework again.  Now xcode crashes anytime I'm trying to  
do this.  Even if I open a brand new application, and try and add a  
framework xcode crashes.



Please file a bug report here:

<http://developer.apple.com/bugreporter/>

In the future, you might want to direct messages of this type to the  
"Xcode-Users" mailing list.
If you post more information about your crash there, someone might be  
able to suggest a workaround. But even so, you should still file a  
formal bug report. Don't forget to include information about the  
version of Mac OS X and Xcode that you're using.


Thanks,

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: window controller's [self window] not working

2008-05-14 Thread j o a r


On May 14, 2008, at 9:23 PM, Daniel Child wrote:

This exact same code used to work in previous incarnations of the  
program, and it seems that it simply "broke" when I opened the nib  
in IB3 and added a text field. (It was originally created in IB2 and  
worked fine in Leopard and XCode 3 until I modified it.)


I am just getting used to IB3 but don't see what or how I could have  
broken the connection. Are there any obvious culprits?



Double-check that the "window" property of the window controller  
(files owner) is connected to the window in your nib file.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: validateMenuItem() not always being called

2008-05-18 Thread j o a r


On May 18, 2008, at 3:46 PM, Hal Mueller wrote:


-validateMenuItem: is deprecated



Really? Where is this documented?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-19 Thread j o a r


On May 19, 2008, at 10:33 AM, Peter Duniho wrote:

In any case, it takes a pretty blind eye to claim that the volume of  
complaints is in no way related to problems.



I would expect that the volume of complaints is pretty much directly  
related to the over 100.000 downloads of the iPhone SDK that happened  
over the last several weeks. Who can look at that number and not  
expect to hear from a lot of confused programmers trying to learn [1]  
a new language, [2] a new framework and [3] a new OS at the same time?


Programmers have been productive on this platform (language, tools,  
OS) for years and years. The tools, technologies and documentation is  
better than ever. Are there still things that could be better? Of  
course there is, but would that not always be true?


Whenever you, as a programmer, try to make this jump to a new platform  
you have to suppress the urge to complain about everything that isn't  
exactly like your old environment, or everything that you don't  
understand right away. This is just like traveling to a different  
country. Things that are different are not necessarily bad, and it  
typically takes a while to understand why things work the way they do  
(Take it from me, I just moved to the US). The point of traveling is  
experiencing new things to learn from and get inspired by, and the  
same holds true for learning about new environments as a programmer.


We welcome input from new users to our platform. It's great to have an  
influx of new people come with fresh ideas. Please file bug reports  
for any concrete problems you find or suggestions that you have:


<http://developer.apple.com/bugreporter/>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with updating NSProgressIndicator

2008-05-20 Thread j o a r


On May 19, 2008, at 11:53 PM, Vitaly Ovchinnikov wrote:


I tried to move progress update from timer to selector that was called
by performSelectorFromMainThread - doesn't help too.



Does this comment mean that you're currently calling -setDoubleValue:  
from a background thread? That's, AFAIK, not supported. You need to  
change this, and any other calls that you do on UI components, to the  
main thread. This is likely the source of your problems.


Verify that your background threads never make any thread unsafe  
calls, and use -performSelectorOnMainThread: to forward your status  
updates to the main thread for display.
If you still have this problem, I think that the next step would be  
for you to create a small sample project that reproduces the problem  
and then sending a link to the list so that we can check it out.



On May 20, 2008, at 6:40 AM, Matt Long wrote:

I recently wrote a blog post with a demo xcode project that shows an  
implementation of updating a progress indicator for file copy. You  
can see it here: http://www.cimgf.com/2008/05/03/cocoa-tutorial-file-copy-with-progress-indicator/



Two things:

* The "context" pointer of your callback function is designed to allow  
you to pass information about the object that is interested in the  
callback. In that way you don't have to do things like creating a  
separate static variable for the progress indicator. I find this to be  
a "cleaner", or at least more object oriented, solution.


* If you're not blocking the main thread you don't have to call - 
displayIfNeeded. The "if needed" part probably doesn't make much sense  
here in any case - You know that it's needed, you just updated the  
value. If you need to force display you should call -display, but you  
should only have to do this in exceptional situations. It is much more  
common to flag a control as needing to update display, in which case  
you would call -setNeedsDisplay:. In this case though, you shouldn't  
have to do either, as the call to -setDoubleValue: will flag the  
control as needing display.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-21 Thread j o a r


On May 20, 2008, at 9:52 PM, Peter Duniho wrote:

Each language varies a bit, of course.  But in the other popular  
languages that I know reasonably well -- C++, C#, Java -- a subclass  
does not have the ability to touch any part of the base  
implementation that is not specifically exposed by that  
implementation.  Private members are invisible, and other members  
are only overridable when the base class allows it by making them  
virtual.


Cocoa restrains class extension _much_ less than any of these other  
languages, and in turn has a _much_ higher degree of hazard.



The goal is not for every language to mimic C++/C#/Java. Different  
languages serves different purposes and there is no single best  
language. Take Adobe Lightroom as an example, almost half of the code  
(by line count) is written in Lua:


<http://www.lua.org/wshop05/Hamburg.pdf>

Is this because they don't know how great a static, restrictive, safe,  
and secure language is? No, it's because they thought that some other  
language quality was more important.


I think that Objective C finds a pragmatic sweet spot between the  
performance and interoperability of C, and the dynamism and rapid  
development qualities of scripting languages. It is small and easy to  
learn, easy to read and write, and since you rarely have to deal with  
raw pointers, it also provides many of the benefits of a more pure  
object environment like Smalltalk/Java/C#.


Most developers that I know of feel more productive in Objective C  
than using more restrictive languages like C++/C#/Java. You might  
expect that the same qualities that makes a language good for rapid  
development also would brings some drawbacks, for example making the  
code more difficult to read and maintain. However, this is not a  
problem typically associated with Objective-C.


Finally, also note that the compiler isn't the only, or perhaps even  
the best, way to achieve productivity and quality - See the  
discussions on "Strong Typing vs. Strong Testing":


<http://mindview.net/WebLog/log-0025>


It's certainly a continuum.  I agree we're not talking either/or,  
black/white, etc. here.  Other languages aren't without their danger  
zones either.  It just seems to me that Cocoa goes overboard, for  
relatively little payoff.



Let's agree to re-visit this discussion one to two years from now. I  
don't think that it's fair of us to expect you to provide an informed  
comparison before you have more experiences with both environments.


Regards,

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-21 Thread j o a r


On May 21, 2008, at 12:49 AM, Peter Duniho wrote:

I have already acknowledged that opinions vary.  You, being among  
the regular contributors to this mailing list, I fully expect to  
"think that Objective-C find a pragmatic sweet spot".  Anything else  
would surprise me.



There are a lot of things I would like to change about Objective-C if  
I could, but would my version end up having the same broad appeal?  
With pragmatic I wanted to imply that I think that it manages to solve  
a lot of problems without falling into the trap of being too "pure" in  
any direction.



[...] Let's agree to re-visit this discussion one to two years from  
now. I don't think that it's fair of us to expect you to provide an  
informed comparison before you have more experiences with both  
environments.


You are simply proving my point.

You reject my impressions simply because I have less experience with  
the language.  You fail to have any sympathy whatsoever for my  
personal experience, and tell me that I will change my mind after  
using Cocoa for two more years.



That was not my intention. What I wanted to say is that I think that  
we've probably taken this discussion as far as we can at this point,  
but that I thought it would be interesting to come back to this same  
topic at some later point when you have had a chance of getting to  
know ObjC + Cocoa better. My hope was not that you at this point would  
be either brain washed or departed. I clearly failed to communicate  
this well enough, and I should also not assume to know how much  
experience you already have on this platform. If I came across as  
blunt and / or condescending, I apologize.



And again: it's not that I'm on a crusade to have Objective-C  
changed, or to have Cocoa made fully accessible via some other  
language.  I just want people to have some empathy for what at least  
some of us go through upon encountering the one official Mac  
development environment.  Stop telling us that our reactions aren't  
valid; for better or worse, these are our reactions and we can no  
more control them than you can stop breathing.  They are ours and  
like it or not, they matter.



I do respect both your first impressions, and your unique insight  
based on experiences from other platforms. That's why I wrote this in  
my other message to this thread:



We welcome input from new users to our platform. It's great to have  
an influx of new people come with fresh ideas. Please file bug  
reports for any concrete problems you find or suggestions that you  
have




j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Application rights.

2008-05-22 Thread j o a r


On May 22, 2008, at 8:43 AM, Eugen Belyakov wrote:

I want to create updater for my application. The problem is that  
application
can be update not by the user, that installed it. And updater  
application
won't be able to overwrite files. Is it possible to increase rights  
of my

application through authentification (like in Finder when performing
operations with files of other users)?



I would advice against trying to write your own installer / updater.  
This is very difficult to get right, even if you are an expert Mac OS  
X developer. It's not just a technical problem, you would also have to  
know about the guidelines for where files should be installed on Mac  
OS X, how users expect installers to work on Mac OS X, et.c.


I would suggest that you look at one of the existing updaters, like  
Sparkle:


<http://sparkle.andymatuschak.org/>

Or to Apple's installer:

	<http://developer.apple.com/documentation/DeveloperTools/Conceptual/PackageMakerUserGuide 
>
	<http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What is an id?

2008-05-22 Thread j o a r


On May 22, 2008, at 10:05 AM, john darnell wrote:


The question is, what does the code want me returning as an id?

I tried to do a search in Cocoa Help on id and as you might imagine, I
got lots and lots of hits, none of which looked anywhere near what I
wanted for an explanation of what id is.  So what is the framework
expecting me to return?



It expects you to return an object that will be used by the cells in  
your table view to display their respective value.


The type of object to return would depend on the cell type used for  
that particular column-row intersection. A string if you're using a  
text cell, an image if you're using an image cell, and so on.


The reason for using "id" here is to allow you to use any type of  
object value as the source of data for your cell to display.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSString vs NSPathStore2

2008-05-22 Thread j o a r


On May 22, 2008, at 10:38 AM, <[EMAIL PROTECTED]> wrote:

I am then trying to populate an NSTableView with a filename obtained  
from a
NSOpenPanel. The problem is that NSOpenPanel seems to return a  
NSPathStore2
and not an NSString, which seems to be causing problems. Is there  
are a way

to convert NSPathStore2 to an NSString?



How do you determine that this is a problem? What is the problem?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How can i get current system time?

2008-05-30 Thread j o a r


On May 30, 2008, at 11:40 PM, haresh vavdiya wrote:

I have read about NSDate, NSTimer but i can't understand how to use  
that class for getting current system time?



You could use +[NSDate date], as it according to the documentation:

"Creates and returns a new date set to the current date and time."

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: super respondsToSelector

2008-05-31 Thread j o a r


On May 31, 2008, at 12:10 AM, Michael Ash wrote:


If you're adventurous and foolish you can extract your superclass
without needing to hard-code any class names:

#import 
...
Class superclass = ((struct objc_super *)super)->class;

But this is probably a poor idea to use in practice



Why not simply:

[[self superclass] instancesRespondToSelector:...]

?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: KVO: I get called on change, but then can't get the object

2008-05-31 Thread j o a r


On May 31, 2008, at 12:21 AM, Rick Mann wrote:

I registered to observe changes in the "number" column of my tree  
controller:


[mItemsController addObserver: self
forKeyPath: @"selection.number"
options: (NSKeyValueObservingOptionNew)
context: NULL];

My -observe: action gets called, but this line

	NSLog(@"Value changed %@: %@ (%@)", inKeyPath, inChange, [inObject  
selection]);


dumps this to the console:

Value changed selection.number: {
   kind = 1;
   new = ;
} (<_NSControllerObjectProxy: 0x177cb0>)

Note that "new" is null. I would expect it to be the value of the  
number.



Search for "NSKeyValueObservingOptionNew" here:

<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>



Furthermore, this line:

NSLog(@"selection: %@", [inObject valueForKey: @"selection"]);

dumps:

selection: <_NSControllerObjectProxy: 0x177cb0>

But if I change it to @"selection.number", it throws the exception:

"[ valueForUndefinedKey:]: this class is  
not key value coding-compliant for the key selection.number."



What happens if you call "-valueForKeyPath:" instead of "-valueForKey:"?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: super respondsToSelector

2008-05-31 Thread j o a r


On May 31, 2008, at 12:23 AM, Michael Ash wrote:


Assume the following class hierarchy:

A <- B <- C <- D <- E

In the implementation of B, you write [self superclass]. Now your
method executes with self set to an instance of E. What do you get?



I would propose that you should re-examine your design if you find  
that to be a problem in practice:


<http://en.wikipedia.org/wiki/Code_smell>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray

2008-06-01 Thread j o a r


On Jun 1, 2008, at 5:02 PM, Nathan wrote:


[tableView setDataSource: Items];



Besides what Markus and Jonathan already suggested:

NS/Mutable/Array doesn't conform to NSTableDataSource as far as I know.
The data source should typically be one of your controller classes,  
like a window controller.
You would also typically set the data source in IB, and not in an  
action method.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to use the default about panel

2008-06-01 Thread j o a r


On Jun 1, 2008, at 5:56 PM, Nick Rogers wrote:


How can I make changes to the default "about panel"?
Or do i have to add my own panel?



Have a look at this technote:

<http://developer.apple.com/technotes/tn2006/tn2179.html>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread j o a r


On Jun 2, 2008, at 9:12 AM, Todd Ransom wrote:

It seems that what I need is a non-retaining array. I googled around  
a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed. Still, I  
thought I would ask around and see if anyone else has done this  
before I embark on trying to subclass a class cluster.


Has anyone out there created a non-retaining array class or come up  
with another solution to this problem? Or is there anything in  
particular I should watch out for when subclassing NSMutableArray?



If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread j o a r


On Jun 2, 2008, at 10:04 AM, Jens Alfke wrote:

If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


That is So. Awesome. I've been using Leopard for like two years now,  
and I'd never noticed this class before. Thanks for the tip!



It is pretty awesome. It was introduced together with the new  
NSMapTable and NSHashTable classes [*], primarily to support using  
Cocoa together with Garbage Collection.


j o a r


[*] Not to be confused with the older C-API with the same name

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Best Practice for Returning Immutable Objects?

2008-06-03 Thread j o a r


On Jun 3, 2008, at 8:56 AM, Karl Moskowski wrote:


Would it be sufficient to cast, like this?
:
return (NSData *)myData;

Does this generalize to other non-collection classes, e.g., NSString?



In the general case yes. I would say that it's not up to you to ensure  
that this object is not being accidently mutated at some later point -  
you already declared the returned object to be of an immutable type.


If someone later needs to ensure that they hold an immutable and  
private copy, they can always copy it at that point. If the object  
being copied is already immutable, this is typically cheap. See the  
"Copying Mutable Versus Immutable Objects" optimization here:


<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/ImplementCopy.html#//apple_ref/doc/uid/20000049-999791 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Versioning MainMenu.nib

2008-06-04 Thread j o a r


On Jun 3, 2008, at 8:12 PM, Chris Outwin wrote:

I have MainMenu.nib and MainMenu(Debug).nib in a Cocoa document app  
using Xcode 3.0.  The (Debug)version has controls only used during  
development.  I am trying to use build settings to dynamically load  
the MainMenu(Debug).nib when PreprocessorMacros has a value  
associated with the debug configuration.


The only example I've found is AppeanceSample:  a Carbon app which  
does not have NSMainNibFile MainMenu in  
the Info.plist.  This key/value pair may be my problem.


How do you dynamically select between two version of MainMenu.nib in  
a Cocoa document app?



Having extra menu items added to your debug builds is not an uncommon  
practice. Most of the time though, developers choose to not replace  
the whole menu, but rather just add a special "Debug" menu at the end  
of their regular menu bar.


You could load this debug menu from a nib file, but I would probably  
suggest that you just create and insert it programatically. See the  
API in NSApplication (for how to get a reference to the main menu),  
and the API in NSMenu & NSMenuItem (for how to create and insert the  
menu).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where to start looking to fix hang?

2008-06-04 Thread j o a r


On Jun 4, 2008, at 9:17 PM, Graham Cox wrote:

Where should I start to look to debug/fix this? I just can't see  
where I need to set a breakpoint to begin with.



Run your app in the debugger. When it hangs, hit the "pause" button in  
the debugger and take a look at the backtrace in the thread list. That  
would tell you where it's hanging.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting rid of specific "May not respond" messages

2008-06-05 Thread j o a r


On Jun 5, 2008, at 8:50 AM, Dale Jensen wrote:

In my project, I get a number of warnings that are invalid, telling  
me that something or another "may not respond" to something, when in  
fact, it can.  As an example, I get a lot of these:


warning: 'NSString' may not respond to '- 
stringByReplacingOccurrencesOfString:withString:'

warning: 'NSFileManager' may not respond to '-removeItemAtPath:error:'
warning: 'WebView' may not respond to '-mainFrameURL'

while are all Cocoa framework calls, which do work.  In some  
instances, I've found that tracking down a header file and  
#importing it sometimes gets rid of the message, but not always  
(can't seem to get rid of the three shown here, ever.)



These are all methods added in Mac OS X 10.5. Check the SDK settings  
for your target.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App hangs when displaying any sheet in 10.5 [SOLVED]

2008-06-06 Thread j o a r


On Jun 5, 2008, at 10:26 PM, Graham Cox wrote:

I guess the question is, given an object type 'id', which method  
signature will the compiler go with? Does the return type affect the  
method signature? (In C++ it doesn't for example), so two methods:


- (CGPoint) position;
- (float)   position;

might well have identical signatures. The compiler doesn't have an  
object type to narrow it down, so which will it use - the first it  
finds maybe.



You might want to experiment with enabling one or more of the  
following optional warnings:


-Wselector
Warn if multiple methods of different types for the same selector are  
found during compilation. The check is performed on the list of  
methods in the final stage of compilation. Additionally, a check is  
performed for each selector appearing in a "@selector(...)"  
expression, and a corresponding method for that selector has been  
found during compilation. Because these checks scan the method table  
only at the end of compilation, these warnings are not produced if the  
final stage of compilation is not reached, for example because an  
error is found during compilation, or because the -fsyntax-only option  
is being used.

-Wstrict-selector-match
Warn if multiple methods with differing argument and/or return types  
are found for a given selector when attempting to send a message using  
this selector to a receiver of type "id" or "Class". When this flag is  
off (which is the default behavior), the compiler will omit such  
warnings if any differences found are confined to types which share  
the same size and alignment.

-Wundeclared-selector
Warn if a "@selector(...)" expression referring to an undeclared  
selector is found. A selector is considered undeclared if no method  
with that name has been declared before the "@selector(...)"  
expression, either explicitly in an @interface or @protocol  
declaration, or implicitly in an @implementation section. This option  
always performs its checks as soon as a "@selector(...)" expression is  
found, while -Wselector only performs its checks in the final stage of  
compilation. This also enforces the coding style convention that  
methods and selectors must be declared before being used.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: IKImageBrowserView is bonkers

2008-06-06 Thread j o a r


On Jun 6, 2008, at 3:50 PM, Randall Meadows wrote:

The images are captured from a digital camera, which is oriented in  
a portrait fashion.  Once downloaded from the camera, the images are  
rotated (using jpegtran) to a "normal" orientation, the EXIF is  
edited to match (using exiftool, since jpegtran leaves the flag  
alone when it rotates it), and finally an icon is added to the file  
using this code:


NSImage *preview = [[NSImage alloc] initWithContentsOfFile:filePath]];
[[NSWorkspace sharedWorkspace] setIcon:preview forFile:filePath  
options:0];


So the image is created from the rotated, EXIF-fixed image file.   
The image file displays correctly in Preview, Safari, QuickLook, and  
its Finder preview icon is correct also.


Why come then does the IKImageBrowserView always initially show the  
image rotated 90° CW, and then a little while later refresh it to be  
correct?  Sorry, not even INITIALLY, its whenever the view updates  
from the data source.  The data source simply returns the full path  
to the image in the filesystem to display when requested.  I've  
already determined that the image file itself is correct in all ways.


You can see a short (~30 second) QT movie of this strange behavior  
in action at <http://idisk.mac.com/callipygiani/Public/ 
RotationWTF.mov>.  The movie shows several images being captured and  
added to the view, a couple deleted from the view, and then another  
captured and added.


Any tips or suggestions as to what is going on would be GREATLY  
appreciated.  I really don't want to have to write my own image  
browser view...



The images probably have an embedded thumbnail / preview that is not  
updated when you rotate the main image using "jpegtran". My bet is  
that the image browser for performance reasons by default use an  
existing embedded thumbnail / preview to improve perceived performance.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Expanding Window/View

2008-06-09 Thread j o a r


On Jun 9, 2008, at 9:07 PM, SD wrote:

I'm going to be creating a Cocoa ui that will need to be able to  
display, side-by-side, a variable number of copies of the same view  
(ie: the view will have labels, and text fields and buttons but each  
view will show different data).



See:NSCollectionView

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Updating a progress bar from a code loop

2008-06-09 Thread j o a r


On Jun 9, 2008, at 11:24 PM, Graham Cox wrote:

I have a lengthy routine that I'd like to show a progress bar for.  
The routine runs in a while() loop, and calls a delegate which  
implements the progress update. My progress window opens OK but  
nothing gets updated, though I know that it's getting the correct  
values set.


I'm assuming the problem is that because I'm not running the event  
loop at this point, updates aren't getting processed. Makes sense I  
think.


How do I give some time to the event loop while I'm running my own  
loop? I tried:


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


but it didn't fix the problem. Note that I've tried running my  
window both modally and non-modally but it's the same either way.


What should I be doing?



See if you can make your lengthy routine thread safe, and if so, run  
it on a background thread.
You should put a lot of effort into always leaving the main thread  
open for user events.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Updating a progress bar from a code loop

2008-06-10 Thread j o a r


On Jun 10, 2008, at 3:17 AM, Graham Cox wrote:

though out of curiosity I wonder if there is a way to do this  
"cooperatively" on the main thread without having to break up the  
loop doing the actual work. For example, in Carbon one can run the  
event loop for a short period or just for one event on each cycle of  
the loop - and this code can live in the progress dialog controller,  
so it works transparently with respect to the loop that drives the  
progress indicator. I'm not sure that approach is considered "good"  
in this day and age though I used it a lot on Mac OS 6/7/8/9. Just  
wondered if such an approach is feasible in Cocoa.



Yes, you can do that. You would typically use a NSTimer to repeatedly  
schedule small pieces of work to be performed on the main thread. You  
wouldn't have to use a modal session to do this - It is certainly not  
a requirement to lock out the user while processing data.


That said - No, it is not considered to be a good approach. It's  
almost impossible to implement it in such a way that it doesn't affect  
the user experience. It's typically much better, and more "future  
safe", to invest your time in a multi-threaded implementation.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Garbage collector vs variable lifetime

2008-06-11 Thread j o a r


On Jun 11, 2008, at 12:29 AM, Jim Puls wrote:

For that matter, it may be worth pointing out John's confusion  
between "sloppy" and "incorrect". He makes a decent point that  
returning a mutable object when the method definition specifies an  
immutable one is sloppy and, indeed, fraught with peril.



Do you feel the same way about passing a (char *) to a method that  
takes a (const char *)?


I think that it's perfectly reasonable to expect the receiver of the  
piece of data, or object, that you hand over to respect the basic  
restrictions of that type.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView threading problem

2008-06-14 Thread j o a r


On Jun 14, 2008, at 9:12 PM, Bill Bumgarner wrote:

As well, no amount of locking will make a non-thread-safe object  
thread-safe unless you absolutely positively know that only your  
code (and only your code protected by the locks) contain the only  
reference to said object.



In the general case you wouldn't even be safe if this was the case,  
since that object could in turn modify shared mutable state in a  
thread-unsafe manner.


The bottom line is that you have to understand what you're doing, and  
you have to follow the thread safety rules outlined in the  
documentation.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView threading problem

2008-06-16 Thread j o a r


On Jun 16, 2008, at 7:44 AM, David wrote:


While I've been investigating this, I have found more documentation on
thread safety issues in the "Threading Programming Guide". I'd read it
before but it helps to re-read. It says that NSView classes ARE thread
safe... to an extent.



Very interesting that it says that NSView is "generally thread-safe",  
but then immediately afterwards limits you to "perform other  
operations [...] only from the main thread". Note the "other", which  
is as broad in scope as the "generally" used earlier. I'm going to  
file an enhancement request for improved documentation here.


I think that what they want to call out there is that you can draw  
from background threads. I could be wrong, but I don't think that you  
should read more into it than that.


Also note that just because there are some operations on the NSView  
class that are thread safe, that doesn't mean that subclasses have  
even the same level of thread safety - unless explicitly called out in  
the documentation.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: awakeFromNib

2008-06-16 Thread j o a r


On Jun 16, 2008, at 8:07 AM, David Harper wrote:

I am setting up a preferences window, and I would like awakeFromNib:  
to be invoked earlier than it does.  Currently, it only gets invoked  
when the preferences window is shown / opened.



You can call:   -[NSWindowController loadWindow]

But I'm not sure if that's really what you should be doing - see my  
comments below.



I expected that there might be an option to specify this in the .nib  
file itself, and I got my hopes up with the "deferred" check box  
which is enabled by default - the tooltip said "Sets whether the  
window server creates a window device for the window immediately.   
When YES, the window server defers creating the window device until  
the window is moved onscreen."



No, this checkbox controls something else at a lower level, something  
you shouldn't mess with.
I have to say, I'm not even sure why we have a checkbox for this in  
IB...



Right now the reason I want to do this is that the contents of the  
controls in the preferences windows can themselves be used to save  
the preferences.  For example I'd stick [backgroundColor color] in a  
dictionary (where backgroundColor is a color well) instead of  
managing my own NSColor * and responding to delegate methods.



If I read this correctly, you use the controls in your window as model  
objects to store preferences that are accessed by other parts of your  
application? If so, I'd suggest that this is a design flaw that you  
should fix. The view objects in your application should not double as  
model objects - See: The MVC design pattern.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView threading problem

2008-06-16 Thread j o a r


On Jun 16, 2008, at 9:05 AM, Adam R. Maxwell wrote:

This level of vagueness is persistent throughout the framework docs,  
though, and gives them an absolute value |v| < 0 with respect to  
threading (my opinion, of course).  And yes, I know the "file a bug  
report" mantra, but a) I don't get paid for filing bug reports, and  
b) it can take years even for a doc bug to be fixed (my oldest is  
from 2005, but I expect it's just forgotten).



You're clearly right in that Apple needs to provide much better  
documentation with regards to thread safety.


While I would also have to respect your "I'm not paid for filing bug  
reports" standpoint, just keep in mind that bug reports does matter -  
a lot - and I can assure you that it's much easier to get a feature  
request on improved documentation fixed, than it is to get a feature  
request on a software product fixed. The reason why this is the case  
should be clear to anyone working in the software industry. For this  
reason it is my experience that it's typically rather gratifying to  
file doc bugs - give it another chance!


If you have a very old bug open for a simple documentation fix I'd  
suggest that you contact ADC and ask for an update. There might be  
some sort of misunderstanding:


<http://developer.apple.com/contact/>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView threading problem

2008-06-16 Thread j o a r


On Jun 16, 2008, at 3:59 PM, Adam R. Maxwell wrote:

The confusion between "thread safe" and "main thread only" on this  
list hasn't helped, either...



From a documentation perspective there is no single or simple  
definition of "thread safe", it all depends on the context.


Some objects are not thread safe, and also have the restriction that  
they can only be used on the main thread. Other objects, while still  
not being thread safe, can be used on a non-main thread - As long as  
they're only used on one thread. Other objects, while still not thread  
safe, can be used from different threads - As long as they're only  
ever used from one thread at a single time. Et.c., et.c.


The complexity of this topic makes it difficult to create the same  
type of documentation that we enjoy for the simple API reference of  
classes and methods.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSSound thread-safety?

2008-06-16 Thread j o a r


On Jun 16, 2008, at 5:07 PM, Jens Alfke wrote:

Is NSSound thread-safe? Now that I look, I can't find any  
documentation; the Cocoa thread safety docs don't refer to NSSound  
at all.



That would indicate that it isn't thread safe.

I think that you can use QTKit to load and play sound files  
asynchronously.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Send Key Event to Focused Window

2008-06-18 Thread j o a r


On Jun 18, 2008, at 12:31 AM, Daniel wrote:


I'm developing a tool for assistive input and my question is how can I
send a key event (like a keyboard press event) to the current window
(whatever this one could be), for data input.



Have you looked at the Quartz Event Services?

<http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html 
>


I assume that you've already familiarized yourself with the  
Accessibility APIs:


<http://developer.apple.com/documentation/Cocoa/Conceptual/Accessibility/cocoaAXIntro/cocoaAXintro.html 
>



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Send Key Event to Focused Window

2008-06-18 Thread j o a r


On Jun 18, 2008, at 4:25 AM, Daniel wrote:


Basically, I've noticed that the code I'm using works (as it sends the
right event), but it is sent to the wrong "receiver". That means I'm
sending it to my current application, instead I should be able to
click on a button (representing a key stroke) and sending the event
(e.g. Safari) to the right application.



Cocoa is not a "cross-process" API, for the most part, so that would  
be expected.


In the code you posted you used a reference to "NSApp". This is a  
reference to your own application, it's not a reference to some other  
application. The OS prevents you from interacting directly with the  
internals of other applications for stability and security reasons.


You should be able to do what you want using Quartz Event Services.



Is there a way to build a focus-less application/window?



Can you explain what you mean by that?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with NSWindow setFrame

2008-06-19 Thread j o a r


On Jun 18, 2008, at 11:50 PM, kalpana k wrote:


window setFrame: NSMakeRect(0,0,1024,1200)



Should this not be something more like:

NSMakeRect(0.0, -768.0, 1024.0, 1200.0)

Also note that, according to the documentation:

	"Note that any NSWindow with a title bar automatically constrains  
itself to the screen."


	<http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Tasks/SizingPlacingWindows.html#//apple_ref/doc/uid/2228-135785 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating a Bundle via Code

2008-06-20 Thread j o a r


On Jun 20, 2008, at 3:28 PM, Grant Limberg wrote:

Initially I was storing the data in Core Data.  In my app, the user  
has the ability to attach an image to a record in Core Data.  
Unfortunately, changing from a JPEG to NSData inflates a 1.5MB JPEG  
to over 20 MB.  In talking with some folks at the local Cocoaheads  
meeting on wednesday, one person suggested making a bundle or  
package in Application Support to store the images and just have a  
referencing URL in the Core Data store. This is what I'm trying to  
do now.



It doesn't sound to me that you actually need to have a bundle. You  
can just store the image data as files in the file system.


I'm also curious as to why you decompress the JPEG file? If you got  
the image as a compressed JPEG, why not store it as is?


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating a Bundle via Code

2008-06-20 Thread j o a r


On Jun 20, 2008, at 3:43 PM, Grant Limberg wrote:

As far as I know, you can't store a raw jpeg in Core Data directly  
without turning it into an NSData object first which in turn  
decompresses it.



It sounds quite possible that Core Data only support images in the  
form of NSData. That said, I see no reason why you would have to  
decompress the JPEG to generate this NSData.


We need to know more about your application to provide more detailed  
assistance. Where do you get your JPEG images from? Over the network?  
From files in the file system? Pasted into an image view by the user?


It sounds like you go from JPEG -> NSImage -> NSData? Instead of  
creating a NSImage, how about just storing the JPEG as is to the file  
system first, and only later generating NSImages as needed for display  
in your application.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating a Bundle via Code

2008-06-20 Thread j o a r


On Jun 20, 2008, at 4:00 PM, Grant Limberg wrote:

Currently, the user drags an existing image from their filesystem to  
an NSImageView bound to an NSData attribute in the sqlite data  
store.  This causes the decompression from 1.5MB to 20MB.  As you  
can see, this isn't exactly efficient.   Hence the question on  
package/bundle creation.  I'm wanting to just store the jpeg  
directly to disk and just store a URL to it in the sqlite data store.



You can always re-compress the image file before writing it out to the  
file system. But that seems kind of silly...


I would suggest that you intercept the drag operation and copy the  
file directly. You should be able to do this quite easily if you  
subclass the image view:


<http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html 
>


j o a r



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to prevent NSControl from graying out when sent to background?

2008-06-24 Thread j o a r


On Jun 24, 2008, at 9:28 AM, Greg wrote:

Hi, I'm making little notification windows that contain some  
NSControls in them, one particular one is the NSProgressIndicator  
(as a bar).  These windows are similar to the default growl windows,  
and so appear above all other windows and appear "active" while  
actually being hosted by a background application.  As such, the  
progress indicator in one of them is grayed out, how do I prevent it  
from doing that?



Create a custom NSWindow / NSPanel subclass that overrides "- 
isKeyWindow" to always return YES.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help getting custom cell layout in NSOutlineView column

2008-06-27 Thread j o a r


On Jun 27, 2008, at 8:55 AM, Sebastian Nowicki wrote:

I've been trying to find some documentation as to how to do this,  
and as far as I can tell I'm supposed to subclass NSCell and somehow  
draw both labels. I'm completely new to creating views and such, and  
I'm unable to find any good sample code as how to do it. The layout  
I want looks something like this:


+---+
| |  Foobar
|   (Image)|
| |  Some description that can be quite  
long, but should never

| |  exceed the height of the image...
+--+

I hope that doesn't come out too mangled, but you get the picture.  
I'm mostly worried about the two text fields, since the image could  
probably go in a separate column.


How do I go about this?



This is a good piece of sample code to show how to create a complex  
custom cell subclass:


<http://developer.apple.com/samplecode/PhotoSearch/>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Garbage Collection woes...

2008-06-29 Thread j o a r


On Jun 27, 2008, at 12:31 PM, John Engelhart wrote:

Lesson #1:  If you have any interest in performance, you must avoid,  
at all costs, "writing" to a __strong pointer.



That's almost like saying:

	"If you have any interest in performance, you must avoid, at all  
costs, using a high level language like C."


It's only true if you ignore other things that are also both true, and  
that many consider to have a higher priority. For one, using higher  
level languages and libraries allows us to be more productive and to  
build software that delivers more functionality while at the same time  
being easier to maintain.




-(BOOL)doSomething:(id)obj error:(NSError **)error
{
 if(error != NULL) { *error = NULL; } // Make sure we clear the  
error object

}

It's sort of ambiguous as to what should be returned by the indirect  
error pointer on the condition of success.  I could think of several  
neat ideas if the expected behavior were defined up front, even  
requiring the caller to initialize the pointer to a default NSError  
singleton and allowing errors to accumulate in a stack like  
fashion.  Alas, the only clearly defined behavior is that one  
failure, a NSError object is indirectly returned.



The relevant documentation is found here:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/chapter_4_section_4.html#//apple_ref/doc/uid/TP40001806-CH204-SW5 
>


If you have suggestions for improvements, please file formal  
enhancement requests.



The write barrier penalty is substantial.  I benchmarked a tight  
loop that called a function that did nothing but the naive clearing  
of the value.  The result (on a 1.5GHz G4) was that it was 2429.55%  
(or, over 24 times) slower with -fobjc-gc enabled.  So, best to  
avoid updating a __strong pointer at any and all costs.



If you're a developer who cares about performance, your #1 priority is  
to implement the actual functionality. Your #2 priority to run  
meaningful benchmarks. Your #3 priority to address any performance  
problems that you find, in order of severity.


Synthetic / micro benchmarks are typically of limited value. Most  
Cocoa application developers will find that their performance problems  
are higher level and more algorithmic in nature, rather than on this  
very low level.




typedef struct {
 NSString *aString;
 __weak NSString *aWeakString;
 NSInteger anInteger;
} MYStructType;

MYStructType globalStructTypeArray[42]; // <-- Global!


The pointer to 'aString' in the above (or any of my other __strong  
pointers in my actual code) were clearly not being treated as  
__strong, and the GC system was reclaiming them causing all sorts of  
fun and random crashes.




Bugs are bad, and if you think that you have found one, it would be  
great if you could file a formal bug report.
That said, this is Cocoa-Dev, and the code above has very little to do  
with Cocoa / Objective-C development in practice.
Most Cocoa developers will find that Garbage Collection works  
absolutely fine, and that runtime performance is about the same  
(sometimes better, sometimes worse) compared with using manual memory  
management.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating AppControllers in InterfaceBuilder 3.1

2008-06-30 Thread j o a r


On Jun 30, 2008, at 7:14 AM, [EMAIL PROTECTED] wrote:

I'm writing my first project in Leopard and can't figure out how to  
accomplish the old
"Subclass NSObject/Generate Files/Instantiate" series of steps in  
Interface Builder 3.1.



What you typically do is to create the subclass in Xcode, and not in  
IB. Once you've done that, switch back to IB and drag in a generic  
NSObject from the Library (it looks like a blue cube). Hit Cmd+6 to  
open the identity inspector, and type the name of the class that you  
want to instantiate.




On Jun 30, 2008, at 7:20 AM, Tommy Nordgren wrote:

You create the files from an XCode file template, and drag the  
header file into IB



The thinking here is indeed that Xcode handles the creation of  
classes, while IB handles instances of classes and their  
configuration. The last part of that sentence is no longer required  
though: Xcode and IB are now on better speaking terms, so you don't  
have to manually tell IB to read header files for it to learn about  
changes to classes in the project, it stays up to date automatically.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Responder Chain and NSViewController in non-doc applications

2008-06-30 Thread j o a r


On Jun 30, 2008, at 9:52 AM, Jerry Isdale wrote:

Again, the NSViewController doesnt appear in the responder chain,  
unless it was designated by the initial Event Responder.  If it was  
designated, but doesnt respond, what happens? An Error or does it go  
back to the responder chain?



I'm not clear on what you mean by "designated by the initial Event  
Responder".



The NSViewController is a Responder, but the associated view does  
not patch it into the responder chain for either event or action  
responding. Correct?



Correct. Unless you manually insert it into the responder chain, in  
that case typically right after its view.



But if my design explicitly specifies the target (connecting  
IBActions in InterfaceBuilder), I dont have to worry about the  
Responder chain for actions.  Correct?



Correct.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie question: Timers

2008-06-30 Thread j o a r


On Jun 30, 2008, at 2:36 PM, Matthew Youney wrote:

In the VS environment, there is a “timer” control that can be  
dropped onto a
form, and will generate timer events every X milliseconds.  How  
would I
impliment similar functionality in Cocoa, or what would you gurus  
suggest

that I look into?  What is best?



There is no way to do that in IB, you would have to set up the timer  
in code, but that's easy enough - Check the documentation for the  
NSTimer class. What are you going to use the timer for? There might be  
something else that would be better for you to use in Cocoa.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Importing Xcode 2.x projects into Xcode 3

2008-07-08 Thread j o a r


On Jul 8, 2008, at 6:03 PM, John Joyce wrote:

Are there any caveats when importing an XCode 2.x project into XCode  
3?

I seem to have NIBs that are no longer connected properly...
It could be something I did (or did not do properly), but just  
curious if anybody else has had any issues.



I think that would be considered a bug in IB 3, and not an expected  
side effect. If you can verify that this is the case, and in  
particular if you can reproduce the problem, you should file a bug  
report here:


<http://developer.apple.com/bugreporter/>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem on reload data source of a table view

2008-07-15 Thread j o a r


On Jul 15, 2008, at 10:17 AM, JArod Wen wrote:

Thanks for fast reply! Just as Jens said, I have checked the table  
and I am sure that it is not nil:


Printing description of dataTable:

(gdb) continue



You should probably also verify that the NSTableView knows where to  
get data from - Using the "dataSource" property of the table view. At  
this point it sounds like a good thing to double-check that this  
connection is set up properly in IB.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem on reload data source of a table view

2008-07-15 Thread j o a r


On Jul 15, 2008, at 10:36 AM, JArod Wen wrote:

The dataSource of TableView is connected to tableSource. There is a  
TableController containing two IBOutlets to both tableSource and  
dataTable. Then dataTable.dataSource is connected to tableSource in  
IB. Anything I lost here?



You might want to verify, at runtime, that this connection is set. You  
can do this either in the debugger, or just using a standard debug log  
statement.


Btw.: Have you set up any bindings for this table view?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Blue lines

2008-07-15 Thread j o a r


On Jul 15, 2008, at 5:31 PM, Andrew Thompson wrote:

How do Interface Builder and Quartz Composer draw the blue line  
connections

from object to object?
I have been looking through the APIs, but I can't find anything that  
looks

right.

I thought of just drawing my own line on a custom view (shouldn't be  
that
hard), but interface builder manages to do it between objects that  
aren't

connected by ANY view, and I am not sure how to do that.



IB probably uses one or more separate transparent windows to hold the  
connection lines.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Attributed string to an Image without window

2008-07-16 Thread j o a r


On Jul 16, 2008, at 9:59 AM, Nethan Aryan wrote:

I have to write a command line utility which will create an image  
from another source image by adding some attributed text onto the  
source image.



Before thinking about how you would implement this, you should read  
about the concept of "daemon-safe frameworks":


	<http://developer.apple.com/technotes/tn2005/tn2083.html#SECLAYEREDFRAMEWORKS 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: just don't get it...

2008-07-17 Thread j o a r


On Jul 17, 2008, at 2:24 PM, Nick Zitzmann wrote:

How on earth to I communicate with an object that has been  
instantiated by Interface Builder???


Declare an IBOutlet pointer connecting an instantiated class to the  
instantiated object. Then read the instantiated class's header file  
into IB, which is normally done automatically, but you may have to  
do it manually if you're working on a framework.



...but note that this is not how James would solve the concrete  
problem mentioned in the original message.


In a document based application you don't have "the document", you  
have any number of documents. The AppDelegate doesn't just want a  
reference to any document, it's looking for some specific document.  
Typically that would be the document associated with the "main  
window" (check the documentation for more on what "main" and "key"  
window is in Cocoa). You could find that document like this:


    NSApp > Main Window > Window Controller > Document


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread j o a r


On Jul 18, 2008, at 11:51 AM, Andy Lee wrote:


I don't see the difference from the caller's point of view.



There isn't any, and that was not MMalcs point. His point was that you  
were using the term "autoreleased" incorrectly.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: observers removed?

2008-07-27 Thread j o a r


On Jul 27, 2008, at 7:36 PM, James Maxwell wrote:

Stupid question, probably, but if an object is deleted, is it  
automatically removed as an observer of notifications? Or should I  
write a removeObserver into my dealloc?



If you're talking about NSNotification/Center, then the answer is: "It  
depends".
If you're using GC, you wouldn't have to remove the observer. If  
you're not using GC, you would.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: IKSlideshow Question

2008-08-07 Thread j o a r


On Aug 5, 2008, at 5:37 PM, Robert McCullough wrote:

The IKSlideshowDataSource protocol for IKSlideshow includes several  
optional methods, one of which is "nameOfSlideshowItemAtIndex".  
However, this method NEVER seems to be called. Anyone know why?



I think that it's simply a bug - most likely a very well known bug.
You might still want to file a bug report to indicate interest in  
getting this API fixed for some future release.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Get specified window from nib

2008-08-11 Thread j o a r


On Aug 11, 2008, at 8:08 PM, Fosse wrote:


In fact, in my another application, there are more than one hundred
windows.. split them into one hundred nib? and create one hundred  
Outlet?


Seems a little too crazy!



Over a hundred different windows seems a little crazy too   ;-)

If you describe your application, and your use of nib files, it might  
be that we could provide some suggestions for cutting down on that  
number.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to implement the auto-complement function like Xcode 3.x?

2008-08-13 Thread j o a r


On Aug 12, 2008, at 8:24 PM, Leopard x86 wrote:

Then here comes the question: how can we implement this function for  
our editor-like application?
Because I am working on an editor project which concerns about the  
user experience,  I think the auto-complement function is an  
indispensable one. Moreover, the Xcode-style of auto-implement is  
exactly what I want. This feature can improve the efficiency and  
productivity of users greatly.



Have a look at the NSTextView "- 
textView:completions:forPartialWordRange:indexOfSelectedItem:"  
delegate method.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: @try @catch

2008-08-14 Thread j o a r


On Aug 14, 2008, at 5:34 PM, Andrew Farmer wrote:

Python has been optimized to handle exceptions quickly, so it's  
often faster to catch exceptions than to check for exceptional  
situations in Python code. Objective-C has not been similarly  
optimized*, so checking for errors before attempting operations will  
be much faster than catching exceptions unless the exceptions are  
exceedingly rare.


*: Or, more accurately, the overhead of setting up exceptions is  
much higher compared to the overhead of checking for situations that  
would trigger them.



The cost, and where you pay it, depends on many factors: The type of  
exceptions handler you use, and the version of Mac OS X and the  
version of the Objective C runtime you happen to execute on.


That said, and has been pointed out earlier in this thread, the  
decision to use exceptions for control flow or not is not simply one,  
perhaps not even primarily one, of performance considerations.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Clearing a Memory Buffer?

2008-08-18 Thread j o a r


On Aug 18, 2008, at 6:19 AM, Dave wrote:

I'm fairly new to Cocoa and was wondering if there are OS functions  
to Copy and Clear/Fill Memory available?



In addition to the lower level C API:s that have been mentioned so  
far, there is also the object oriented Cocoa NSData + NSMutableData  
API:s that might provide some / all of what you're looking for.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Question about respondsToSelector

2008-08-18 Thread j o a r


On Aug 18, 2008, at 11:17 AM, Carmen Cerino Jr. wrote:

Does the id type have enough information for the respondsToSelector  
method to work. I have a class with an ivar of type id, and when I  
invoke the respondsToSelector method it fails when it should  
succeed. I am assuming it should work fine, because if I skip  
checking with the respondsToSelector method and just make the call,  
it executes the method. Can someone please tell me what I am doing  
wrong?



Perhaps you've misspelled the name of the selector - just like you've  
done above with "respondsToSelector:" (note the trailing ":").


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: passing an object between views

2008-08-19 Thread j o a r


On Aug 19, 2008, at 5:31 PM, John Greene wrote:


Hopefully this is a generic enough question that it applies to general
Cocoa development:  How do I pass an object between views?  That is: I
have an array of objects that I've built using NSXMLParser, and that
populates a table, and clicking on a cell changes my view to another
table with a separate controller.  I had originally thought that I  
could

just write a method, setTableData in the secondary controller, that
takes an object as an argument, and then use that object to build the
secondary table.  This is apparently forbidden by the language, so
what's the proper approach?  I could make the array available  
somehow to
the new controller, since I can pass the integer index, but I'm not  
sure

how!



It sounds like you might be trying to implement a Master-Detail  
Interface. Possibly.


If so, you might have a look at this:

	<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Tasks/masterdetail.html 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: !foo vs foo == nil

2008-08-20 Thread j o a r


On Aug 20, 2008, at 4:56 PM, John C. Randolph wrote:

Personally, I prefer "if (!foo)" over "if (foo == nil)", because the  
latter has the hazard of a typo that compiles.  You can lose a fair  
bit of time staring at "if (foo = nil)" before you spot the mistake.



There is a GCC warning to help you with that, but in addition, you can  
learn to type:


if (nil == foo)

Problem solved!   :-)

I personally much prefer to have if-statements that clearly evaluate  
to a boolean value. More intention revealing, and to me that's more  
important than being terse.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSWindowController, owner, "primary window"...

2008-08-21 Thread j o a r


On Aug 21, 2008, at 10:12 AM, Negm-Awad Amin wrote:

Probably because the GoF prefers combination over (?) subclassing.  
Subclassing always discloses parts of the implementation of a class.  
("white-boxing") So generally it is a good idea, to look for  
alternatives for subclassing, esp. delegates.



You are right in that Cocoa programmers often look to other design  
patterns before choosing to subclass one of the framework provided  
classes. That said, NSWindowController is one of the classes in Cocoa  
designed and intended to be subclassed, so that's not a consideration  
in this particular case.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Undocumented Leopard support for overlapping sibling views

2008-08-28 Thread j o a r


On Aug 28, 2008, at 1:28 PM, Nathan Vander Wilt wrote:

According to two list postings (http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg01760.html,http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg01764.html 
) both by Apple employees, overlapping sibling subviews are fully  
supported in Leopard (and presumably beyond).


However, the official documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/chapter_5_section_5.html 
) still says:
"Cocoa does not enforce clipping among sibling views or guarantee  
correct invalidation and drawing behavior when sibling views  
overlap. If you want a view to be drawn in front of another view,  
you should make the front view a subview (or descendant) of the rear  
view."


And Interface Builder 3.1 on the one hand has options like "Layout >  
Send to Front" that change the ordering of subviews, yet on the  
other still warns about "Illegal geometry" when a view overlaps one  
of its siblings even when the deployment target is set to 10.5.



I can't find anything in the documentation (or even release notes)  
that describes that/how overlapping views are supported. Why isn't  
this documented? Can we rely on overlapping sibling views working  
now and in the future? Are there any caveats we should be aware of?



Hello,

Please file a couple of bug reports on this:

<http://developer.apple.com/bugreporter/>

Thanks!

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread j o a r


On Aug 29, 2008, at 9:56 AM, Michael Ash wrote:


It really just needs to be unique in your class hierarchy, right?


True, but not particularly useful. Your class hierarchy includes
NSObject, which is free to observe whatever it feels like in your
objects.



No this is not generally true, so just forget about that and instead  
ensure that the context pointers are globally unique.




If you use a constant string, you should make sure that the
string *contents* are unique, in order to ensure uniqueness of the
pointer to it. So don't call it @"context", use @"MyFunkyClass KVO
observer context". After all there's no penalty for being verbose in
this case. Of course using a pointer to a global solves this too.



The penalty for using constant strings is that they will end up  
wasting space in your binary...

Rons suggestion is probably optimal.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating movie on background thread

2008-09-02 Thread j o a r


On Sep 2, 2008, at 12:55 AM, Roger Herikstad wrote:


Since the Carbon stuff is not 64 bit



Not correct: Some of it is, some of it isn't. Read the API reference  
documentation and release notes to figure out which is what. Besides,  
QTKit is a Cocoa framework.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating movie on background thread

2008-09-02 Thread j o a r


On Sep 2, 2008, at 1:14 AM, Roger Herikstad wrote:

But I do need the Carbon headers to use the functions  
AttachMovieToCurrentThread, DetachMovieFromCurrentThread, etc, no?



It doesn't seem like that's the case:

"With Mac OS X 10.5 and QuickTime 7.3 or later installed, QTKit  
provides the framework level support that is required to use QTKit  
objects on background threads. This includes the ability to tell QTKit  
when you want to use a QTMovie instance on a background thread, when  
you're attaching or detaching a QTMovie instance from the current  
thread and also allows control of the QTMovie idle state."


<http://developer.apple.com/technotes/tn/tn2125.html>

I'm not an expert on this - you might want to consult a QT specific  
mailing list for a definitive answer.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSDate autorelease problem

2008-09-03 Thread j o a r


On Sep 3, 2008, at 10:02 AM, [EMAIL PROTECTED] wrote:

I'm trying to calculate the elapsed time by calling this twice and  
getting the difference.


double Seconds()
{
  return [[NSDate date] timeIntervalSince1970];
}



How about replacing that with:

return [NSDate timeIntervalSinceReferenceDate];

That said, I would bet that there are simple C APIs that would be more  
efficient to use for this purpose.



This is being called from an audio play back proc which is being  
called about 100 times a second.  I'm getting this error message in  
the log window a whole bunch of times.


2008-09-03 09:39:30.766 App[321] *** _NSAutoreleaseNoPool(): Object  
0x36acd0 of class NSCFDate autoreleased with no pool in place - just  
leaking



The reason is that you're executing the code above on a non-main  
thread. See the documentation for NSAutoReleasePool for details (or  
just use Google), but in general:


"Cocoa expects there to be an autorelease pool always available. If a  
pool is not available, autoreleased objects do not get released and  
you leak memory. NSAutoreleasePool objects are automatically created  
and destroyed in the main thread of applications based on the  
Application Kit, so your code normally does not have to deal with them."


On threads that you set up, you have to manage the top level  
autorelease pool manually.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: when should my NSWindowController be released?

2008-09-13 Thread j o a r


On Sep 13, 2008, at 1:43 PM, Markus Spoettl wrote:

Not true, I can think of many scenarios where you have no other  
choice.



Like what? Seth is right in general, app termination is very much a  
special case.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSUInteger in for-loop?

2008-09-14 Thread j o a r


On Sep 14, 2008, at 9:15 PM, Alex Reynolds wrote:

I'm wondering if I'm using unsigned integers (specifically  
NSUInteger) properly or not.


I was under the impression that unsigned integers run from 0 to  
MAX_INT, but when I use them in a "for" loop within these bounds,  
the loop does not seem to always obey these constraints.


For example:

for (NSUInteger counter = 5; counter >= 0; --counter)
{
NSLog(@"NSUInteger: %d", counter);
}

keeps running well after the "counter" variable turns negative:



NSUInteger runs from 0 -> NSUIntegerMax.

This is how you print a NSUInteger:

NSLog(@"NSUInteger: %lu", ((unsigned long)counter));

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create a new window initially zoomed to the maximal size?

2008-09-20 Thread j o a r


On Sep 20, 2008, at 11:02 AM, Oleg Krupnov wrote:


What I want to achieve is that when a new window is created, it has
the maximal size allowed by the screen, menu and the dock, exactly
like if someone clicked the green zoom button in the window's title
bar. I don't want any resizing animation or flickering though.



You would have to resize the window manually. To find out how to size  
and position it, ask NSScreen for the appropriate frame. To avoid  
flickering, do this in "awakeFromNib" or similar, before the window is  
put on screen.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create a new window initially zoomed to the maximal size?

2008-09-20 Thread j o a r


On Sep 20, 2008, at 11:11 AM, Benjamin Stiglitz wrote:

Alternatively, you can set its frame to [[window screen]  
defaultFrame], which is the same frame

that -zoom: will use, subtracting space for any visible drawers.



I think that should be:

"-[NSScreen visibleFrame]"

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: unrecognized selector sent to instance

2008-09-26 Thread j o a r


On Sep 25, 2008, at 4:01 AM, pan xuan wrote:

Hi, I am having a strange problem of my class declaration. I used to  
declare some methods of a class in a category, "Private". After I  
have done some refactoring work (basically moving some classes into  
another framework), it seems those methods declared in the category,  
"Private" do not belong to the object anymore. If I load the code in  
my debugger and try to invoke a method declared as "Private", the  
program receives a doesNotRecognizeSelector error and crashes after  
receiving the signal SIGTRAP. And if I move those methods into the  
main implementation of the class, it all works out. Any idea why is  
that? Thanks for your help. BR, Pan



Perhaps a memory management error somewhere? Try to run your app with  
NSZombieEnabled (Google for the details) and see what that turns up.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [NSCFNumber intValue]: unrecognized selector

2008-09-26 Thread j o a r


On Sep 25, 2008, at 6:22 AM, Steve Rossi wrote:

I've deduced that he crash seems to be something timing related  
which occurs only at application startup, and only under certain  
conditions (i.e. reproduce occassionlly by opening an NSOpenPanel  
modal dialog before the application is fully up and running). When I  
say the application is fully up and running, I mean a secondary  
thread has retrieved data from a network source and populated a  
model class. This secondary thread cyclically updates the data about  
8x per second by means of a timer in the secondary thread's run loop.
I use Cocoa bindings to display the data in the UI. I'm sure the  
problem is happening in the bindings, but I'm having trouble finding  
where.



In the general case, and with few exceptions, you can't call your UI  
on non-main threads. This means that you can't drive UI updates based  
on KVO notifications from non-main threads. Could this be your problem?


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: sending email with attachement from cocoa

2008-09-26 Thread j o a r


On Sep 26, 2008, at 10:03 AM, Alexander Cohen wrote:

Is there a way to use a url request to open mail with all its fields  
completed but most importantly, contain an image attachement?



Not using the frameworks provided by Apple.

Your problem, in particular, is that you can't assume that all users  
are running the same email client.


There are some third party attempts at solving this problem -> Google.

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [NSCFNumber intValue]: unrecognized selector

2008-09-26 Thread j o a r


On Sep 26, 2008, at 4:36 PM, Steve Rossi wrote:

Yes, that is correct. A separate thread is spawned which updates the  
model - consequently driving UI updates based on KVO notifications.
It is the only thread that is updating the model - the main thread  
does very little except respond to fairly minimal UI events.
It works very reliably it seems ... except on these occassions when  
the OpenPanel is opened from the main thread.



That might appear to be the case on your machine, on this version of  
your application, and on this version of Mac OS X - But as soon as you  
change any of these variables, it might well start to fall apart.



I can think through whether I really need that separate thread. But  
is there a way to make the model updates from the 2nd thread safe?



If you're doing blocking work, having it on a separate thread is  
probably a good thing - But you need to forward your UI updates to the  
main thread. That's typically easy to do using  
"performSelectorOnMainThread:"



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: large documents with doc based app

2008-03-05 Thread j o a r


On Mar 6, 2008, at 12:19 AM, Torsten Curdt wrote:


But according to the docs NSData is limited to 2GB.
What I am wondering is... How can one handle files larger than 2GB?



Override the path / URL based methods from NSDocument instead, and  
read the interesting portions of the files piece-by-piece. You  
typically don't want to load all of it into RAM at once.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Deferring a selector until later, but before painting

2008-03-05 Thread j o a r


On Mar 6, 2008, at 2:12 AM, John Stiles wrote:

Right now in my app, there are some controls which appear and then  
their state changes a fraction of a second later, and I'd like to  
avoid the visually jarring "pop" effect of a control which changes  
itself right after first appearing, but I can't find an easy way to  
avoid deferring some operations.



How about delaying adding the control until the value you want to  
display in the control is "ready"?


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Deferring a selector until later, but before painting

2008-03-06 Thread j o a r


On Mar 6, 2008, at 8:32 AM, Ken Ferry wrote:


Or can you do your final setup in -viewWillDraw?

For some kinds of problems, you could synchronously mark whatever  
state you're interested as invalid, then resolve any invalidated  
state in -viewWillDraw.  This would be an appropriate way to do  
deferred layout, for example.



I think it's unfortunate to have to resolve to subclassing for this  
type of problem - The OP might end up having to subclass several  
different NSControl subclasses to make it work. Perhaps NSView should  
provide some sort of notification or delegation scheme to supplement  
this method?


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to set Document Icon when saving

2008-03-06 Thread j o a r


On Mar 6, 2008, at 4:23 PM, Lincoln Green wrote:


How do you set the document icon?


Typically you don't. The Finder will query Launch Services and  
automatically associate your documents with the correct icon based on  
the information found in your applications property list - And also  
based on user preferences, in the case of a shared document type with  
multiple possible applications to choose from.


See for example:

<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Concepts/DocTypePList.html#//apple_ref/doc/uid/2024-BHADAGHF 
>


<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Tasks/ImplementingDocApp.html 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread j o a r


On Mar 11, 2008, at 3:03 PM, Kevin Dixon wrote:

I'm using an NSTableView, and I want to be able to remove items from  
the
list by pressing the delete key on the keyboard. What is the  
procedure to

receive a message when a key is pressed and the table view has focus?



Subclass NSTableView and override "-keyDown:". There should be several  
implementations of this online that you could take a look at.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread j o a r


On Mar 11, 2008, at 3:49 PM, Quincey Morris wrote:

Personally I prefer the factory method approach, a la [NSArray  
array] etc:



Note that factory class methods typically also return id for the same  
reason that init methods return id (NSArray, NSString, et.c.).


This in contrast to shared instances that are strongly typed  
(NSFileManager, NSHost, NSNull, et.c.).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread j o a r


On Mar 11, 2008, at 5:47 PM, Kevin Dixon wrote:






to catch the pressing of delete on the NSTableView. This works, but
reminds me of BASIC...Is there a better way to do this, to make sure  
I'm

getting the delete key, say even on international keyboards?



See "NSDeleteCharacter" and similar in NSText.h (and in the  
documentation).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: XCode3 errors on startup

2008-03-18 Thread j o a r


On Mar 18, 2008, at 10:29 AM, Steve Cronin wrote:

When I start XCode3 in Leopard I am seeing the following in  
Console.app.

Any ideas on what is going on?



This question belongs, and has been answered, on Xcode-Users:

<http://www.cocoabuilder.com/archive/message/xcode/2007/11/7/16930>

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting notifications when any file in a folder change

2008-03-18 Thread j o a r


On Mar 18, 2008, at 11:07 AM, Mr. Gecko wrote:

Hello I am wondering how to get my program to notice when a file  
changes in a folder.



See:

<http://developer.apple.com/documentation/Darwin/Conceptual/FSEvents_ProgGuide/ 
>
<http://developer.apple.com/documentation/Darwin/Reference/FSEvents_Ref/FSEvents/index.html 
>


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Intercepting retain/release of object

2008-03-21 Thread j o a r


On Mar 21, 2008, at 11:13 AM, Scott Ribe wrote:
If you really want to understand what's going on, forget the counts,  
set
breakpoints on your overloaded retain & release methods, then look  
at the
stack trace every time. It may take a while, because there may be a  
lot
going on behind the scenes, but it's one way to get an  
understanding. (Also

add an override for autorelease.)



A much, much, better way of doing that would be to use the Object  
Allocations instrument.


j o a r

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How do I disable this warning: "local declaration of 'varname' hides instance variable"

2008-03-23 Thread j o a r

Chuck,

* You really shouldn't suppress these warnings

* If you use ObjC 2.0 properties you don't have to write those  
accessors in the first place, and


* If you use ObjC 2.0 properties, you can use this form without  
warnings:


self.foo = foo;

j o a r


On Mar 23, 2008, at 8:59 PM, charlie wrote:


For years, I've been doing this:

- (void)setController:(id)_controller
{
if (!_controller)
{
  return;
}
controller = [_controller retain];
}



It has always irked me having to work around namespace conflicts  
between method args and instance variables.


So, today I decided to try this for my next project...

- (void)setController:(id)controller
{
if (!controller)
{
  return;
}
self->controller = [controller retain];
}



I works fine.  But does not fix the warning itself.




So, the question stands How do I suppress the warning.


- Chuck


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to delay application quit?

2008-03-25 Thread j o a r


On Mar 25, 2008, at 9:26 AM, James Hober wrote:

Do you write the dealloc anyway?  Just wondering what others do.   
Personally I still write a dealloc method in a class for an object  
that I keep around for the life of the app.  Then I preface it with  
a self-amusing comment:


//actually this dealloc never gets called - the app just  
relinquishes all memory upon quitting.

//But just to keep things tidy...

I suppose this is utter superstition on my part.  Yet somehow I feel  
better that there are matching releases, etc. that never get called.


And of course, if the class were ever used not solely for a single  
object that lingers for the life of the app but for objects that  
come and go, then the proper memory management is in place.



I wouldn't recommend doing that. I'd suggest using something like this:

- (void) dealloc
{
NSAssert(FALSE, @"Singleton objects should never be released");
[super dealloc];
}

This communicates better what your intention is, and also catches the  
unlikely case of this instance ever being deallocated when it  
shouldn't, or if the class is being repurposed to a multi-instance  
pattern.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to delay application quit?

2008-03-25 Thread j o a r


On Mar 25, 2008, at 3:19 PM, James Hober wrote:


On the other hand, the documentation for dealloc says:

"Note that when an application terminates, objects may not be sent a  
dealloc message since the process’s memory is automatically cleared  
on exit—it is more efficient simply to allow the operating system to  
clean up resources than to invoke all the memory management methods."


Since it says "may," theoretically it could be considered an  
implementation detail that dealloc is not called during termination  
and Apple could change things in a future release.  Admittedly, this  
is not very likely and admittedly worrying about code that almost  
certainly will never execute is probably not the best use of time.   
And yet it is very common to have a number of singleton objects of  
this kind in Cocoa apps.  So nearly all of us are "solving" this one  
way or another.



That's a valid argument, but I feel pretty confident that Apple  
wouldn't be able to make such a chance for existing binaries without  
creating havoc in the installed application base.


If they do change this, I would expect them to communicate it first,  
and then only actually update the behaviour for apps compiled on a  
newer version of the OS.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main Thread UI and Detached Thread

2008-03-31 Thread j o a r


On Mar 30, 2008, at 11:55 AM, Mike wrote:
In my worker thread I do a tight processing loop and one of the  
things I do in the loop is call two methods in the main thread to  
update the display (a text message and progress bar) - via  
performSelectorOnMainThread:withObject:waitUntilDone:modes.


However, when the loop runs in the spawned thread, the display  
doesn't get updated. If I insert a sleep(1) call into the loop, then  
the display  updates.



How much work do you perform on the main thread? If a lot, it's not  
unexpected that you would se interruptions in display updates. You  
might need to throttle or otherwise limit your callouts to the main  
thread if this proves to be the problem.


You can use Instruments or Shark to get a view of the work being  
performed on the main thread while you run your worker thread.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main Thread UI and Detached Thread

2008-03-31 Thread j o a r


On Mar 31, 2008, at 11:02 AM, Mike wrote:
I'm not doing any work on the main thread while the spawned thread  
runs. In fact, the main thread is just idling doing nothing. And the  
behavior isn't really a responsiveness issue: the rest of the UI  
still responds fine, but my indicators that I update in the UI do  
*nothing* the entire time the spawned thread is running. Nothing. No  
activity. If I take the sleep calls out, then main thread updates  
the UI instantly upon termination of the spawned thread.



You said that you're calling the main thread, so I expect it to do  
*something*...


How do you notify the controls in the UI that they need to update to  
reflect new values?

What is the total time required to run the task by your worker thread?

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main Thread UI and Detached Thread

2008-03-31 Thread j o a r


On Mar 31, 2008, at 12:20 PM, Mike wrote:
I have two methods in the main thread that I call from the worker  
using performSelector, etc. The method for updating the progress bar  
for example looks like this:


- (void)setProgressBarValue:(double)value
{
if( progressBar )
{
[ progressBar setDoubleValue:value ];

[ progressBar setNeedsDisplay:YES ];

[ progressBar display ];
}
}



Your calls to "-setNeedsDisplay:" and "-display" are basically  
mutually exclusive. You should typically not call "-display" directly.



This is a pretty simple app and I don't have time to dive into  
performance tools to discover why a single thread in a 10-page app  
isn't doing what it's advertised to do.



I don't think you're saving any time by not learning how to use the  
performance tools.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main Thread UI and Detached Thread

2008-03-31 Thread j o a r


On Mar 31, 2008, at 12:25 PM, Mike wrote:
I am doing nothing in the main run loop when th worker thread fires.  
The main thread is doing nothing but idling



This is not true, as you call to the main thread for display updates.



On Mar 31, 2008, at 12:28 PM, Mike wrote:

But my question is: why should I have to?
The docs say run all the UI on the main thread and notify the main  
thread from within the worker thread when the UI needs updating.



That should indeed be enough.

I think that you need to either post more code, or preferably a sample  
project that exhibits this problem, for us to be able to help you  
figure out what's wrong.



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main Thread UI and Detached Thread

2008-04-04 Thread j o a r


On Apr 4, 2008, at 12:08 AM, Mike wrote:
If that is the case then why does the progress bar get updated with  
the correct value every time when I insert the sleep( 1 ) call?  
Obviously it wouldn't be displaying the correct value if garbage was  
being sent to the selector.



I don't think it's constructive to take the discussion in that  
direction.
You should start out by fixing your code to pass objects - Perhaps  
something like this:


- (void) setProgressBarValue:(NSNumber *) value
{
NSLog(@"Bar: %@, Value: %f", progressBar, [value doubleValue]);
[progressBar setDoubleValue: [value doubleValue]];
}

Like I said earlier, I think that you would benefit from posting a  
sample project that reproduces the problem.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Menu Key Equivalents Not Displayed

2008-04-06 Thread j o a r


On Apr 6, 2008, at 12:01 PM, Jonathan Dann wrote:
However the command-G does not show up on the menu.  The same  
happens if I set the key equivalent to @"p", @"q" and some others,  
but equivalents like @"u" and @"b"  work fine.  Can anyone verify  
this for me please as I think I'm going mad.



Sounds like some sort of conflict with keyboard shortcuts used by menu  
items in the main menu?


(g -> find next, p -> print, q -> quit, et.c.)

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Menu Key Equivalents Not Displayed

2008-04-06 Thread j o a r


On Apr 6, 2008, at 12:37 PM, Jonathan Dann wrote:

Yeah I thought that, but couldn't see where g was defined.



Typically under Edit > Find


Any idea why it works in other contextual menus, including the main  
menu?



Please file a bug report and ask for improved documentation:

<http://developer.apple.com/bugreporter/>

j o a r



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to replace image contents?

2008-04-09 Thread j o a r


On Apr 9, 2008, at 8:02 PM, Samvel wrote:
It was a general thought. I am programming in Objective-C only for  
about month and was wondering if there is any faster way to replace  
image/string/etc. contents instead of reallocating object itself.



Being concerned about performance is a good thing, but like Bill  
suggested, in the vast majority of cases you should start out with  
getting hard performance data from our performance tools.


If you're new to our platform (Welcome!) it's likely that you haven't  
had a chance of using performance tools like Shark or Instruments  
before. They're both very good, and also relatively easy to learn and  
use. I strongly suggest that you spend some time on getting to know  
them.


You can find information both on developer.apple.com, and elsewhere on  
the web using Google. If you have a chance of attending WWDC, that's  
obviously also a really good place to learn more about our tools - and  
everything else related to development on the Mac.


Cheers,

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: ObjC static member variable

2008-04-10 Thread j o a r


On Apr 10, 2008, at 12:42 PM, vance wrote:

Yes that works but then it becomes a global variable.



It's static, so it's local to the module being compiled.


I was wondering if ObjC can handle static member variables. If not I  
will have to hack it up and declare the variable outside of the class



No, ObjC doesn't have any support for static member variables.

j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: ObjC static member variable

2008-04-10 Thread j o a r


On Apr 10, 2008, at 12:48 PM, j o a r wrote:

No, ObjC doesn't have any support for static member variables.



Btw. For ObjC I think it would be more appropriate to call them "class  
variables".



j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting line numbers from an NSString

2008-04-11 Thread j o a r


On Apr 11, 2008, at 10:23 AM, allan greenier wrote:
If I have an NSString that is multi lined (say in contains "\n"  
characters)
is there an api call so I can get line 0, line 1, ect? Or should I  
just code that myself?



There is no "NSLineEnumerator" (although that would be a very cool  
addition), you basically have to do it manually.


NSString has a method to help you identify line endings in case you  
have to deal with files that could use different characters /  
character sequences to represent that (\n, \r, et.c.).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


  1   2   >