Re: Problem with friend function and gcc 4.2 with

2008-08-11 Thread Ken Worley
First, I appreciate the response and discussion. Thank you. My  
response is not meant to be argumentative, but I'd like to get to the  
bottom of this.


The main thrust of that discussion (on bytes.com) seems to be that  
since the friend function is both declared and defined inline within  
the class test1 declaration, that it is trapped in test1's namespace  
and only usable from within the class. At least, that's the way I  
understand the discussion.


FWIW, using gcc 4.2, and it turns out it doesn't matter if I'm  
compiling the file as C++ or objective-C++, the following both fail  
with the same compile error:


1. Trying to call newtest1 from within a method of test1

2. Calling the friend function like this: test1* newobj =  
test1::newtest1(5); from within main.


So, in what circumstance _would_ I be able to call that friend  
function? It's not usable from within another method of that class and  
it is apparently not callable from outside the class without  
duplicating the function prototype outside the body of the class.  
Duplicating the prototype outside the class declaration DOES allow the  
example to compile (whether it's added before or after the class  
declaration).


So, is there some exception for operator friend functions? I can add  
an operator friend function declared and defined inline within the  
body of the class declaration (just like the newtest1 friend  
function). That type of friend function compiles and works just fine  
and is callable from main...


So I'm confused. The compiler allows the friend function to be  
declared and defined inline within the class declaration, but I'm not  
allowed to call it from anywhere without another declaration of the  
prototype elsewhere. That doesn't seem right to me, but I'll concede  
that it might be. If that's the case, then there must an exception for  
friend operators or that's another bug in the compiler except this  
one's not fixed in gcc 4.2.


Ken

On Aug 10, 2008, at 2:13 PM, Roni Music wrote:



You can read a discussion regarding this problem here:
http://bytes.com/forum/thread828536.html

it seems gcc 4.0 had a bug which is corrected in gcc 4.2



Message: 12
Date: Sat, 9 Aug 2008 09:36:17 -0600
From: Ken Worley <[EMAIL PROTECTED]>
Subject: Re: Problem with friend function and gcc 4.2 with
To: cocoa-dev cocoa-dev 
Cc: Roni Music <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

FWIW, it does in fact compile in 4.2 (and in 4.0) when formatted as
you suggest. I still believe the original format is correct and that
4.2 is the version with the bug. The info Clark Cox pointed out seems
to support that. In any case, a bug has been filed, so I'll know
Apple's point of view eventually :) Thanks for the input (and thanks
also to Clark and Thomas for responding).

rdar://6135771

Ken

On Aug 8, 2008, at 10:42 PM, Roni Music wrote:



I'm not a C++ expert but your code below should not compile (as I
see it)

You should declare the friend function inside the class:

class test1
{
public:

friend test1* newtest1(int x);
/*
the function newtest1() is now a friend to test1 class and may
access private member variables
and functions such as finishinit()
*/

snip
};

then define the function outside the class:

test1* newtest1(int x)
{
test1* anobj = new test1();
anobj->finishinit(x);
return anobj;
}

So if you code worked with gcc 4.0 and not gcc 4.2, then it seems
gcc 4.2 now works according to the C++ standard
and gcc 4.0 did not

Rolf





Message: 10
Date: Fri, 8 Aug 2008 16:41:42 -0600
From: Ken Worley <[EMAIL PROTECTED]>
Subject: Re: Problem with friend function and gcc 4.2 with
objective-c++
To: cocoa-dev cocoa-dev 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
delsp=yes

Hmmm, no response as of yet. I went ahead and submitted a bug  
against

Xcode: rdar://6135771
We'll see what happens.

Ken
On Aug 7, 2008, at 4:09 PM, Ken Worley wrote:


Hi all,

I'm using Xcode 3.1 and just switched to gcc 4.2 from 4.0, but  
I've

run into a problem with friend functions when compiling in
objective-
c++. I contrived an example that illustrates the problem:

1. Created new Cocoa project
2. Forced compilation of all files to use objective-c++
3. Changed content of main.m to below...

This project builds fine using gcc 4.0, but when I switch the
compiler setting to use gcc 4.2, I get the errors listed below.  
Any

clues would certainly be appreciated if I'm doing something wrong.
If not, I guess I'll file a bug...

Here's main.m:

#import 

class test1
{
public:

friend test1* newtest1(int x)
{
test1* anobj = new test1();
anobj->finishinit(x);
return anobj;
}

virtual ~test1()
{
}

private:

int avalue;

test1()
{
avalue = 0;
}

void finishinit(int x)
{
avalue = x;
}
};

int main(int argc, char *argv[])
{
test1* tobj = newtest1(5);
delete tobj;

 return NSApplicationMain(argc,  (const char **) argv);
}


Here's t

Re: Lazy Loading of images

2008-08-11 Thread Johannes Fahrenkrug
Kyle,

Thank you very much, that was what I needed to know!!

- Johannes

On Sun, Aug 10, 2008 at 8:09 PM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:
> On Fri, Aug 8, 2008 at 9:52 AM, Johannes Fahrenkrug
> <[EMAIL PROTECTED]> wrote:
>> I'd like to display placeholder images until the table cell gets
>> displayed and then load the actual thumbnail, replacing the
>> placeholder image with the real thumbnail once it has loaded.
>> What would be the best way to do this? I'm thinking of something on
>> the lines of a proxy object...
>
> Are you using the NSTableView data source API?  I think that would be
> easier for what you want to do.  I'd create a placeholder NSImage at
> first, and when I'm asked for the data for my NSImage column, if I
> haven't yet finished downloading the image for that particular row,
> give the NSTableView my placeholder image.  Then, once the image has
> finished downloading, call [myTableView
> setNeedsDisplayInRect:NSIntersectionRect([myTableView
> rectForColumn:indexOfImageColumn], [myTableView
> rectForRow:rowOfUpdatedItem])].
>
> Remember that the rows of an NSTableView don't actually exist as one
> large dataset, so there isn't a one-to-one table cell to NSCell
> correspondence.  Instead, each NSTableColumn has its own cell, that it
> uses like a rubber stamp.  When a region of the table is marked as
> dirty (setNeedsDisplay:/setNeedsDisplayInRect:), the table view
> figures out which columns are affected, and tells them to draw
> themselves.  Each column then asks for the data for each table cell
> that needs to be redrawn, and passes this value off to the NSCell
> assigned to that column, which does the real drawing.
>
> So your image column has an NSImageCell.  When you start scrolling,
> the NSTableView figures out which logical row and column numbers have
> just been revealed by your scrolling maneuver, and kicks off the above
> process.  Your data source is asked "alright, row 12 column 2 needs to
> be painted, gimme the data", and then hands that data off to the cell
> belonging to the column.  The dirty little secret is that from the
> table view's perspective, there aren't actually any rows at all; it
> just does a bunch of math based on where the scroll point is located
> to convert graphics coordinates to logical rows.  Your data source is
> none the wiser.
>
> --Kyle Sluder
>



-- 
http://blog.springenwerk.com
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSImage and zooming PDFs vs. bitmaps

2008-08-11 Thread Hamish Sanderson

On 8 Aug 2008, at 17:53, Ken Ferry wrote:


The correct answer is to call setDataRetained:YES on your image.
However, there may be a bug in Leopard and previous with NSImage cache
expiration that prevents that from being enough.  If you seem to be
hitting it, you can probably work around it by additionally turning
off caching entirely (setCacheMode:NSImageCacheNever) or maybe by
manually invalidating the image cache (-[NSImage recache]) when you
are changing the scale.


Yay! A combination of -setDataRetained: on image loading and -recache  
on zooming did the trick, although I did need to kludge in a size  
check before calling -recache as rasterising an entire PDF above  
~10,000x10,000 quickly gets painful performance- and memory-wise.  
Obviously there are ways to rasterise just the visible portion on an  
as-needed basis (c.f. PDFKit's PDFView), but I suspect this is non- 
trivial to implement so I'll see if users can live with the current  
resolution limit (which is still a big improvement from before).


Out of interest, is there an easy way to make NSImage retain and reuse  
these different sized cached representations rather than throwing them  
away each? At the moment, things get a bit sluggish every time you  
zoom into details; it'd be nice if it only had to be sluggish the  
first time. The NSImage API looks like it should be able to do this,  
but I'm having trouble getting my head around it. Any pointers?


Many thanks,

Hamish
--

Hamish Sanderson
Production Workflow Developer
Sun Branding Solutions Ltd
Tel: +44(0)1274 200 700
www.s-brandingsolutions.com




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArrayController's selectedIndexes

2008-08-11 Thread Negm-Awad Amin


Am Sa,09.08.2008 um 09:32 schrieb Ryan Brown:

Never mind, the "(Missing) KVO notification old and new values"  
section on mmalc's Cocoa Bindings Examples and Hints confirmed that  
this is a bug. It mentions that this won't be fixed for the  
forseeable future... could someone elaborate as to why?

Hi,

it is, because there is no reason to do it.
- You can retrieve the new value with -infoForBinding: + KVC.

NSDictionary* bindingInfo = [self infoForBinding:@"boundProperty"];
id newValue = [[bindingInfo objectForKey:NSObservedObjectKey]  
valueForKeyPath:[bindingInfo objectForKey:NSObservedKeyPathKey]];



- you can retrieve the old value from your ivar. Remember: Binding  
means, that a property of the bound object synchronizes with a  
property of an observed object. So the value of your property at the  
beginning of -observeValue:… is the old value:


id oldValue = [self boundProperty];

Amin



Ryan

On Aug 9, 2008, at 12:24 AM, Ryan Brown wrote:


When I observe an NSArrayController's selectedIndexes key like so:

- (void)awakeFromNib {
	[arrayController addObserver:self forKeyPath:@"selectionIndexes"  
options:(NSKeyValueObservingOptionNew |  
NSKeyValueObservingOptionOld) context:nil];

}

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
  change:(NSDictionary *)change
 context:(void *)context {
NSLog(@"change: %@", change);
}

I'm never seeing the old and new indexes. I always see output like:

2008-08-09 00:14:04.513 test[12498:10b] change: {
  kind = 1;
  new = ;
  old = ;
}

[arrayController selectedIndexes] gives the correct new value. A  
table view is bound to the array controller in a typical  
configuration (selectedIndexes is bound to the array controller).


Any ideas?

Ryan
___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTokenField with plain text

2008-08-11 Thread Chris Idou
I've seen programs where a NSTokenField allows plain text interspersed with 
tokens. But when I use NSTokenField it insists on making all text that is 
entered to be part of a token. How do I restrict the set of allowable tokens 
and make anything else entered to be just plain text?





  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSTokenField with plain text

2008-08-11 Thread Chris Idou
I've seen programs where a NSTokenField allows plain text interspersed with 
tokens. But when I use NSTokenField it insists on making all text that is 
entered to be part of a token. How do I restrict the set of allowable tokens 
and make anything else entered to be just plain text?





  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Sort Descriptor problem in NSTableView

2008-08-11 Thread Graham Cox
I have a table view where one column's strings are sorted using  
(NSCaseInsensitiveSearch | NSNumericSearch). To do this I use  
compare:options: on the strings.


I'd like to be able to allow the user to sort ascending or descending  
in the usual way by clicking the column header but using the above  
comparison options. It doesn't look as if that's possible with sort  
descriptors because compare:options: isn't KVC compliant. Is there a  
way around this?


cheers, Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Non-NSObject object and garbage collection

2008-08-11 Thread Oleg Krupnov
My application relies fully on garbage collection as the memory
management method.

Now I want to use a Quartz object which is not derived from NSObject.

Will it cause a memory leak if I treat the Quartz object in the same
way as I do to all my NSObject descendants, i.e. no retains and rely
only on garbage collection?

My understanding has been that the garbage collection functionality is
implemented somewhere under the hood of NSObject and that's (one of
the reasons) why all my objects should derive from NSObject. I hope I
am wrong and Quartz objects can be used just as well. :)

Thanks!
___

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

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

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

This email sent to [EMAIL PROTECTED]


Thread deadlock?

2008-08-11 Thread Trygve Inda
I am seeing a deadlock I think... It works in the debugger, but hangs when
running alone. The killThread is called as part of the
applicationWillTerminate delegate method.

My thought is that somehow after blocking to wait for kConditionThreadIdle,
my performSelectorOnMainThread is getting called. When this happens, it gets
stuck because the main thread is already blocked.

Perhaps after calling if (![self threadMustExit]), but before dispatching to
the main thread?

Does anyone have any thoughts on this or a good way to prevent it?

Trygve

-(void)awakeFromNib
{
 lock = [[NSConditionLock alloc] initWithCondition:kConditionThreadRunning];

[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:self];
}


- (void)threadMethod:(id)anObject
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

while (1)
{
if (![self threadMustExit])
[self doStuff];

if (![self threadMustExit])
[self performSelectorOnMainThread:@selector(doThreadUnsafeStuff)
  withObject:nil waitUntilDone:YES];

if ([lock lockWhenCondition:kConditionThreadMustExit)
{
[lock unlock];
break;
}
}

[lock lock];
[lock unlockWithCondition:kConditionThreadIdle];

[pool release];
}


- (BOOL)threadMustExit
{
[lock lock];
BOOL threadMustExit = ([lock condition] == kConditionThreadMustExit);
[lock unlock];

return (threadMustExit);
}


-(void)killThread
{
[lock lock];
if ([lock condition] == kConditionThreadRunning)
{
//instruct thread to exit
[lock unlockWithCondition:kConditionThreadMustExit];

//Wait for thread to exit
[lock lockWhenCondition:kConditionThreadIdle];
[lock unlock];
}
else
[lock unlock];
}




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Web links with PyObjC

2008-08-11 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 8:02 PM, Aaron <[EMAIL PROTECTED]> wrote:
> Thanks, but I have no idea how to make it link to a web link in the source.

Use +[NSWorkspace openURL].

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Non-NSObject object and garbage collection

2008-08-11 Thread Antonio Nunes

On 11 Aug 2008, at 12:56, Oleg Krupnov wrote:


Will it cause a memory leak if I treat the Quartz object in the same
way as I do to all my NSObject descendants, i.e. no retains and rely
only on garbage collection?


You either take care of the object's life time manually as you would  
in a non-garbage collected environment, or you explicitly move it into  
the realm of the garbage collector. Lookup "CFMakeCollectable" and  
"NSMakeCollectable" in the docs.


António


I try to take one day at a time, but sometimes, several days attack me  
all at once!




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Non-NSObject object and garbage collection

2008-08-11 Thread Antonio Nunes

On 11 Aug 2008, at 13:14, Antonio Nunes wrote:


Will it cause a memory leak if I treat the Quartz object in the same
way as I do to all my NSObject descendants, i.e. no retains and rely
only on garbage collection?


You either take care of the object's life time manually as you would  
in a non-garbage collected environment, or you explicitly move it  
into the realm of the garbage collector. Lookup "CFMakeCollectable"  
and "NSMakeCollectable" in the docs.


I should add: read the "Memory Management Semantics" in "Using Core  
Foundation with Garbage Collection" in the "Garbage Collection  
Programming Guide", which has a thorough explanation of how to handle  
CF objects under GC.


António


It isn't so important to do great things,
as to do what you do with great love.




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Non-NSObject object and garbage collection

2008-08-11 Thread Jean-Daniel Dupas


Le 11 août 08 à 14:25, Antonio Nunes a écrit :


On 11 Aug 2008, at 13:14, Antonio Nunes wrote:


Will it cause a memory leak if I treat the Quartz object in the same
way as I do to all my NSObject descendants, i.e. no retains and rely
only on garbage collection?


You either take care of the object's life time manually as you  
would in a non-garbage collected environment, or you explicitly  
move it into the realm of the garbage collector. Lookup  
"CFMakeCollectable" and "NSMakeCollectable" in the docs.


I should add: read the "Memory Management Semantics" in "Using Core  
Foundation with Garbage Collection" in the "Garbage Collection  
Programming Guide", which has a thorough explanation of how to  
handle CF objects under GC.


António


And note also that CoreGraphics objects (CGXxxxRef) are CFTypeRef  
(Core Foundation based objects).




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: including a cocoa bundle in a carbon app

2008-08-11 Thread Jonathan deWerd

On Aug 10, 2008, at 5:39 PM, Uli Kusterer wrote:


On 10.08.2008, at 19:38, Bob Sabiston wrote:
I got my Cocoa bundle to compile on the Intel machine.  It still  
doesn't load within my app, though.  Is there something special I  
need to do to include it in my project? I just dragged it in on the  
left, amongst all the other types of files, and it gave me a menu  
of targets from which I selected the correct one.  But the load is  
still failing.  I'm using the function below, gotten from Apple's  
examples.  Anyone know what could be the problem?  CFBundleCreate  
is just setting bundlePtr to 0, I don't know why.



I've done stuff like that and it worked fine for me (heck, I've  
loaded CFM bundles into Mach-O apps). What template did you use as a  
basis for your bundle? You keep saying bundle, but the variable  
names mention frameworks. Now, there are different ways of building  
stuff like that. E.g. frameworks contain a path they expect to be  
loaded at (installation path setting), while bundles as they're used  
for plugins generally don't.


Did you perhaps mix those up? Alternately, are you perhaps mixing  
debug and release builds? Anything not 100% homogeneous in there?
A bundle shouldn't be dragged in on the left in XCode (a framework  
should). You *might* be getting a bundle already loaded error if  
that's the case. Try using loadAndReturnError: or  
CFBundleLoadExecutableAndReturnError (which seems like it doesn't just  
load executable bundles, aka applications?) to determine what the  
exact problem is.





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





___

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

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

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


This email sent to [EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Using @selector()

2008-08-11 Thread Negm-Awad Amin


Am Sa,09.08.2008 um 11:23 schrieb Christian Giordano:


yep, it works with that :)
I presume it is an error in the book. Personally I thought that
passing the method not as string it would have recognized the scope
(target) automatically.
Fortunaly they don't. Selector-dispatching is performed dynamically as  
every other message-dispatch. So the same selector can be executed on  
different objects of different classes. Otherwise some techniques of  
Cocoa wouldn't work (I. e. responder chain, bindings)


Amin



Thanks a lot, chr


On Sat, Aug 9, 2008 at 9:45 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:


Le 9 août 08 à 10:34, Christian Giordano a écrit :


Hi guys, I'm a newbie and I'm reading a book which shows the two
different option to link programmatically a control to an action:

SEL mySelector;
mySelector = @selector(methodName:);
[myButton setAction:mySelector];

OR

SEL mySelector;
mySelector = NSSelectorFromString(@"methodName:");
[myButton setTarget:someObjectWithTheMethod];
[myButton setAction:mySelector];

On my test, the first syntax doesn't seem to work. This is my
implementation.

- (void)awakeFromNib
{
  NSLog(@"awakeFromNib");
 SEL mySelector;
  mySelector = @selector(sayIt:);
  [sayItButton setAction:mySelector];
}

If I do the other syntax:

- (void)awakeFromNib
{
  NSLog(@"awakeFromNib");
 SEL mySelector;
  mySelector = NSSelectorFromString(@"sayIt:");
  [sayItButton setTarget:self];
  [sayItButton setAction:mySelector];
}

Works. The sayIt method is in the same class than the awakeFromNib  
of

course. Any ideas?



Why you do not set the target in the first method ?




___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


URL Text Color in NSTextView

2008-08-11 Thread Simon Wolf
I am using an NSTextView to display the contents of a Credits.html  
file. The credits file contains URLs which I am specifying as HTML  
links. For example, one line in my Credits.html file may be:


"Distributed under a http://creativecommons.org/licenses/by/3.0/ 
" target="_blank">Creative Commons License"


My problem is that the hyperlinks are always colored blue which  
doesn't work against the dark-colored background I am using.


In order to display the contents of the file I am using the following  
code:


[[textAcknowledgements textStorage] setAttributedString: [self  
acknowledgementString]];


which calls:

- (NSAttributedString *) acknowledgementString
{
// get the contents of Credits.html
NSString *filePath = [[NSBundle mainBundle]  
pathForResource:@"credits" ofType:@"html"];
NSMutableString * stringFileContents = [NSMutableString  
stringWithContentsOfFile:filePath];


NSFont * fontSystem = [NSFont systemFontOfSize:[NSFont  
systemFontSize]];
NSString * fontName = [NSString stringWithString:[fontSystem  
displayName]];
NSString * fontSize = [NSString stringWithFormat:@"%gpt",[NSFont  
labelFontSize]-2];


[stringFileContents replaceOccurrencesOfString:@"[ff]"  
withString:fontName options:NSLiteralSearch range:NSMakeRange(0,  
[stringFileContents length])];
[stringFileContents replaceOccurrencesOfString:@"[fs]"  
withString:fontSize options:NSLiteralSearch range:NSMakeRange(0,  
[stringFileContents length])];
NSData *myData = [stringFileContents  
dataUsingEncoding:NSUTF32StringEncoding];


if (myData) {
NSMutableAttributedString * stringCredits =  
[[[NSMutableAttributedString alloc] initWithHTML:myData  
documentAttributes:nil] autorelease];

NSRange range = NSMakeRange(0, [stringCredits length]);
[stringCredits addAttribute:NSForegroundColorAttributeName  
value:[NSColor greenColor] range:range];

return stringCredits;
} else {
return nil;
}
}

[The whole fonts bit is to ensure that the text is displayed using the  
standard system font at the standard size. I'm not sure if this is  
totally necessary or whether I could just hard-code the values but it  
seems more future-proof this way.]


All of my attempts to change the foreground color via  
NSForegroundColorAttributeName have failed so far as have attempts to  
set the color in the Credits.html file (CSS works for standard text,  
not links however).


Does anyone have any idea how I can solve this?

Simon
___

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

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

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

This email sent to [EMAIL PROTECTED]


How to check the capital letter?

2008-08-11 Thread Macarov Anatoli
HI!
Cocoa, Obj-C.
How to check the capital letter?



  
Вы уже с Yahoo!? 
Испытайте обновленную и улучшенную. Yahoo! Почту! http://ru.mail.yahoo.com
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the capital letter?

2008-08-11 Thread Jaime Magiera


On Aug 11, 2008, at 8:52 AM, Macarov Anatoli wrote:


HI!
Cocoa, Obj-C.


Hi,

You'll want to look into NSScanner and NSCharacterSet. The String  
Programming Guide should provide all you need...


http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/index.html

hope that helps,

Jaime Magiera

Sensory Research
http://www.sensoryresearch.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: URL Text Color in NSTextView

2008-08-11 Thread Uli Kusterer

On 11.08.2008, at 14:45, Simon Wolf wrote:
All of my attempts to change the foreground color via  
NSForegroundColorAttributeName have failed so far as have attempts  
to set the color in the Credits.html file (CSS works for standard  
text, not links however).



 IIRC NSTextView has a method to specify the attributes used for  
links. Those override whatever you specify in the attributed string,  
AFAIK.


 Ah, here it is : -setLinkTextAttributes:

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





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the capital letter?

2008-08-11 Thread Mike Abdullah


On 11 Aug 2008, at 13:52, Macarov Anatoli wrote:


HI!
Cocoa, Obj-C.
How to check the capital letter?


You really need to explain what it is you actually want to do.





 
Вы уже с Yahoo!?
Испытайте обновленную и улучшенную. Yahoo!  
Почту! http://ru.mail.yahoo.com

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the capital letter?

2008-08-11 Thread Ron Fleckner


On 11/08/2008, at 10:52 PM, Macarov Anatoli wrote:


HI!
Cocoa, Obj-C.
How to check the capital letter?


Hi, I don't remember if there is a Cocoa solution, but of course you  
can use plain C:


NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 check the capital letter?

2008-08-11 Thread Jean-Daniel Dupas


Le 11 août 08 à 15:29, Ron Fleckner a écrit :



On 11/08/2008, at 10:52 PM, Macarov Anatoli wrote:


HI!
Cocoa, Obj-C.
How to check the capital letter?


Hi, I don't remember if there is a Cocoa solution, but of course you  
can use plain C:


NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.


Wrong. characterAtIndex: return an unichar not a char, which is AFAK  
an UTF16 character.




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 check the capital letter?

2008-08-11 Thread Ron Fleckner


On 11/08/2008, at 11:29 PM, Ron Fleckner wrote:



On 11/08/2008, at 10:52 PM, Macarov Anatoli wrote:


HI!
Cocoa, Obj-C.
How to check the capital letter?


Hi, I don't remember if there is a Cocoa solution, but of course  
you can use plain C:


NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.



Forgot to mention: this isn't plain C, but a function from the C  
library.  No need to explicitly link, it just works.


Ron
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: URL Text Color in NSTextView

2008-08-11 Thread Simon Wolf

On 11 Aug 2008, at 14:27, Uli Kusterer wrote:


On 11.08.2008, at 14:45, Simon Wolf wrote:
All of my attempts to change the foreground color via  
NSForegroundColorAttributeName have failed so far as have attempts  
to set the color in the Credits.html file (CSS works for standard  
text, not links however).



IIRC NSTextView has a method to specify the attributes used for  
links. Those override whatever you specify in the attributed string,  
AFAIK.


Ah, here it is : -setLinkTextAttributes:


Thanks Uli. I think I was concentrating on doing it via the  
NSAttributedString too much.


Simon
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 check the capital letter?

2008-08-11 Thread Ron Fleckner


On 11/08/2008, at 11:35 PM, Jean-Daniel Dupas wrote:



Le 11 août 08 à 15:29, Ron Fleckner a écrit :



Hi, I don't remember if there is a Cocoa solution, but of course  
you can use plain C:


NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.


Wrong. characterAtIndex: return an unichar not a char, which is  
AFAK an UTF16 character.


Yes, I saw that.  But it still works.  No compiler warning either.   
Would it be a problem?


Ron___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 check the capital letter?

2008-08-11 Thread Uli Kusterer

On 11.08.2008, at 15:29, Ron Fleckner wrote:

NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.


 Bad Idea (tm):

You're discarding the high byte of the unichar that characterAtIndex:  
returns by casting it to a regular char, so isupper() might get to see  
a completely different character than the user sees.


Second, Unicode can have decomposed character sequences, so the glyph  
at that particular index may actually be several characters long, and  
you're only analyzing the first one.


NSCharacterSet is probably your best bet. You could check whether  
whatever character you're looking at is a member of the  
uppercaseLetterCharacterSet.


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





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the capital letter?

2008-08-11 Thread Ron Fleckner


On 11/08/2008, at 11:54 PM, Uli Kusterer wrote:


On 11.08.2008, at 15:29, Ron Fleckner wrote:

NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
	NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :  
@"lowercase");
	NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :  
@"lowercase");


Result:

A is uppercase.
a is lowercase.


 Bad Idea (tm):

You're discarding the high byte of the unichar that  
characterAtIndex: returns by casting it to a regular char, so  
isupper() might get to see a completely different character than  
the user sees.


Second, Unicode can have decomposed character sequences, so the  
glyph at that particular index may actually be several characters  
long, and you're only analyzing the first one.


NSCharacterSet is probably your best bet. You could check whether  
whatever character you're looking at is a member of the  
uppercaseLetterCharacterSet.


Cheers,
-- Uli Kusterer


OK, thanks Uli and Jean-Daniel.  I see why it's not such a good idea.

Ron
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSConditionLock vs MPQueue

2008-08-11 Thread Trygve Inda
I am using NSConditionLock in Cocoa but it seems unable to match the
capabilities of MPQueue for my needs.

I am using

-- from my worker thread, do something on the main thread --

[lock lockWhenCondition:kTaskComplete];

In the Carbon version I used MPWaitOnQueue.

The difference is that MPWaitOnQueue can wait for any signal to be received.
I need to wait on either kTaskComplete or kTaskAbort

With MPQueue I could send either kTaskComplete or kTaskAbort, but with
NSConditionLock I can only wait on a single condition.

Is there some other method that will let me block on "A or B" ?

Thanks,

Trygve


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


addObserver:

2008-08-11 Thread Chris Idou

I'm making the following call (and defining observeValueForKeyPath on self etc) 
on an NSArrayController, hoping to get notifications of it changing. But I 
don't seem to be getting any notifications. Should this work?


[arrayController addObserver:self 
 forKeyPath:@"content"  
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
 context:nil];




  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Sort Descriptor problem in NSTableView

2008-08-11 Thread Keary Suska
8/11/08 4:35 AM, also sprach [EMAIL PROTECTED]:

> I have a table view where one column's strings are sorted using
> (NSCaseInsensitiveSearch | NSNumericSearch). To do this I use
> compare:options: on the strings.
> 
> I'd like to be able to allow the user to sort ascending or descending
> in the usual way by clicking the column header but using the above
> comparison options. It doesn't look as if that's possible with sort
> descriptors because compare:options: isn't KVC compliant. Is there a
> way around this?

OTOH, implement a custom sort method, setting it as the method to use in the
table column properties.

HTH, 

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: addObserver:

2008-08-11 Thread Negm-Awad Amin


Am Mo,11.08.2008 um 16:15 schrieb Chris Idou:



I'm making the following call (and defining observeValueForKeyPath  
on self etc) on an NSArrayController, hoping to get notifications of  
it changing. But I don't seem to be getting any notifications.  
Should this work?



[arrayController addObserver:self
	 forKeyPath:@"content" 		options:(NSKeyValueObservingOptionNew| 
NSKeyValueObservingOptionOld)

 context:nil];


You should set the observation to the observable property of the array  
controller, i. g. the "output". Use the key @"arrangedObjects" instead  
of @"content". (content is the bound property, the "input".)


Amin






___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: addObserver:

2008-08-11 Thread Keary Suska
8/11/08 8:15 AM, also sprach [EMAIL PROTECTED]:

> I'm making the following call (and defining observeValueForKeyPath on self
> etc) on an NSArrayController, hoping to get notifications of it changing. But
> I don't seem to be getting any notifications. Should this work?
> 
> 
> [arrayController addObserver:self
> forKeyPath:@"content"
>   options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
> context:nil];

It works, but perhaps not the way you want it to. You will receive
notifications any time the "content" property of your array controller is
changed (or led to believe that it has changed). I.e. any time the array
object itself is changed to another array object, *not* when the elements of
the array are changed.

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the capital letter?

2008-08-11 Thread Marco Masser

How to check the capital letter?


If you don't want to mess around with NSCharacterSet and NSScanner,  
you could also do this:


NSString *string = @"abcABC";
NSUInteger index = 0; // The character at this index will be checked
NSString *character = [string substringWithRange:NSMakeRange(index, 1)];
NSLog(@"is uppercase: %i", [character isEqualToString:[character  
uppercaseString]]);

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Memory Leaks & Instruments Questions

2008-08-11 Thread Nathan Vander Wilt

On Aug 10, 2008, at 12:37 PM, Michael Kaye wrote:
I've ben running my app with leaks in Instruments and it is  
reporting a fair number of leaks.


On analyzing these leaks, they all appear to be related to apple  
frameworks methods/code and never as a direct result of any objects  
I've instantiated.


Therefore my question is, is whether this is correct and what you  
would normally expect to see? Or are the leaks indirectly caused by  
something I am doing? If the former should I just ignore them and if  
the latter how do I track down exactly where it is occurring.


While I have seen an occasional report of a leak from the run loop  
throughout a really long (~20 minutes) analysis session, if you have a  
fair number of leaks I think its safe to assume they are of your doing.


A couple tips:
- If you are viewing the list of allocations for a particular block,  
oftentimes you may see a whole lot of framework activity in the  
history. Remember that the last line is the only one that leaked.
- While tracking down a couple hard-to-find leaks last week, I found  
the "Outline View" with "Invert Call Tree" to be quite helpful. It not  
only shows the root functions that leaked (eg malloc), but allows you  
to look and see what all called that and leaked, and so on. That way  
you can move up past the frameworks to see which of your functions are  
calling the low-level stuff.
- If your program is still running, you can double-click a leaking  
method/function to pull it up in Xcode for further scrutiny. Of course  
this only works for what you have source code access to, that is, your  
own methods. I'm not sure why it only works when running, YMMV on that.


Whilst we are on it, I have a second question and that is whether  
should I expect any singleton object to "appear" as a memory leak in  
Instruments. Obviously the point of a singleton is is that it has  
one instance and any instance variables exist with no dealloc. So  
does Instruments handle this or just report them as a leak?


To be useful, a reference must be kept to the singleton. As long as  
this reference is kept, it has not leaked. A leak is when an object/ 
memory is allocated, but then all references to the object are lost.  
In this scenario there is no way to release/autorelease/free it  
anymore, ever, so it has leaked. But when there is still a reference  
to an object, Leaks will assume you are waiting to release it later.


hope this helps,
-natevw
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Table Column NSSegmentedCell - Segment not Selecting

2008-08-11 Thread hac
I have a table column that contains multiple types of cells. One is an
NSSegmentedCell. To do this, I have tried variations of the following
code. I use it in the table's data source as well as to override the
column's dataCellForRow method:

NSSegmentedCell *theCell = [[[NSSegmentedCell alloc] init] autorelease];
[theCell setSegmentCount:count];
[theCell setSelectedSegment:foo];
return theCell;

What happens is that [theCell selectedSegment] now returns foo, but it
does not appear selected at all. This seems like a simple thing to do,
but I can't seem to do it. Am I doing something totally wrong?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Table Column NSSegmentedCell - Segment not Selecting

2008-08-11 Thread hac
I've solved my own problem, finally. I have set the data source to
return an NSNumber containing the selected index rather than an actual
cell. I still don't really understand why I do this for only some
types of cells, but this solution works fine.

On Sun, Aug 10, 2008 at 11:32 PM, hac <[EMAIL PROTECTED]> wrote:
> I have a table column that contains multiple types of cells. One is an
> NSSegmentedCell. To do this, I have tried variations of the following
> code. I use it in the table's data source as well as to override the
> column's dataCellForRow method:
>
> NSSegmentedCell *theCell = [[[NSSegmentedCell alloc] init] autorelease];
> [theCell setSegmentCount:count];
> [theCell setSelectedSegment:foo];
> return theCell;
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Miniaturizing a window when PowerPoint is in full screen mode

2008-08-11 Thread Angie Frazier
I'm having trouble getting a window in my application to miniaturize when
PowerPoint is open in full screen mode. The window counts down to zero, when
it hits zero, it should miniaturize itself to the dock. This works as
expected unless PowerPoint is also running in full screen mode. The
miniaturize message is ignored and the countdown window stays on top. I have
to click on the countdown window and manually miniaturize it. In the code
after the miniaturize message is sent, I ask the window if it is
miniaturized and it returns no. How can I get the window to miniaturize even
when PowerPoint is open?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why use NSObjectController?

2008-08-11 Thread Sean McBride
On 8/10/08 10:08 PM, Seth Willits said:

>>> What is it that NSObjectController offers me?
>>
>> An implementation of the NSEditor and NSEditorRegistration protocols.
>
>Now I'll just have to figure out when I'd want to use those...

I seem to have run into this situation the other day.  Maybe my example
will help.

I have a nib with some textfields bound to an ivar in File's Owner.  It
mostly works fine.  Now I have a push button that reads those ivars and
performs some computation.  If the user has typed something in the
textfield but not changed focus, this new value is not yet in the ivar.
Here the commitEditing method is your friend.  But it seems you can't
send commitEditing to a textfield.  (Yet the docs say "The NSEditor
informal protocol is implemented by controllers and user interface
elements. [...] These methods are typically invoked on user interface
elements").  I believe I'll need to change those textfields to be bound
to an NSController subclass.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory Leaks & Instruments Questions

2008-08-11 Thread Sean McBride
On 8/10/08 8:37 PM, Michael Kaye said:

>I've ben running my app with leaks in Instruments and it is reporting
>a fair number of leaks.

Is your app garbage collected?  Instruments reports many many false
positives in GC apps.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Michael Ash
On Mon, Aug 11, 2008 at 8:09 AM, Trygve Inda <[EMAIL PROTECTED]> wrote:
> I am seeing a deadlock I think... It works in the debugger, but hangs when
> running alone. The killThread is called as part of the
> applicationWillTerminate delegate method.

You can use gdb to attach to the program after it freezes to find out
where it's stuck. Or just use Shark, or sample in Activity Monitor.

>if ([lock lockWhenCondition:kConditionThreadMustExit)

How does this even compile? The braces are unbalanced, and
lockWhenCondition: returns void.

In any case, you definitely have deadlock potential here. Your
-killThread method blocks waiting for the thread to exit. Your thread
blocks waiting for the main thread to complete. If both of these
happen at the same time, both of them are waiting for the other to
finish first.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSImage and zooming PDFs vs. bitmaps

2008-08-11 Thread Ken Ferry
On Aug 11, 2008, at 1:15 AM, Hamish Sanderson <[EMAIL PROTECTED] 
> wrote:



On 8 Aug 2008, at 17:53, Ken Ferry wrote:


The correct answer is to call setDataRetained:YES on your image.
However, there may be a bug in Leopard and previous with NSImage  
cache

expiration that prevents that from being enough.  If you seem to be
hitting it, you can probably work around it by additionally turning
off caching entirely (setCacheMode:NSImageCacheNever) or maybe by
manually invalidating the image cache (-[NSImage recache]) when you
are changing the scale.


Yay! A combination of -setDataRetained: on image loading and - 
recache on zooming did the trick, although I did need to kludge in a  
size check before calling -recache as rasterising an entire PDF  
above ~10,000x10,000 quickly gets painful performance- and memory- 
wise. Obviously there are ways to rasterise just the visible portion  
on an as-needed basis (c.f. PDFKit's PDFView), but I suspect this is  
non-trivial to implement so I'll see if users can live with the  
current resolution limit (which is still a big improvement from  
before).


For drawing that would lead to a very large raster cache, NSImage  
prefers to draw directly from the source rather than make a cache.  
However, it sounds like this isn't doing it for you. Could you file a  
bug with a demonstration app?


Perhaps you could try just turning caching off, or turning it off when  
the scale factor is high?  As you said, at some point the cost of  
making and holding the cache outweighs the cost of just drawing from  
the PDF.


Also, sorry, there's nothing built-in that caches partial images or  
holds caches for multiple destination sizes.


-Ken
Cocoa Frameworks

Out of interest, is there an easy way to make NSImage retain and  
reuse these different sized cached representations rather than  
throwing them away each? At the moment, things get a bit sluggish  
every time you zoom into details; it'd be nice if it only had to be  
sluggish the first time. The NSImage API looks like it should be  
able to do this, but I'm having trouble getting my head around it.  
Any pointers?


Many thanks,

Hamish
--

Hamish Sanderson
Production Workflow Developer
Sun Branding Solutions Ltd
Tel: +44(0)1274 200 700
www.s-brandingsolutions.com





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSConditionLock vs MPQueue

2008-08-11 Thread Michael Ash
On Mon, Aug 11, 2008 at 10:07 AM, Trygve Inda <[EMAIL PROTECTED]> wrote:
> I am using NSConditionLock in Cocoa but it seems unable to match the
> capabilities of MPQueue for my needs.
>
> I am using
>
> -- from my worker thread, do something on the main thread --
>
> [lock lockWhenCondition:kTaskComplete];
>
> In the Carbon version I used MPWaitOnQueue.
>
> The difference is that MPWaitOnQueue can wait for any signal to be received.
> I need to wait on either kTaskComplete or kTaskAbort
>
> With MPQueue I could send either kTaskComplete or kTaskAbort, but with
> NSConditionLock I can only wait on a single condition.
>
> Is there some other method that will let me block on "A or B" ?

You could use a separate flag, and use the NSConditionLock to simply
signal whenever the separate flag's value changes. This will have the
consequence of waking up a waiting thread for all changes, not just
the ones it cares about, but if you put it in a loop then it will go
right back to sleep again.

You may also be able to do this more directly using pthread primitives
rather than Cocoa's classes. I don't see anything that *directly* has
the semantics you describe, but rest assured that it's possible to
build them, because the MP library is built on top of the pthread
calls.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Get specified window from nib

2008-08-11 Thread Michael Ash
On Sun, Aug 10, 2008 at 10:01 PM, Fosse <[EMAIL PROTECTED]> wrote:
> I have one nib containing more than ten dialogs and want to get the
> specified window after nib is loading..

Don't take this badly, but if you have one nib with ten windows and
you only want to access one of them, you're doing it wrong. Separate
nibs will be easier to work with and will be more efficient (you don't
have to create and then destroy nine windows you don't care about
every time you load one you do care about).

> If I use FileOwner and binding, I need to add a lot of Outlets in the
> fileOwner class and create the binding in the IB..   Is there a more
> convenient way to get the specified  window by passing the window name and
> nib reference like Carbon?

Create one outlet to each window. Ten outlets doesn't seem like an
enormous hardship.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Newbie Error on Loading XML

2008-08-11 Thread Matt Keyes
Hello,

I am trying to load an XML file from the project, and here is what I do:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
pathForResource:@"MyXmlFile" ofType:@"Xml"]];
NSXMLDocument *xmlDoc = nil;

@try {
xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:url];
}
@catch (NSException * e) {
txtResult.text = [NSString stringWithFormat:@"Error: %@", [e reason]];
}
@finally {

}

if(xmlDoc != nil)
{
 //... do stuff
}

The error I receive is:

"-[NSXMLDocument initWithContentsOfURL]: unrecognized selector sent to instance 
0x471100"

I was able to load a NSData object from the XML file and I can capture the file 
path in a string from the NSBundle resource path and it is correct.  I get this 
same error if I use the initWithData function for the NSXMLDocument object.

Any ideas?

Thanks,
Matt

_
Your PC, mobile phone, and online services work together like never before.
http://clk.atdmt.com/MRT/go/108587394/direct/01/___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Error on Loading XML

2008-08-11 Thread Randall Meadows

On Aug 11, 2008, at 11:16 AM, Matt Keyes wrote:

I am trying to load an XML file from the project, and here is what I  
do:


NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]  
pathForResource:@"MyXmlFile" ofType:@"Xml"]];

NSXMLDocument *xmlDoc = nil;

@try {
   xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:url];
   }

[snip]

The error I receive is:

"-[NSXMLDocument initWithContentsOfURL]: unrecognized selector sent  
to instance 0x471100"


I was able to load a NSData object from the XML file and I can  
capture the file path in a string from the NSBundle resource path  
and it is correct.  I get this same error if I use the initWithData  
function for the NSXMLDocument object.


Any ideas?


Yeah, NSXMLDocument doesn't respond to initWithContentsOfURL: or  
initWithData:. :)


It *does*, however, respond to initWithContentsOfURL:options:error:  
and initWithData:options:error:.


HTH.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Error on Loading XML

2008-08-11 Thread Matt Keyes
That makes sense.  I am new to Objective-C and the compiler did not complain 
with the missing arguments... lesson learned!



> CC: cocoa-dev@lists.apple.com
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: Newbie Error on Loading XML
> Date: Mon, 11 Aug 2008 11:24:07 -0600
> 
> On Aug 11, 2008, at 11:16 AM, Matt Keyes wrote:
> 
> > I am trying to load an XML file from the project, and here is what I  
> > do:
> >
> > NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]  
> > pathForResource:@"MyXmlFile" ofType:@"Xml"]];
> > NSXMLDocument *xmlDoc = nil;
> >
> > @try {
> >xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:url];
> >}
> [snip]
> > The error I receive is:
> >
> > "-[NSXMLDocument initWithContentsOfURL]: unrecognized selector sent  
> > to instance 0x471100"
> >
> > I was able to load a NSData object from the XML file and I can  
> > capture the file path in a string from the NSBundle resource path  
> > and it is correct.  I get this same error if I use the initWithData  
> > function for the NSXMLDocument object.
> >
> > Any ideas?
> 
> Yeah, NSXMLDocument doesn't respond to initWithContentsOfURL: or  
> initWithData:. :)
> 
> It *does*, however, respond to initWithContentsOfURL:options:error:  
> and initWithData:options:error:.
> 
> HTH.

_
Got Game? Win Prizes in the Windows Live Hotmail Mobile Summer Games Trivia 
Contest
http://www.gowindowslive.com/summergames?ocid=TXT_TAGHM___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Error on Loading XML

2008-08-11 Thread Devon Ferns

You're missing some parameters for initWithContentsOfURL


The full method signature is
- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask 
error:(NSError **)error


Devon

Matt Keyes wrote:

Hello,

I am trying to load an XML file from the project, and here is what I do:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MyXmlFile" 
ofType:@"Xml"]];
NSXMLDocument *xmlDoc = nil;

@try {

xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:url];
}
@catch (NSException * e) {
txtResult.text = [NSString stringWithFormat:@"Error: %@", [e reason]];
}
@finally {

}

if(xmlDoc != nil)

{
 //... do stuff
}

The error I receive is:

"-[NSXMLDocument initWithContentsOfURL]: unrecognized selector sent to instance 
0x471100"

I was able to load a NSData object from the XML file and I can capture the file 
path in a string from the NSBundle resource path and it is correct.  I get this 
same error if I use the initWithData function for the NSXMLDocument object.

Any ideas?

Thanks,
Matt

_
Your PC, mobile phone, and online services work together like never before.
http://clk.atdmt.com/MRT/go/108587394/direct/01/___

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

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

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

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Miniaturizing a window when PowerPoint is in full screen mode

2008-08-11 Thread Eric Schlegel


On Aug 11, 2008, at 6:14 AM, Angie Frazier wrote:

I'm having trouble getting a window in my application to miniaturize  
when
PowerPoint is open in full screen mode. The window counts down to  
zero, when

it hits zero, it should miniaturize itself to the dock. This works as
expected unless PowerPoint is also running in full screen mode. The
miniaturize message is ignored and the countdown window stays on  
top. I have
to click on the countdown window and manually miniaturize it. In the  
code

after the miniaturize message is sent, I ask the window if it is
miniaturized and it returns no. How can I get the window to  
miniaturize even

when PowerPoint is open?


Unfortunately you can't; when an app is in fullscreen mode, the Dock  
is hidden, and the Dock doesn't support miniaturizing windows when  
it's hidden. -[NSWindow miniaturize] will be a no-op in this case.


-eric

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Peter Duniho

Date: Mon, 11 Aug 2008 12:09:05 +
From: Trygve Inda <[EMAIL PROTECTED]>

I am seeing a deadlock I think... It works in the debugger, but  
hangs when

running alone. The killThread is called as part of the
applicationWillTerminate delegate method.

My thought is that somehow after blocking to wait for  
kConditionThreadIdle,
my performSelectorOnMainThread is getting called. When this  
happens, it gets

stuck because the main thread is already blocked.

Perhaps after calling if (![self threadMustExit]), but before  
dispatching to

the main thread? [...]


Perhaps.  Is the "killThread" method executed on the main thread?  If  
so, then yes...it would get stuck waiting for the the  
"kConditionThreadIdle" condition.  If the main thread reached that  
code any time before the "doThreadUnsafeStuff" method was actually  
executed on the main thread, then that selector will never be  
performed, the worker thread will never get past the  
"performSelectorOnMainThread" statement, and will itself never  
release the main thread.


Sounds like deadlock to me.  Hard to know for sure, since the code  
you posted isn't a complete sample, nor would it even compile, so  
it's obviously not actually the code you're using.  But assuming it's  
a fair representation, it looks like it has a deadlock bug in it.


For what it's worth, it seems to me that blocking the main thread for  
_any_ significant time is just a bad idea.  I'm less familiar with  
Cocoa, but this is true in every other message/event-dispatching  
architecture I'm familiar with.  That's the main reason for putting  
lengthy operations on a different thread in the first place, and  
making the main thread wait on such a lengthy operation negates the  
whole point of putting that operation on a different thread.


So even if you weren't calling "performSelectorOnMainThread", waiting  
on the worker thread is probably not a great idea.  Of course, in  
your example, it's _definitely_ not a great idea.  :)


By the way, I admit...I'm not familiar with the exact usage of  
NSConditionLock, but it would surprise if you have to take the lock  
just to inspect the condition (per the "threadMustExit" method).


Pete
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Newbie Question on "self"

2008-08-11 Thread Matt Keyes
Hello again,

In C/C++ and the .NET languages I am used to, I have generally tried to prefix 
any member variables inside class methods with "this"

i.e. this.m_sMyString = "this is my string";

In Objective-C, this doesn't seem as clear to me (or at least it doesn't 
compile).  For example:

- (id)initWithString:(NSString *) string {
self.myString = [[NSString alloc] initWithString:string];
}

Produces an error:

error: request for member 'myString' in something not a structure or union

I am sure this is something very simple and basic I am missing, but any 
assistance is appreciated.

Thanks,
Matt

_
Get Windows Live and get whatever you need, wherever you are.  Start here.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home_082008___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread I. Savant
> In Objective-C, this doesn't seem as clear to me (or at least it doesn't 
> compile).  For example:
>
> - (id)initWithString:(NSString *) string {
>self.myString = [[NSString alloc] initWithString:string];
> }
>
> Produces an error:
>
> error: request for member 'myString' in something not a structure or union

  Several things:

1 - Using the dot syntax (a feature of Objective-C 2.0) requires that
you have proper accessors set up for the property you're using. In
this case, the "myString" property. Do you?

2 - In your -initWithString: method, you probably want:
self.myString = string;
  ... in your version, you're uselessly creating a string from the
passed string when the passed string will do. If you waned a copy of
the passed string, the property is where you'd specify this behavior
(ie, copy versus retain, etc.).

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie Question on "self"

2008-08-11 Thread Jonathan Hess


On Aug 11, 2008, at 10:47 AM, Matt Keyes wrote:


Hello again,

In C/C++ and the .NET languages I am used to, I have generally tried  
to prefix any member variables inside class methods with "this"


i.e. this.m_sMyString = "this is my string";

In Objective-C, this doesn't seem as clear to me (or at least it  
doesn't compile).  For example:


- (id)initWithString:(NSString *) string {
   self.myString = [[NSString alloc] initWithString:string];
}


Hey Matt -

If you prefer this type of explicit reference to an instance variable,  
this syntax will work:


self->myString = [[NSString alloc] initWithString:string];

Since self is a pointer, you need to use the -> operator. If you're  
familiar with working with structure members, object members work the  
same way. The . syntax only applies if you have an actual object  
instead of a pointer to an object, which you'll really never have in  
objective-c.


Good Luck -
Jon Hess




Produces an error:

error: request for member 'myString' in something not a structure or  
union


I am sure this is something very simple and basic I am missing, but  
any assistance is appreciated.


Thanks,
Matt

_
Get Windows Live and get whatever you need, wherever you are.  Start  
here.

http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home_082008___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSConditionLock vs MPQueue

2008-08-11 Thread Adam R. Maxwell
 
On Monday, August 11, 2008, at 09:56AM, "Michael Ash" <[EMAIL PROTECTED]> wrote:
>On Mon, Aug 11, 2008 at 10:07 AM, Trygve Inda <[EMAIL PROTECTED]> wrote:
>> I am using NSConditionLock in Cocoa but it seems unable to match the
>> capabilities of MPQueue for my needs.
>>
>> I am using
>>
>> -- from my worker thread, do something on the main thread --
>>
>> [lock lockWhenCondition:kTaskComplete];
>>
>> In the Carbon version I used MPWaitOnQueue.
>>
>> The difference is that MPWaitOnQueue can wait for any signal to be received.
>> I need to wait on either kTaskComplete or kTaskAbort
>>
>> With MPQueue I could send either kTaskComplete or kTaskAbort, but with
>> NSConditionLock I can only wait on a single condition.
>>
>> Is there some other method that will let me block on "A or B" ?
>
>You could use a separate flag, and use the NSConditionLock to simply
>signal whenever the separate flag's value changes. This will have the
>consequence of waking up a waiting thread for all changes, not just
>the ones it cares about, but if you put it in a loop then it will go
>right back to sleep again.

You can also use NSCondition for this, although it's apparently buggy pre-10.5. 
 It allows you to wake the thread up and check whatever flag(s) you care about, 
so I find it a bit more flexible than NSConditionLock.

>You may also be able to do this more directly using pthread primitives
>rather than Cocoa's classes. I don't see anything that *directly* has
>the semantics you describe, but rest assured that it's possible to
>build them, because the MP library is built on top of the pthread
>calls.

Maybe pthread_cond_wait/pthread_cond_signal?   That's the closest thing I know 
of, and conditions are fairly straightforward to use; just make sure to check 
the return value from pthread_cond_wait/pthread_cond_timedwait.

-- 
Adam
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why use NSObjectController?

2008-08-11 Thread R.L. Grigg


On Aug 11, 2008, at 8:52 AM, Sean McBride wrote:


But it seems you can't
send commitEditing to a textfield.


Why? If this was supported, wouldn't it greatly simplify things,  
meaning no need to have a NSController subclass, etc.? This is what  
confuses alot of newbs like me. Not arguing against it, just trying to  
see the motivation behind it.


Russ

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread Matt Neuburg
On Mon, 11 Aug 2008 17:47:59 +, Matt Keyes <[EMAIL PROTECTED]>
said:
>Hello again,
>
>In C/C++ and the .NET languages I am used to, I have generally tried to prefix
any member variables inside class methods with "this"
>
>i.e. this.m_sMyString = "this is my string";
>
>In Objective-C, this doesn't seem as clear to me (or at least it doesn't
compile).  For example:
>
>- (id)initWithString:(NSString *) string {
>self.myString = [[NSString alloc] initWithString:string];
>}
>
>Produces an error:
>
>error: request for member 'myString' in something not a structure or union

If myString is an ivar you can access it by saying self->myString.
Objective-C is C! (And it is not C++.)



There is a religious war over whether you *should* do this, though.
Personally I like it and I do it a lot, because it reminds me that this
thing (myString) is an ivar. Furthermore, this religious war is also bound
up with a religious war over accessors; some will say that you should always
implement an accessor and say

[self setMyString: whatever]

instead. Personally, I know when I need to pass thru the accessor for
memory-management or KVC and when I don't, so there are plenty of times when
I still say self->myString. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], 
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: 
AppleScript: the Definitive Guide - Second Edition!




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread Matt Keyes
Thanks y'all... in all the Obj-C examples I've read, I've never seen the -> 
operator used.  I should have thought to check! (since in C++ it would be 
this->whatever).

Thanks again,
Matt



> Date: Mon, 11 Aug 2008 11:05:55 -0700
> Subject: Re: Newbie Question on "self"
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: cocoa-dev@lists.apple.com
> 
> On Mon, 11 Aug 2008 17:47:59 +, Matt Keyes <[EMAIL PROTECTED]>
> said:
> >Hello again,
> >
> >In C/C++ and the .NET languages I am used to, I have generally tried to 
> >prefix
> any member variables inside class methods with "this"
> >
> >i.e. this.m_sMyString = "this is my string";
> >
> >In Objective-C, this doesn't seem as clear to me (or at least it doesn't
> compile).  For example:
> >
> >- (id)initWithString:(NSString *) string {
> >self.myString = [[NSString alloc] initWithString:string];
> >}
> >
> >Produces an error:
> >
> >error: request for member 'myString' in something not a structure or union
> 
> If myString is an ivar you can access it by saying self->myString.
> Objective-C is C! (And it is not C++.)
> 
>  es/chapter_3_section_4.html#//apple_ref/doc/uid/TP30001163-CH12-BAJHEIFE>
> 
> There is a religious war over whether you *should* do this, though.
> Personally I like it and I do it a lot, because it reminds me that this
> thing (myString) is an ivar. Furthermore, this religious war is also bound
> up with a religious war over accessors; some will say that you should always
> implement an accessor and say
> 
> [self setMyString: whatever]
> 
> instead. Personally, I know when I need to pass thru the accessor for
> memory-management or KVC and when I don't, so there are plenty of times when
> I still say self->myString. m.
> 
> -- 
> matt neuburg, phd = [EMAIL PROTECTED], 
> A fool + a tool + an autorelease pool = cool!
> One of the 2007 MacTech Top 25: 
> AppleScript: the Definitive Guide - Second Edition!
> 
> 
> 
> 

_
Get Windows Live and get whatever you need, wherever you are.  Start here.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home_082008___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread Todd Heberlein

- (id)initWithString:(NSString *) string {
   self.myString = [[NSString alloc] initWithString:string];
}


Well, you don't need the "self" prefix, but you may want to look at  
using "setters" and "getters". It would look like this


@interface MyThingy : NSObject {
...
NSString*   myString;
...
};
...
@property (copy) NSString* myString;
...
@end



And then in the implementation file you would have something like this:

@implementation MyThingy
...
@synthesize myString;
...
@end


And then, when you set the value, you do it like this:

[self setMyString: anotherString];


The benefit of this approach is that Apple has a run-time system that  
monitors access to variables set via setters like this, and other  
objects can subscribe to receive notifications when the value has  
changed. In particular, you can use Apple's Controller objects to glue  
your model (i.e., MyThingy) to GUI elements (e.g., a label in a  
window). Then whenever you set myString with the setMyString method,  
then the GUI is automatically updated. Likewise, an update in a GUI  
element will automatically get pushed into your variable.


All very cool (although a bit confusing when you are first getting  
started).


Todd

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread Gregory Weston

Matt Keyes wrote:


Hello again,

In C/C++ and the .NET languages I am used to, I have generally  
tried to prefix any member variables inside class methods with "this"


i.e. this.m_sMyString = "this is my string";

In Objective-C, this doesn't seem as clear to me (or at least it  
doesn't compile).  For example:


- (id)initWithString:(NSString *) string {
self.myString = [[NSString alloc] initWithString:string];
}

Produces an error:

error: request for member 'myString' in something not a structure  
or union


I am sure this is something very simple and basic I am missing, but  
any assistance is appreciated.


The short answer is: self is a pointer.

The longer answer is a question: Why do you do this? Do your naming  
conventions not make clear that something is an instance variable?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 on "self"

2008-08-11 Thread Charles Steinman
--- On Mon, 8/11/08, Todd Heberlein <[EMAIL PROTECTED]> wrote:

> Well, you don't need the "self" prefix, but
> you may want to look at  
> using "setters" and "getters". It would
> look like this
> 
> @interface MyThingy : NSObject {
>   ...
>   NSString*   myString;
>   ...
> };
> ...
> @property (copy) NSString* myString;
> ...
> @end
> 
> 
> 
> And then in the implementation file you would have
> something like this:
> 
> @implementation MyThingy
> ...
> @synthesize myString;
> ...
> @end
> 
> 
> And then, when you set the value, you do it like this:
> 
> [self setMyString: anotherString];

Using dot-syntax calls getters and setters. You would get exactly the same 
behavior by calling self.myString = anotherString.

Cheers,
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]


Opening an external file in a external application

2008-08-11 Thread John Love
I have a multiple document Cocoa app where I (try to) open an external  
file in whatever application the file belongs to -- in my case, an  
Excel spreadsheet in Excel.  The new Cocoa document window shown keeps  
track of the calculation progress in Excel via a NSProgressIndicator  
and a NSTextField.


So, instead of opening a text file and showing it directly in the  
NSWindow of MyDocument, I just want to startup Excel by selecting the  
appropriate  file in Cocoa's open dialog. I have 'XLS8' in my  
"info.plist" file. The Excel spreadsheet opens up and the  
NSProgressIndicator starts spinning and the appropriate text is placed  
in the NSTextField.


I believe I want to do this opening within my override of - 
readFromURL.  Am I on the right track here?


John Love

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Scott Ribe
> ...but it would surprise if you have to take the lock
> just to inspect the condition (per the "threadMustExit" method).

That part is correct, as it's the entire point behind conditions, atomically
check a condition and release the lock at the same time (and subsequently
relock)--in order to avoid race conditions between thread a releasing lock
and checking, and thread b setting...
 
-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Delayed termination to allow release

2008-08-11 Thread Trygve Inda
My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are ended,
something in the OS is retaining my objects for a bit... They end up never
being dealloc'd which messes a few things up as some data is written to disk
at this point.

This fixes it:

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
{
if (!prepareQuit)   // make sure we only do this part once
{
[myObjects release];// the OS still retains them for a bit
prepareQuit = YES;
}

if (objCount == 0)
return (NSTerminateNow);

else // wait around for everything to be cleaned up by the OS
{
   [[NSApplication sharedApplication]
performSelector:@selector(terminate:) withObject:nil afterDelay:0.5];
return (NSTerminateCancel);
}
}

In my obj alloc I set objCount++ and in the dealloc I set objCount--

Is there a better way around this?

Without delaying the termination for the OS to clean up (guessing some
autorelease pool), some of my objects are never dealloc'd and the app simply
goes away with no error.

Thoughts?

Thanks,

Trygve


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Dev Style: Using Class versus Object Methods

2008-08-11 Thread Christopher Nebel

On Aug 8, 2008, at 8:33 AM, Uli Kusterer wrote:


On 08.08.2008, at 07:28, Nick Zitzmann wrote:


On Aug 7, 2008, at 11:08 AM, Lee, Frederick wrote:

1)  why use instantiated objects versus classes (via class  
methods)?


Because class methods other than +new return autoreleased objects,  
which makes non-GC memory management a little bit easier.


This is simply wrong. Ignore that. A counterexample would be +alloc.  
Better read Apple's memory management rules if you want to know the  
correct story.


As a blanket rule, sure.  However, classes will often define class  
methods that act as conveniences for the longer instance  
initializers.  Consider NSArray:


+ (id) arrayWithArray:(NSArray *) array
- (id) initWithArray:(NSArray *) array

Both of these follow the normal memory management rules, so  
+arrayWithArray: returns an autoreleased object, while -initWithArray:  
doesn't, so these two expressions are equivalent:


[NSArray arrayWithArray:x]
[[[NSArray alloc] initWithArray:x] autorelease]

Presumably this is what Mr. Zitzmann was referring to.


--Chris N.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSConditionLock vs MPQueue

2008-08-11 Thread Scott Ribe
If all your thread questions here relate to cleanly shutting down the
thread, you could just spin on isFinished. Then file a bug report asking for
a join method in NSThread...

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Challenge 18 in Hillegass Book

2008-08-11 Thread James G.


On Aug 10, 2008, at 10:03 AM, Kyle Sluder wrote:


On Sat, Aug 9, 2008 at 8:54 PM, James Gorham <[EMAIL PROTECTED]> wrote:
I think that's where I'm unclear. Making the Document class aware  
of the
view is easy enough with an IBOutlet. But how to properly make the  
view

aware of the document I'm unsure of.


You're missing the point.  You don't connect your NSDocument (model)
to your views, you have a controller in between.  This controller is
responsible for noticing/being notified when the document changes so
it can update the view, and it is also responsible for noticing/being
notified when the view changes so it can update the document.


Understood. For such an example, it seemed like creating a dedicated  
controller was a bit overkill, while not adhering strictly to MVC.


I ended up making the custom view an outlet in the document, and  
setting a pointer to the document as an ivar in the view. During  
redraw, the view requests the list of objects from the NSDocument.  
When new objects are added, the view messages the document to add them  
to the collection.


It looks like the line of code from Dave Carrigan could have solved it  
pretty easily as well, without requiring the NSDocument ivar.



id doc = [[[self window] windowController] document]


So yes, the document does end up acting as both the controller and  
model, but it works well enough for this simple application.


Thanks to all for their input, it was helpful in both achieving the  
solution and increasing my understanding.


-James

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Use of AppKit in command-line app on headless node

2008-08-11 Thread Rick Hoge


Hi -

I am trying to factor some frameworks so that code used in a document- 
based Cocoa app can be shared with command-line tools that might run  
on a headless node (no window server).


I've seen some discussion in the past on questions such as whether  
NSImage and related classes can be used headless.  It seems that this  
works, but it's necessary to initialize and NSApplication instance for  
the classes to work correctly.


I realize that many AppKit functions will not be meaningful in a  
headless context.  However I am wondering if, for example, it would be  
possible (and safe) to use an NSDocument subclass instance in the  
following way in a headless app:


  MyDocument *doc = [[[MyDocument] alloc] init];
  [doc readFromURL:url ofType:type error:error];

The idea would simply be to use the instance as a container for some  
data, and use the file read and write methods I've already implemented  
for the doc-based interactive application.  This seems to work in some  
simple test apps I've written, but I'm wondering if there is anything  
risky about this that could become a problem in the future.


Also, when is it necessary to initialize an NSApplication instance?   
Is this just an NSImage thing?  or is it a more general AppKit  
requirement.


Thanks for any suggestions,

Rick






___

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

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

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

This email sent to [EMAIL PROTECTED]


Opening an external file in a external application

2008-08-11 Thread John Love
I have a multiple document Cocoa app where I (try to) open an external  
file in whatever application the file belongs to -- in my case, an  
Excel spreadsheet in Excel.  The new Cocoa document window shown keeps  
track of the calculation progress in Excel via a NSProgressIndicator  
and a NSTextField.


So, instead of opening a text file and showing it directly in the  
NSWindow of MyDocument, I just want to startup Excel by selecting the  
appropriate  file in Cocoa's open dialog. I have 'XLS8' in my  
"info.plist" file. The Excel spreadsheet opens up and the  
NSProgressIndicator starts spinning and the appropriate text is placed  
in the NSTextField.


I believe I want to do this opening within my override of - 
readFromURL.  Am I on the right track here?


John Love
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delayed termination to allow release

2008-08-11 Thread David Duncan

On Aug 11, 2008, at 11:33 AM, Trygve Inda wrote:


My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are  
ended,
something in the OS is retaining my objects for a bit... They end up  
never
being dealloc'd which messes a few things up as some data is written  
to disk

at this point.



-dealloc is short circuited when an application is quit (as  
deallocation is going to occur due to the application's memory space  
going away).


You should arrange for things that need to occur on application quit  
to occur in -applicationShouldTerminate: without relying on object  
lifetimes to do this (if you ever write a GC enabled application you  
will find you have the same issues in that you cannot message an  
object in -finalize reliably).

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delayed termination to allow release

2008-08-11 Thread Charles Steinman
--- On Mon, 8/11/08, Trygve Inda <[EMAIL PROTECTED]> wrote:

> My main thread creates a few other objects which have
> NSThreads and/or
> timers. I have found that when I quit the app, and the
> threads are ended,
> something in the OS is retaining my objects for a bit...
> They end up never
> being dealloc'd which messes a few things up as some
> data is written to disk
> at this point.

>From the docs:
"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."

In other words, you shouldn't assume dealloc will be called and it's generally 
not a good idea to perform essential cleanup there. The designated place for 
application cleanup code is applicationWillTerminate:.

Cheers,
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: Memory Leaks & Instruments Questions

2008-08-11 Thread Michael Kaye
Thanks for the reply - very helpful. Looks like I have some work to  
do. Appreciate the explanation of the singleton business too.


To the other replier - no I'm not using GC with this app but thanks  
for the pointer.


Regards. Michael.

On 11 Aug 2008, at 16:21, Nathan Vander Wilt wrote:


On Aug 10, 2008, at 12:37 PM, Michael Kaye wrote:
I've ben running my app with leaks in Instruments and it is  
reporting a fair number of leaks.


On analyzing these leaks, they all appear to be related to apple  
frameworks methods/code and never as a direct result of any objects  
I've instantiated.


Therefore my question is, is whether this is correct and what you  
would normally expect to see? Or are the leaks indirectly caused by  
something I am doing? If the former should I just ignore them and  
if the latter how do I track down exactly where it is occurring.


While I have seen an occasional report of a leak from the run loop  
throughout a really long (~20 minutes) analysis session, if you have  
a fair number of leaks I think its safe to assume they are of your  
doing.


A couple tips:
- If you are viewing the list of allocations for a particular block,  
oftentimes you may see a whole lot of framework activity in the  
history. Remember that the last line is the only one that leaked.
- While tracking down a couple hard-to-find leaks last week, I found  
the "Outline View" with "Invert Call Tree" to be quite helpful. It  
not only shows the root functions that leaked (eg malloc), but  
allows you to look and see what all called that and leaked, and so  
on. That way you can move up past the frameworks to see which of  
your functions are calling the low-level stuff.
- If your program is still running, you can double-click a leaking  
method/function to pull it up in Xcode for further scrutiny. Of  
course this only works for what you have source code access to, that  
is, your own methods. I'm not sure why it only works when running,  
YMMV on that.


Whilst we are on it, I have a second question and that is whether  
should I expect any singleton object to "appear" as a memory leak  
in Instruments. Obviously the point of a singleton is is that it  
has one instance and any instance variables exist with no dealloc.  
So does Instruments handle this or just report them as a leak?


To be useful, a reference must be kept to the singleton. As long as  
this reference is kept, it has not leaked. A leak is when an object/ 
memory is allocated, but then all references to the object are lost.  
In this scenario there is no way to release/autorelease/free it  
anymore, ever, so it has leaked. But when there is still a reference  
to an object, Leaks will assume you are waiting to release it later.


hope this helps,
-natevw
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Trygve Inda
> Key Trygve,
> 
> This looks similar to the threading code we talked about a while
> back. Far be it for me to say that my threading code is bugless :),
> but I haven't run into a deadlock problem, and the code you posted
> has two changes that would give me pause...
> 
> 
>> [self performSelectorOnMainThread:@selector
>> (doThreadUnsafeStuff)
>>   withObject:nil waitUntilDone:YES];
> 
> Probably not the problem, but I've often used
> performSelectorOnMainThread: in thread methods, but always passing NO
> to waitUntilDone. What is your doThreadUnsafeStuff doing? In my case,
> it's always just passing a percentage done value back to the main
> thread or something like that. If your thread depends on what
> doThreadUnsafeStuff does, then I guess it has to doe shave wait until
> it's done. But if it's just UI stuff, why wait?

It is doing some stuff that is not Thread Safe and the code following is
dependent up on it.

>> if ([lock lockWhenCondition:kConditionThreadMustExit)
> 
> Seems like this may be the real problem. I think Apple misnamed
> lockWhenCondition: - it should've been called "blockUntilCondition".
> With this in mind, isn't the thread loop going to run once, then
> block and stay blocked until the main thread tells it to exit? I
> think it is...

Sorry - this got truncated somehow. Supposed to be:

if ([lock lockWhenCondition:kConditionThreadMustExit beforeDate:[engine
blockUntil]])

This is there because I want the thread to not repeat quickly... Because
this is used to throttle it elsewhere, the block delay will be short
typically.

> Threading code always seems to bring in "just one more thing", and
> doubtless you used the above for good reasons. Looking at it alone,
> though, it just seems like more locking than necessary. The pattern
> I've successfully used (so far - always with the slight suspicion
> that "one more thing" will crop up and break it :) is more like:

I think the issue here is that if I dispatch with
performSelectorOnMainThread (with waitUntilDone:YES), then the thread block
and if killThread gets called while the dispatch is happening but before it
is processed, then each part is waiting for the other.

Not quite sure how to deal with this yet.

Trygve


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Change in NSDocument between 10.4 and 10.5

2008-08-11 Thread Randall Meadows
The application I'm working on is NSDocument-based.  In my client's  
workflow, these documents will typically live on a server volume  
mounted on the desktop, and be edited from there.  When a document is  
opened, it's file name (extension)[1] is changed to indicate that it  
is currently being edited (so when someone else opens that same  
document off the server, they get a message to that effect).  When the  
document is closed, the name is changed back, indicating that others  
may now edit the document.


On 10.4, when the document was edited, pressing cmd-S simply saved the  
document.


On 10.5, when the document is edited, pressing cmd-S now brings up an  
additional dialog, informing the user that "This document has been  
renamed to . It will be saved under this new name, or you  
can provide another name. [Save As...] [Cancel] [Save]".


This appears to be a change in the underlying frameworks, as the same  
executable behaves differently on the different OS versions.  (At  
least, that's my conclusion based on conversations with the client.)


Since I'm controlling the name changing and the saving and all that  
jazz, is there a way I can suppress this new dialog on 10.5?


Thanks.
randy

[1] - I'm currently using the deprecated -setFileName:, but - 
setFileURL: behaves similarly.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why use NSObjectController?

2008-08-11 Thread Mike Abdullah
But then you'd have to figure out which text field to send it to, and  
whether the command is necessary. NSObjectController takes care of  
that for you.


On 11 Aug 2008, at 19:05, R.L. Grigg wrote:



On Aug 11, 2008, at 8:52 AM, Sean McBride wrote:


But it seems you can't
send commitEditing to a textfield.


Why? If this was supported, wouldn't it greatly simplify things,  
meaning no need to have a NSController subclass, etc.? This is what  
confuses alot of newbs like me. Not arguing against it, just trying  
to see the motivation behind it.


Russ

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delayed termination to allow release

2008-08-11 Thread Negm-Awad Amin


Am Mo,11.08.2008 um 20:33 schrieb Trygve Inda:


My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are  
ended,
something in the OS is retaining my objects for a bit... They end up  
never
being dealloc'd which messes a few things up as some data is written  
to disk

at this point.
[…]
What you are doing is finalization.  In most cases this is simply a  
wrong design. -dealloc is for


1. memory management
2. memory management
3. memory management

It is not for additional functionality bound to an instance. (I do  
know what I talk about, because I did this mistake many times.)


If you find no other solution just register your threads (whatever) in  
the app-delegate and clean it up at -applicationDidFinishLaunching..



Amin Negm-Awad
[EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Use of AppKit in command-line app on headless node

2008-08-11 Thread Rick Hoge



I am trying to factor some frameworks so that code used in a  
document-based Cocoa app can be shared with command-line tools that  
might run on a headless node (no window server).


I've seen some discussion in the past on questions such as whether  
NSImage and related classes can be used headless.  It seems that  
this works, but it's necessary to initialize and NSApplication  
instance for the classes to work correctly.



I noticed that there is some useful info relating to this topic in the  
documentation on Agents and Daemons at


  http://developer.apple.com/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY

It does say that AppKit is not daemon-safe, but my testing suggests  
that if (as suggested in the technote) you avoid sensitive methods it  
should be ok (more info would be welcome).


I should also mention that the code in question would potentially be  
run under Xgrid - have not tested this yet;  wonder if there could be  
bootstrap namespace issues here...


Rick
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delayed termination to allow release

2008-08-11 Thread Trygve Inda
> --- On Mon, 8/11/08, Trygve Inda <[EMAIL PROTECTED]> wrote:
> 
>> My main thread creates a few other objects which have
>> NSThreads and/or
>> timers. I have found that when I quit the app, and the
>> threads are ended,
>> something in the OS is retaining my objects for a bit...
>> They end up never
>> being dealloc'd which messes a few things up as some
>> data is written to disk
>> at this point.
> 
>> From the docs:
> "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."
> 
> In other words, you shouldn't assume dealloc will be called and it's generally
> not a good idea to perform essential cleanup there. The designated place for
> application cleanup code is applicationWillTerminate:.
> 
> Cheers,
> Chuck


Hmmm... This is not so much my app cleaning up (it is not dealloc on my
AppController) but a series of sub objects which dealloc. I guess I'll have
to break out the cleanup code... Makes it less clean :) , but oh well.

T.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Delayed termination to allow release

2008-08-11 Thread Gregory Weston

Trygve Inda wrote:


My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are  
ended,
something in the OS is retaining my objects for a bit... They end  
up never
being dealloc'd which messes a few things up as some data is  
written to disk

at this point.

...

In my obj alloc I set objCount++ and in the dealloc I set objCount--

Is there a better way around this?

Without delaying the termination for the OS to clean up (guessing some
autorelease pool), some of my objects are never dealloc'd and the  
app simply

goes away with no error.

Thoughts?


My primary thought is that dealloc is not the place to perform  
required termination-time tasks, because there's no guarantee it'll  
be called. Deallocation is where you let go of subsidiary  
allocations. If you've got objects that need to do things at  
termination, register them as observers of  
NSApplicationWillTerminateNotification.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Peter Duniho

Date: Mon, 11 Aug 2008 12:29:55 -0600
From: Scott Ribe <[EMAIL PROTECTED]>


...but it would surprise if you have to take the lock
just to inspect the condition (per the "threadMustExit" method).


That part is correct, as it's the entire point behind conditions,  
atomically
check a condition and release the lock at the same time (and  
subsequently
relock)--in order to avoid race conditions between thread a  
releasing lock

and checking, and thread b setting...


Which part is correct?  The original code?  Or my comment?

It's true that for scenarios where one wants to change the condition  
as a dependency of the current condition, the  
"lock"/"unlockWithCondition" pattern is needed.


But the code posted gains nothing by locking and unlocking while  
checking the condition, since it locks unconditionally and doesn't  
change the condition state as a result of its inspection.  Inasmuch  
as a race condition might exist, the code that was posted doesn't  
avoid it (note that "race condition" can still happen even when  
locking...not all race conditions are bad, they just need to be  
accounted for) because in the method I was describing, the lock/ 
unlock behavior in the code doesn't use the "Condition" part of the  
NSConditionLock.


Now, it could be that there's something about how the class maintains  
the "condition" property that makes it a bug to not take the lock  
before inspection that property.  But that would be unusual for an  
object specifically designed for thread synchronization, and  
especially given that the documentation doesn't mention any  
requirement to take the lock before inspecting the property.


Pete
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Should I retain a variable returned from this accessor?

2008-08-11 Thread Sean DeNigris
Hi, how do I handle memory management for todoUid below?  Do I have to  
retain or autorelease it?


I'm using Scripting Bridge to communicate with iCal.  Also, this is a  
sub-routine and todoUid will only be used in the method that calls it.


- (NSString*) saveToiCalTodo: (NSString*) theSummary : (id)  
theDescription

{
// Create new iCal todo
	iCalTodo* newTodo = [[[iCal classForScriptingClass:@"todo"] alloc]  
init];


// Add the todo to my iCal calendar
[[myCalendar todos] addObject:newTodo];

// Set its summary
[newTodo setSummary:theSummary];

// Store description
[newTodo setObjectDescription: theDescription];

// Get uid to return
NSString* todoUid = [newTodo uid];

// Clean up
[newTodo release];
newTodo = nil;

return todoUid;
}

Thanks in advance!
___

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

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

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

This email sent to [EMAIL PROTECTED]


Objective-C and Cocoa Training in the MD/DC/VA Area?

2008-08-11 Thread Lyndsey Ferguson


Hello,

Is anyone aware of training in the Maryland, DC, Virginia area? I'm  
already aware of AboutObjects.com, but I'm looking at all the options.


Thanks in advance,
Lyndsey Ferguson

---
Mr. Lyndsey Ferguson
[EMAIL PROTECTED]

http://winterlandexpat.blogspot.com/







___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie Question on "self"

2008-08-11 Thread Scott Ribe
> Using dot-syntax calls getters and setters. You would get exactly the same
> behavior by calling self.myString = anotherString.

That assumes Objective-C 2.

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie Question on "self"

2008-08-11 Thread Charles Steinman
--- On Mon, 8/11/08, Scott Ribe <[EMAIL PROTECTED]> wrote:

> > Using dot-syntax calls getters and setters. You would
> get exactly the same
> > behavior by calling self.myString = anotherString.
> 
> That assumes Objective-C 2.

The code in question was using properties with synthesized accessors. 
Objective-C 2 seems like a safe assumption.

Cheers,
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: Thread deadlock?

2008-08-11 Thread Scott Ribe
> Which part is correct?  The original code?

The original code was what I meant. However I was thinking of traditional
conditions & locks; NSConditionLock does operate at a higher level, and you
are right that there is no need for an unconditional lock. But really, I
don't see a need for a lock at all.

volatile int threadStatus = kConditionRun;


-(void)awakeFromNib
{
[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:self];
}


- (void)threadMethod:(id)anObject
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

while (threadStatus == kConditionRun)
 [self doStuff];

[pool release];

[self performSelectorOnMainThread:@selector(threadHasExited)
  withObject:nil waitUntilDone:NO];
}


-(void)requestThreadExit
{
threadStatus = kConditionThreadMustExit;
}


-(void) threadHasExited
{
// clean up here
}


-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Use of AppKit in command-line app on headless node

2008-08-11 Thread Ken Ferry
Hi Rick,

I think you might be misreading that technote.. what it says is that
trying to guess which methods are and are not safe doesn't work,
because a method that does not happen to require the windowserver in
one release may require it in another.  The section you're quoting is
about what to do if you're going to ignore that fact.  It's better not
to ignore it.

AppKit in general requires a window server connection.  It would be
nice if there was a defined subset that was safe, but there is not at
the moment.  There may be exceptions where there is a pledge that
something works without a windowserver connection, but it's going to
be an opt-in situation. That is, unless you see otherwise, it method
is contractually free use the windowserver.

It's possible that NSDocument could make that pledge, but I don't know.

If you're asking about the reality of today's situation rather than
the contract, then yes, many parts of AppKit do require the
windowserver.

-Ken
Cocoa Frameworks

On Mon, Aug 11, 2008 at 11:58 AM, Rick Hoge <[EMAIL PROTECTED]> wrote:
>
>
>> I am trying to factor some frameworks so that code used in a
>> document-based Cocoa app can be shared with command-line tools that might
>> run on a headless node (no window server).
>>
>> I've seen some discussion in the past on questions such as whether NSImage
>> and related classes can be used headless.  It seems that this works, but
>> it's necessary to initialize and NSApplication instance for the classes to
>> work correctly.
>
>
> I noticed that there is some useful info relating to this topic in the
> documentation on Agents and Daemons at
>
>  http://developer.apple.com/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY
>
> It does say that AppKit is not daemon-safe, but my testing suggests that if
> (as suggested in the technote) you avoid sensitive methods it should be ok
> (more info would be welcome).
>
> I should also mention that the code in question would potentially be run
> under Xgrid - have not tested this yet;  wonder if there could be bootstrap
> namespace issues here...
>
> Rick
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Objective-C and Cocoa Training in the MD/DC/VA Area?

2008-08-11 Thread Kyle Sluder
On Mon, Aug 11, 2008 at 3:13 PM, Lyndsey Ferguson
<[EMAIL PROTECTED]> wrote:
> Is anyone aware of training in the Maryland, DC, Virginia area? I'm already
> aware of AboutObjects.com, but I'm looking at all the options.

Though it's not really training so much as an informal meetup, there's
an NSCoder Night chapter that meets at La Madeleine in Bethesda, but
I've never actually made it down there.  Balto to DC on Tuesday night
is too much of a PITA.  http://nscodernight.com/?cat=6

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Use of AppKit in command-line app on headless node

2008-08-11 Thread Jean-Daniel Dupas


Le 11 août 08 à 22:26, Ken Ferry a écrit :


Hi Rick,

I think you might be misreading that technote.. what it says is that
trying to guess which methods are and are not safe doesn't work,
because a method that does not happen to require the windowserver in
one release may require it in another.  The section you're quoting is
about what to do if you're going to ignore that fact.  It's better not
to ignore it.


That may be even worse. For example, the last time I tried, NSImage  
can be successfully created with most files format, but failed with  
icns files.

So even in one release, some API may not work reliably.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Should I retain a variable returned from this accessor?

2008-08-11 Thread Kyle Sluder
On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris <[EMAIL PROTECTED]> wrote:
> Hi, how do I handle memory management for todoUid below?  Do I have to
> retain or autorelease it?
>
> [...snip...]
>
>// Get uid to return
>NSString* todoUid = [newTodo uid];
>
> [...snip...]
>
>return todoUid;
> }

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html

You've gotten todoUid from a method that is not +alloc and does not
begin with +new or contain -copy, so you do not own it.  Therefore you
must -retain it if you want to hold on to it beyond "now".  Since you
don't, just let it go, it's not your responsibility.

That's it.  Done.  If you're really paranoid, you could instead hand
off a copy of todoUid that you know is not mutable by instead
returning [[todoUid copy] autorelease], but that seems unnecessary.
After all, your caller (and even you) can't be sure that todoUid is
mutable at all, since it's only known to be an NSString.  In this
case, however, since you're using -copy, you are responsible for that
copy and so must autorelease it.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Use of AppKit in command-line app on headless node

2008-08-11 Thread Michael Ash
On Mon, Aug 11, 2008 at 2:58 PM, Rick Hoge <[EMAIL PROTECTED]> wrote:
>
>
>> I am trying to factor some frameworks so that code used in a
>> document-based Cocoa app can be shared with command-line tools that might
>> run on a headless node (no window server).
>>
>> I've seen some discussion in the past on questions such as whether NSImage
>> and related classes can be used headless.  It seems that this works, but
>> it's necessary to initialize and NSApplication instance for the classes to
>> work correctly.
>
>
> I noticed that there is some useful info relating to this topic in the
> documentation on Agents and Daemons at
>
>  http://developer.apple.com/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY
>
> It does say that AppKit is not daemon-safe, but my testing suggests that if
> (as suggested in the technote) you avoid sensitive methods it should be ok
> (more info would be welcome).

I'm curious as to whether you really read the thing

"A routine might behave differently depending on its input parameters.
For example, an image decompression routine might work for some types
of images and fail for others."

"The behavior of any given framework, and the routines within that
framework, can change from release-to-release."

In other words, you're playing with fire in a gasoline-soaked shed.
Just because you haven't been burned horribly *yet* doesn't mean you
won't be.

AppKit requires a window server connection, full stop. To the extent
that it functions without one, this behavior is unsupported,
unreliable, and highly risky. Don't do it.

In case you didn't know, having a window server connection isn't the
same as being a GUI app, however. You just need to be able to connect
to it. Realistically, this means either having a user who's logged in
to the GUI and always running as that user, or running as root and not
logging in or out.

And lastly, as far as I know you must initialize NSApplication before
touching AppKit in any other way. Like the window server requirement,
you may be able to get away without doing it sometimes but you should
never rely on it.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Nathan Kinsinger

On Aug 11, 2008, at 1:12 PM, Sean DeNigris wrote:

Hi, how do I handle memory management for todoUid below?  Do I have  
to retain or autorelease it?


I'm using Scripting Bridge to communicate with iCal.  Also, this is  
a sub-routine and todoUid will only be used in the method that calls  
it.


- (NSString*) saveToiCalTodo: (NSString*) theSummary : (id)  
theDescription

{
// Create new iCal todo
	iCalTodo* newTodo = [[[iCal classForScriptingClass:@"todo"] alloc]  
init];


// Add the todo to my iCal calendar
[[myCalendar todos] addObject:newTodo];

// Set its summary
[newTodo setSummary:theSummary];

// Store description
[newTodo setObjectDescription: theDescription];

// Get uid to return
NSString* todoUid = [newTodo uid];

// Clean up
[newTodo release];
newTodo = nil;

return todoUid;
}

Thanks in advance!


You don't need to retain it here. Whatever method called this one  
should decide if it wants to retain it based on it's use of the uid.  
For example, the calling code may add the uid to an NSArray which  
handles keeping references to it's objects and thus you wouldn't  
retain it yourself. But if the calling code just stored it in an ivar  
then you may need to retain it based on how it's accessors are set up.  
Only the calling code would know which it needs.


You may want to read up on memory management:
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html


A few points on style, it would be better to use a keyword for the  
theDescription parameter. It makes it easier to read and debug in the  
calling code. Also since you are returning a value I would add that to  
the method name.


A suggestion for an alternate method name...  
uidForSavingiCalTodoSummary: withDescription:


This allows someone reading/scanning the calling code to know what is  
being returned (uid), what is being done (saving), and what  
information is needed (a summary and a description).



--Nathan



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Trygve Inda
>> Which part is correct?  The original code?
> 
> The original code was what I meant. However I was thinking of traditional
> conditions & locks; NSConditionLock does operate at a higher level, and you
> are right that there is no need for an unconditional lock. But really, I
> don't see a need for a lock at all.
> 

The real issue here is that I need to use

[self performSelectorOnMainThread:@selector(doUnsafeStuff)
  withObject:nil waitUntilDone:YES];

Which blocks until the method completes, so I need a way to end the thread,
but in the original code the killThread method blocks waiting for the thread
to finish.

I probably need to launch a timer or other notification system when the
thread finishes.

Trygve


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Scott Ribe
> Which blocks until the method completes, so I need a way to end the thread,
> but in the original code the killThread method blocks waiting for the thread
> to finish.
> 
> I probably need to launch a timer or other notification system when the
> thread finishes.

Why?

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Trygve Inda
There is a chance that my calls to performSelectorOnMainThread can have
waitUntilDone:NO

I use [myNSData writeToFile:path atomically:YES]

NSFileHandle and NSFileManager are shown as not thread safe, but NSData
is... Perhaps it is ok, but I would think NSData uses one or both of the
above.

One of the calls to performSelectorOnMainThread may need to wait on a file
download, but I think that could be a different lock.

Trygve 


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Scott Ribe
> There is a chance that my calls to performSelectorOnMainThread can have
> waitUntilDone:NO
> 
> I use [myNSData writeToFile:path atomically:YES]
> 
> NSFileHandle and NSFileManager are shown as not thread safe, but NSData
> is... Perhaps it is ok, but I would think NSData uses one or both of the
> above.
> 
> One of the calls to performSelectorOnMainThread may need to wait on a file
> download, but I think that could be a different lock.

I think you're missing the point: once the thread has detected that it
should quit, it calls as its last statement performSelectorOnMainThread for
whatever needs to be done on the main thread, and then just falls off the
end. When the the selector is called in the main thread, you know at that
point that the thread is done--there's no need to wait for the thread to
terminate.

What do you need done that is not done by the sample code that I posted?

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: including a cocoa bundle in a carbon app

2008-08-11 Thread Bob Sabiston


On Aug 10, 2008, at 6:39 PM, Uli Kusterer wrote:


On 10.08.2008, at 19:38, Bob Sabiston wrote:
I got my Cocoa bundle to compile on the Intel machine.  It still  
doesn't load within my app, though.  Is there something special I  
need to do to include it in my project? I just dragged it in on the  
left, amongst all the other types of files, and it gave me a menu  
of targets from which I selected the correct one.  But the load is  
still failing.  I'm using the function below, gotten from Apple's  
examples.  Anyone know what could be the problem?  CFBundleCreate  
is just setting bundlePtr to 0, I don't know why.



I've done stuff like that and it worked fine for me (heck, I've  
loaded CFM bundles into Mach-O apps). What template did you use as a  
basis for your bundle? You keep saying bundle, but the variable  
names mention frameworks. Now, there are different ways of building  
stuff like that. E.g. frameworks contain a path they expect to be  
loaded at (installation path setting), while bundles as they're used  
for plugins generally don't.


Did you perhaps mix those up? Alternately, are you perhaps mixing  
debug and release builds? Anything not 100% homogeneous in there?


Cheers,
-- Uli Kusterer


Well, I checked the builds -- one was Debug, one was Release.  Now  
they are both Debug, and it does get farther than it did before.   
CFBundleCreate() is returning a valid bundle now, instead of 0.  But  
then I try to use it, starting with this:


funcPtr = (FunkyPtr)  
CFBundleGetFunctionPointerForName(runbundleRef,  
CFSTR("initializeRTBundle"));


It returns 0 for the function pointer.  So something still isn't  
working.  Anyone know what could be the problem?


Thanks
Bob


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Trygve Inda
>> There is a chance that my calls to performSelectorOnMainThread can have
>> waitUntilDone:NO
>> 
>> I use [myNSData writeToFile:path atomically:YES]
>> 
>> NSFileHandle and NSFileManager are shown as not thread safe, but NSData
>> is... Perhaps it is ok, but I would think NSData uses one or both of the
>> above.
>> 
>> One of the calls to performSelectorOnMainThread may need to wait on a file
>> download, but I think that could be a different lock.
> 
> I think you're missing the point: once the thread has detected that it
> should quit, it calls as its last statement performSelectorOnMainThread for
> whatever needs to be done on the main thread, and then just falls off the
> end. When the the selector is called in the main thread, you know at that
> point that the thread is done--there's no need to wait for the thread to
> terminate.
> 
> What do you need done that is not done by the sample code that I posted?

In the middle of the thread processing, I need to do some processing on a
downloaded file. The file may be in the middle of being downloaded, so I
need to possibly block until it is ready, then have the main thread do some
work, and return to the thread.

T.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


List box like in Mail app

2008-08-11 Thread Devraj Mukherjee
Hi all,

I want to create a user interface that kind of looks like the Mail
application (so a left hand toolbar with options and the right hand
pane has different views presented depending on the selection).

My question is how do I go about creating a list item that is

1. Grouped like in Mail
2. Has a number associated to the list
3. Icons for each list item

I am assuming I should be looking at a table view to do this?

Any suggestions?

Thanks.

-- 
"I never look back darling, it distracts from the now", Edna Mode (The
Incredibles)
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: List box like in Mail app

2008-08-11 Thread Kyle Sluder
On Mon, Aug 11, 2008 at 7:23 PM, Devraj Mukherjee <[EMAIL PROTECTED]> wrote:
> 1. Grouped like in Mail

-outlineView:isGroupItem: NSOutlineView delegate method.

> 2. Has a number associated to the list

Custom NSCell subclass for column.

> 3. Icons for each list item

Column with NSImageCell.

> I am assuming I should be looking at a table view to do this?

What you're describing is called a "source list", and is now possible
to get using NSOutlineView.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Thread deadlock?

2008-08-11 Thread Peter Duniho

Date: Mon, 11 Aug 2008 21:15:27 +
From: Trygve Inda <[EMAIL PROTECTED]>

The real issue here is that I need to use

[self performSelectorOnMainThread:@selector(doUnsafeStuff)
  withObject:nil waitUntilDone:YES];

Which blocks until the method completes, so I need a way to end the  
thread,
but in the original code the killThread method blocks waiting for  
the thread

to finish.


I tend to agree with Scott's assessment, that you code _appears_ to  
be going overboard on the locking.  It's not clear at all that you  
need to have any thread blocked waiting for a lock at all.


I also wonder how it is you managed to get yourself into a situation  
where you've got a worker thread that for some reason is still  
dependent on code that has to run on the main thread.


That said, without knowing the broader design it's difficult to say  
for sure.  As I and others have pointed out, the code you posted  
obviously isn't the actual code, so we can't even use that to guide  
us.  Maybe you do in fact have some need for locking that's not  
apparent to us.


So, if we assume that you do need the locking, then you need to  
resolve the deadlock somehow of course.  And as I mentioned before,  
it's generally just plain a bad idea to have something in a special  
thread (like Cocoa's "main thread") wind up blocked on anything at all.


It's not clear at all why you want your main thread to wait for the  
worker thread to exit, but it seems to me that what you probably  
ought to be doing is having your worker thread invoke yet another  
method to be executed on the main thread, just before it exits (and  
probably with "waitUntilDone:NO" instead).


That would allow you to execute whatever code it is you're trying to  
execute on the main thread at the time you want it to, but without  
having the main thread just sit there and wait for the worker thread.


Pete
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread deadlock?

2008-08-11 Thread Michael Ash
On Mon, Aug 11, 2008 at 5:15 PM, Trygve Inda <[EMAIL PROTECTED]> wrote:
>>> Which part is correct?  The original code?
>>
>> The original code was what I meant. However I was thinking of traditional
>> conditions & locks; NSConditionLock does operate at a higher level, and you
>> are right that there is no need for an unconditional lock. But really, I
>> don't see a need for a lock at all.
>>
>
> The real issue here is that I need to use
>
> [self performSelectorOnMainThread:@selector(doUnsafeStuff)
>  withObject:nil waitUntilDone:YES];
>
> Which blocks until the method completes, so I need a way to end the thread,
> but in the original code the killThread method blocks waiting for the thread
> to finish.

Well, the *real* issue is that you're using two mutually conflicting techniques:

1) Messaging the main thread and blocking until the result is available.

2) Terminating the thread by signaling it and then blocking until it
returns the signal.

It should be fairly clear, when put in those simple terms, that these
guys just aren't going to get along. The good news is that you only
need to fix *one* of them.

>From what you've shown and said about this code, it sounds like you
can probably fix #2 more easily. Just don't block when you signal
termination! There may be a reason you need to do this, but if so then
I haven't seen it. If you don't need to wait, then don't. Let the
secondary thread finish and clean up at leisure. Problem solved.

#1 can be fixed without a great deal of effort as well. You'd probably
pass NO for waitUntilDone, and then implement your own blocking
mechanism using that NSConditionLock.

And lastly, you might be able to make #1 go away altogether. In
another message you indicated that the main thread messaging is just
for writing and downloading files. Unless I misunderstood, there's no
reason for either of those to be on the main thread.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: List box like in Mail app

2008-08-11 Thread I. Savant

On Aug 11, 2008, at 7:30 PM, Kyle Sluder wrote:


3. Icons for each list item


Column with NSImageCell.


  Well ... this will require another custom cell if you're planning  
on using an outline view because of the disclosure triangle and  
indentation. Search your local example code for "ImageAndTextCell".


--
I.S.




___

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

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

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

This email sent to [EMAIL PROTECTED]


  1   2   >