Re: Avoiding mutual retain cycles

2008-07-22 Thread Quincey Morris

On Jul 21, 2008, at 20:27, Markus Spoettl wrote:

Call me a retro coward, but I absolutely dislike the idea of GC. I  
just don't see the point of it given the complicated implications it  
can have.


But I hope you do see the irony of that last statement, in the context  
of this thread.


FWIW, I have nothing bad to say about writing non-gc apps, or about  
anyone who writes non-gc apps, except that you couldn't pay me to go  
back to doing it. :)



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Avoiding mutual retain cycles

2008-07-22 Thread Markus Spoettl

On Jul 21, 2008, at 11:20 PM, Quincey Morris wrote:
Call me a retro coward, but I absolutely dislike the idea of GC. I  
just don't see the point of it given the complicated implications  
it can have.


But I hope you do see the irony of that last statement, in the  
context of this thread.



I knew this would backfire when I wrote it. What I meant to say was  
that you give up a lot of control over the inner workings of your  
application with GC and I don't like that idea too much. Just don't.


Anyway, it's great to have choices, so everyone can use what they  
think suits them best.


Markus
--
__
Markus Spoettl



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]

File types opened by NSDocument architecture

2008-07-22 Thread Tom Bernard
/*
+ (NSArray *)readableTypes
{
return [NSArray arrayWithObjects:@TIFF, @tiff, @TIF, @tif,
@GIF, @gif, @JPEG, @jpeg, @JPG, @jpg, @png, nil];
}
 */

My application needs to open the above listed file types. When I am in
Finder and I drag and drop one one of these files to my application, the
file opens. When I choose 'Open...' from my application's 'File' menu, only
.tif and .psd files are selectable in the open dialog.

Note that +readableTypes is commented out above. When I uncomment the method
in my NSDocument implementation, no files are selectable in the open dialog.

Here is an excerpt from my info.plist:


keyCFBundleDocumentTypes/key
array
dict
keyCFBundleTypeExtensions/key
array
stringpsd/string
/array
keyCFBundleTypeName/key
stringAdobe Photoshop file/string
keyCFBundleTypeOSTypes/key
array
stringpsd/string
/array
keyCFBundleTypeRole/key
stringEditor/string
keyLSTypeIsPackage/key
false/
keyNSDocumentClass/key
stringLIVDocument/string
keyNSPersistentStoreTypeKey/key
stringBinary/string
/dict
dict
keyCFBundleTypeExtensions/key
array
stringgif/string
/array
keyCFBundleTypeIconFile/key
string/string
keyCFBundleTypeName/key
stringLarge Image Viewer GIF Document/string
keyCFBundleTypeOSTypes/key
array
stringgif/string
/array
keyCFBundleTypeRole/key
stringEditor/string
keyLSTypeIsPackage/key
false/
keyNSDocumentClass/key
stringLIVDocument/string
/dict

...

/array

The info.plist includes a dictionary for each of the above listed types.

Thanks in advance.


Tom Bernard
[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: Weak link usage? @property?

2008-07-22 Thread Marco Masser

So what's the correct form of weak linking to avoid retain cycles?


Please be aware that weak has a different meaning depending on the  
context (GC vs non-GC).


Docs:

Note: In memory management, a nonretained object reference is known as  
a weak reference, which is something altogether different from a weak  
reference in a garbage-collected environment. In the latter, all  
references to objects are considered strong by default and are thus  
visible to the garbage collector; weak references, which must be  
marked with the __weak type modifier, are not visible. In garbage  
collection, retain cycles are not a problem.


http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_8.html


Wikipedia:

Garbage collection
Objective-C 2.0 provides an optional conservative yet generational  
garbage collector. When run in backwards-compatible mode, the runtime  
turns reference counting operations such as retain and release  
into no-ops. All objects are subject to garbage collection when  
garbage collection is enabled. Regular C pointers may be qualified  
with __strong to also trigger the underlying write-barrier compiler  
intercepts and thus participate in garbage collection. A zero-ing weak  
subsystem is also provided such that pointers marked as __weak are  
set to zero when the object (or more simply GC memory) is collected.


http://en.wikipedia.org/wiki/Objective-C#Garbage_collection


Do I need to avoid any @property settings for any weak linked  
objects and just deal with directly in my methods?


If you are not using the garbage collector, simply specify assign to  
get what is considered a weakly linked object. I didn't try that but  
from the above explanation, I'm pretty sure this is what you want.




Other question on @property  retaining

@property (nonatomic, retain) MyClass *myClass;

-(void)holderOfMyClass:(MyClass *)myClassObject;
{

[self setMyClass: myClassObject];   // this retains
self.myClass = myClassObject;   // this retains
	myClass = myClassObject;		// this does not retain?   Seems like it  
doesn't from my tests


}


The first two assignments are the same. The dot syntax simply is a  
shortcut for the first line. Therefore, using self.myClass = ...  
really invokes [self setMyClass:...], whereas myClass = ...  
directly accesses the ivar and doesn't use setters at all. If you  
declared a property like this, chances are good that you don't want to  
do that.
Take a look at the Objective-C 2.0 language guide, specifically at the  
docs about the dot syntax:


http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_2_section_3.html#/ 
/apple_ref/doc/uid/TP30001163-CH11-SW17

___

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

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

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

This email sent to [EMAIL PROTECTED]


Two Questions About Parsing a String

2008-07-22 Thread Ian Jackson

Hi,

I'm looking for some help parsing a string from a file.

Firstly, getting the string is causing some issues. I read the String  
Programming Guide for Cocoa, and got this:


NSString *path = ...;
NSData *data = [NSData dataWithContentsOfFile:path];

// assuming data is in UTF8
NSString *string = [NSString stringWithUTF8String:[data bytes]];

along with a warning that you must not use:

 stringWithContentsOfFile:

So, I tried to do as I was told, but using the first example, I find  
that successfully getting a string from the data is quite random. When  
I start the application, my first attempt to load the file may or may  
not result and a string being created, but if not, repeatedly trying  
to load the file eventually works and I get the string. I'm not sure  
what the encoding is, (I'm trying to create a .obj reader), but  
setting it at UTF8 in Xcode doesn't help.
So, I took a peek at the dark side, and tried the soon to be  
deprecated  stringWithContentsOfFile: which works fine all the time.  
Any thoughts on why the first example might be failing randomly?


My second question is NSScanner related. Going through the .obj file,  
I have managed to get a system going where it scans for key characters  
(e.g. v for vertex, # for commented text etc). Roughly:


while ([theScanner isAtEnd] == NO)
{
[theScanner scanUpToCharactersFromSet:vCharacters 
intoString:NULL];
[theScanner scanCharactersFromSet:vCharacters 
intoString:testString];

if ([testString isEqualToString:@#]) {
[theScanner scanUpToString:@\n 
intoString:dumpString];
NSLog(@dumpString is %@, dumpString);
}

else if ([testString isEqualToString:@o]) {
[theScanner scanUpToString:@\n 
intoString:theObjectName];
NSLog(@name: %@, theObjectName);
}

else if ([testString isEqualToString:@v]) {
[theScanner scanFloat:xVert];
[theScanner scanFloat:yVert];
[theScanner scanFloat:zVert];
			NSLog(@Vertex %i is: x = %f, y = %f, z = %f, ++i, xVert, yVert,  
zVert);

}
}   
}

However, the files also include identifiers such as usemtl, which  
could appear at any time. So any ideas how you go about searching for  
a set of characters, and a set of strings simultaneously? i.e. how do  
I search for the characters without momentarily ignoring the strings  
or vice versa? This seems to be quite straightforward with fscanf, but  
it seems a bit odd going to C, when I'm trying to do this in Objective- 
C.


Any help with either question would be much appreciated.

Thank you,

Ian.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File types opened by NSDocument architecture

2008-07-22 Thread Heinrich Giesen


On 22.07.2008, at 09:50, Tom Bernard wrote:


/*
+ (NSArray *)readableTypes
{
return [NSArray arrayWithObjects:@TIFF, @tiff, @TIF, @tif,
@GIF, @gif, @JPEG, @jpeg, @JPG, @jpg, @png, nil];
}
 */

My application needs to open the above listed file types. When I am in
Finder and I drag and drop one one of these files to my  
application, the
file opens. When I choose 'Open...' from my application's 'File'  
menu, only

.tif and .psd files are selectable in the open dialog.



Big misunderstanding; with readableTypes you have to return:
doc An array of NSString objects representing the readable  
document types. /doc




*document types* not *file/image types*

In your info.plist you define 2 doctypes Adobe Photoshop file and
Large Image Viewer GIF Document wich are responsible for files with
the extensions psd and gif.
Create in Xcode (info - Properties) another doctype which has as
CFBundleTypeExtensions a blank (?) separated list of the above image  
types.


Heinrich

--
Heinrich Giesen
[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]


SBApplication error with iTunes 7.7

2008-07-22 Thread Fabian
Hello all,

I have an app that interacts with iTunes via Scripting Bridge. After
upgrading to iTunes 7.7 I get this error message every time I call
[SBApplication applicationWithBundleIdentifier:@com.apple.iTunes].
The message is: 'unknown type name tdta.'

This doesn't seem to effect performance over here, but I have received
a lot of troubleshooting reports after the iTunes update was posted
and they all contain the same message, so I am afraid it can in fact
cause a problem on other machines.

I looked up tdta in the Apple event manager reference, where it is
declared a typeData constant of typeAEText.

Does anyone know what this means, maybe even how to solve it?

Thanks!
Fabian
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Being notified of changes to a file

2008-07-22 Thread Yann Disser

Ok, thank you all guys! I got it working somehow ^^

Here is my code (if anyone is interested - I am probably doing a lot  
of crazy things, please correct me):


#import Cocoa/Cocoa.h

@interface Observer : NSObject
{}
- (void) outputStuff:(NSNotification*)aNotification;
@end

@implementation Observer
- (void) outputStuff:(NSNotification*)aNotification
{
  id obj = [aNotification object];
  NSData* data = [[aNotification userInfo]  
objectForKey:NSFileHandleNotificationDataItem];

  if(data  [data length]  0)
  {
NSString* str = [[NSString alloc] initWithData:data  
encoding:NSASCIIStringEncoding];

NSLog(@ -- outputting stuff -- );
NSLog(str);
[obj readInBackgroundAndNotify];
  }
}
@end

int main(int argc, char *argv[])
{
  Observer* obs = [[Observer alloc] retain];

  NSTask* task = [[NSTask alloc] init];
  [task setLaunchPath:@numbers.rb];

  NSPipe* output = [NSPipe pipe];
  [task setStandardOutput:output];

  NSFileHandle* file = [output fileHandleForReading];

  [[NSNotificationCenter defaultCenter] addObserver:obs

selector:@selector(outputStuff:)

name:NSFileHandleReadCompletionNotification

 object:file];
  [file readInBackgroundAndNotify];
  [task launch];

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

And here is the ruby script:

#!/usr/bin/env ruby
STDOUT.sync = true
100.times do |i|
  puts i
  sleep 0.05
end

Thanks again,
Yann
___

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

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

2008-07-22 Thread Nicolas L.
Thank you - I have tried enabling NSZombie and it seems the object  
being freed is my managedObjectModel.


I really can't figure out why the MOM instance is being deallocated.
I don't have a lot of code to post since I'm using the standard Xcode- 
generated code for non-duc based CoreData apps. (An app delegate,  
instantiated in the MainMenu nib, and a bunch of accessors to get the  
persistent store coordinator, MOM and MOC the first time someone asks  
for them).


I enabled MallocStackLogging and looked up that xxx address with  
malloc_history pid xxx, and here's what the trace looks like:


=

Call [2] [arg=36]: thread_a00e2fa0 |start | main | NSApplicationMain |  
+[NSBundle(NSNibLoading) loadNibNamed:owner:] | + 
[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] | + 
[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:]  
| loadNib | -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]  
| -[NSNibBindingConnector establishConnection] | - 
[NSObject(NSKeyValueBindingCreation)  
bind:toObject:withKeyPath:options:] | -[NSBinder  
_performConnectionEstablishedRefresh] | -[NSObjectParameterBinder  
_observeValueForKeyPath:ofObject:context:] | -[NSObjectParameterBinder  
_updateObject:observedController:observedKeyPath:context:] | - 
[NSBinder valueForBinding:resolveMarkersToPlaceholders:] | -[NSBinder  
_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] | - 
[NSObject(NSKeyValueCoding) valueForKeyPath:] | - 
[NSObject(NSKeyValueCoding) valueForKey:] | -[AppDelegate  
managedObjectContext] | -[AppDelegate persistentStoreCoordinator] | - 
[AppDelegate managedObjectModel] | +[NSManagedObjectModel  
mergedModelFromBundles:] | -[NSManagedObjectModel  
initWithContentsOfURL:] | +[NSKeyedUnarchiver  
unarchiveObjectWithFile:] | _decodeObject | _decodeObjectBinary | + 
[NSObject allocWithZone:] | _internal_class_createInstance |  
_internal_class_createInstanceFromZone | calloc | malloc_zone_calloc


Call [4] [arg=0]: thread_b013e000 |thread_start | _pthread_start |  
minion_duties2 | CFRelease | -[_PFTask dealloc] | malloc_zone_free


Call [2] [arg=48]: thread_b013e000 |thread_start | _pthread_start |  
minion_duties2 | CFRelease | -[_PFTask dealloc] | NSDeallocateObject |  
objc_duplicateClass | calloc | malloc_zone_calloc


=

Any thoughts as to what minion_duties2 or PFTask is? I am not the one  
creating background threads in the app, so I take it thread_b013e000  
is Cocoa/CoreData's doing.
If the problem comes from my nib and bindings, is there a way to debug  
that?


Thanks!
Nicolas


On Jul 10, 2008, at 5:54 PM, Shawn Erickson wrote:

On Thu, Jul 10, 2008 at 6:56 AM, Nicolas Lapomarda [EMAIL PROTECTED] 
 wrote:



The error I'm getting is random as well, but always takes the form

  *** -[NSCFString _entityForName]: unrecognized selector sent  
to

instance xxx.


You likely are not retaining an object that you expect to stay around.
This results in that object getting deallocated and some other random
object dropping in at that address in memory.

You can enable NSZombie to help track down this issue.

http://developer.apple.com/technotes/tn2004/ 
tn2124.html#SECFOUNDATION


-Shawn


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Two Questions About Parsing a String

2008-07-22 Thread PGM

On 22-Jul-08, at 11:09 AM, Ian Jackson wrote:


I'm looking for some help parsing a string from a file.

Firstly, getting the string is causing some issues. I read the  
String Programming Guide for Cocoa, and got this:


NSString *path = ...;
NSData *data = [NSData dataWithContentsOfFile:path];

// assuming data is in UTF8
NSString *string = [NSString stringWithUTF8String:[data bytes]];

along with a warning that you must not use:

stringWithContentsOfFile:

So, I tried to do as I was told, but using the first example, I find  
that successfully getting a string from the data is quite random.  
When I start the application, my first attempt to load the file may  
or may not result and a string being created, but if not, repeatedly  
trying to load the file eventually works and I get the string. I'm  
not sure what the encoding is, (I'm trying to create a .obj reader),  
but setting it at UTF8 in Xcode doesn't help.
So, I took a peek at the dark side, and tried the soon to be  
deprecated  stringWithContentsOfFile: which works fine all the time.  
Any thoughts on why the first example might be failing randomly?





Have you tried the non-deprecated  
stringWithContentsOfFile:usedEncoding:error: or  
stringWithContentsOfFile:encoding:error: ? The former actually attemps  
to determine the encoding used for the file and returns that by  
reference. They also allow error handling, so you can determine why  
your files may not be read successfully.


Cheers, Patrick
___

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

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

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

This email sent to [EMAIL PROTECTED]


Page flip effect using Core Animation?

2008-07-22 Thread Demitri Muna

Hello,

I'm beginning to delve into Core Animation, and am trying to implement  
what (I think) should be a very simple effect. I want to rotate a  
50x50 layer around an axis defined by one of the edges which is fixed.  
The best analogy is looking down on a book and turning a page, the  
edge of the page being fixed in the binding. I have this so far:


CGFloat angle = DegreesToRadians(-180);

CATransform3D transform = CATransform3DIdentity;
layer.anchorPoint = CGPointMake(1.0, 0.5); // turn page to right
transform = CATransform3DRotate(transform, angle, 0, 1, 0); // y-axis  
rotation

transform = CATransform3DTranslate(transform, -25, 0, 0);
transform.m34 = 0.01f; // for pretty 3D effect
layer.transform = transform;

This is close in that the final and initial states are right, but the  
translation I added to get that makes the page move off the binding  
in the process. Also, why is the value -25 the right one to move the  
layer to the right position? I would have thought that it would be -50  
(i.e. the width).


Any help greatly appreciated!

Cheers,

Demitri

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1

2008-07-22 Thread Kyle Sluder
On Mon, Jul 21, 2008 at 5:02 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
NSString* csvString = [NSString stringWithContentsOfURL: lookupURL
 encoding: NSUTF8StringEncoding error: lookupError];

This line right here requires an autorelease pool.  Have you created
one for your thread?

It's apparent that you have a memory management issue somewhere in
your code.  Can you post more context?

--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: webDAV (lite) framework?

2008-07-22 Thread Kyle Sluder
On Mon, Jul 21, 2008 at 10:37 AM, William Bates
[EMAIL PROTECTED] wrote:
 Is there an objective-C webDAV framework around? I've been rolling my own (I
 only need some basic functionality) but can't image it hasn't been done
 already...

Does it not make sense for you to rely on Finder's built-in WebDAV
support?  Because if you can get away with it, it's great... I'm
having visions of Dreamweaver's go-it-alone attitude towards WebDAV
and how much happier I was when I could stop dealing with it by just
mounting my share in Finder.

--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: Weak link usage? @property?

2008-07-22 Thread Scott Squires

Yes, I typed in the wrong word.   Link instead of reference.

My point being:

1.  The compiler complains and states that 'assign' is incorrect for  
non-GC usage (if I don't explicitly state assign).
If i do use assign it doesn't complain but because it thinks  
assign is incorrect I wanted to verify it was ok instead of just a way  
to stop the compiler from complaining.


2.   Rules of when properties are used and when they aren't:
  [self setMyClass: myClassObject];
  self.myClass = myClassObject;
 myClass = myClassObject;


Since these all change the value of myClass it's certainly not obvious  
that the behavior itself should be different between them, especially  
if you're used to using C++  or when converting from previous Obj-C  
code.
Going through the documents in detail they do clarify this but I  
suspect it has caused a few bugs for people who might overlook these  
details.



___

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

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

2008-07-22 Thread em

Does it not make sense for you to rely on Finder's built-in WebDAV 
support?   
Absoutely not--that wouldn't make sense if I was looking for an 
objective-c framework.  And by the way, do you always answer  a 
question with another question?  Isn't that bizarre? 
-em

___

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

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

2008-07-22 Thread Matt Gough


On 22 Jul 2008, at 4:50pm, em wrote:


And by the way, do you always answer  a
question with another question?  Isn't that bizarre?


I don't know; is it?

(Sorry couldn't resist :) )
Matt
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Two Questions About Parsing a String

2008-07-22 Thread Jens Alfke


On 22 Jul '08, at 2:09 AM, Ian Jackson wrote:


NSString *path = ...;
NSData *data = [NSData dataWithContentsOfFile:path];
// assuming data is in UTF8
NSString *string = [NSString stringWithUTF8String:[data bytes]];


The reason this doesn't work is that -stringWithUTF8String: expects a  
NUL-terminated C string, but [data bytes] just returns the raw  
contents of the data block. So the string factory method will keep  
reading past the end of the data until it finds a zero byte in  
whatever happens to be randomly out there. That means it'll read  
garbage past the end of the string, and if that garbage doesn't look  
like valid UTF-8, it'll fail.


The correct call to make would be
[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]
although as Patrick already replied, the best way to read a string  
from a file is +stringWithContentsOfFile:usedEncoding:error:, which  
will attempt to determine the encoding.


However, the files also include identifiers such as usemtl, which  
could appear at any time. So any ideas how you go about searching  
for a set of characters, and a set of strings simultaneously? i.e.  
how do I search for the characters without momentarily ignoring the  
strings or vice versa? This seems to be quite straightforward with  
fscanf, but it seems a bit odd going to C, when I'm trying to do  
this in Objective-C.


This is beyond what NSScanner can do. You have a number of options,  
like scanning the string character by character using a 'for' loop,  
using a parser generator like ANTLR, or simply calling fscanf.  
(There's nothing wrong with using C APIs, when appropriate.)


—Jens

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: webDAV (lite) framework?

2008-07-22 Thread Jens Alfke


On 22 Jul '08, at 4:55 AM, Kyle Sluder wrote:


Does it not make sense for you to rely on Finder's built-in WebDAV
support?  Because if you can get away with it, it's great... I'm
having visions of Dreamweaver's go-it-alone attitude towards WebDAV
and how much happier I was when I could stop dealing with it by just
mounting my share in Finder.


It depends on what the OP wants to do. WebDAV isn't a file server  
protocol, even though it often gets (mis)used as one, and there are a  
lot of uses for it that don't involve accessing a filesystem. CalDAV  
is one example, and there are also schema for using WebDAV to access  
email on a server (I think Yahoo! mail supports this.)



em wrote:

Absoutely not--that wouldn't make sense if I was looking for an
objective-c framework.  And by the way, do you always answer  a
question with another question?  Isn't that bizarre?



Since you're not the original poster (nor have you contributed to this  
thread earlier) I don't see why you feel entitled to jump in with a  
decision that Kyle's answer is inappropriate for William's question.  
Your response also shows that you don't understand what Kyle is  
getting at: in some cases people do use WebDAV merely for accessing  
files on a server, in which case using the Finder would be a good  
alternative.


Answering with a question is entirely appropriate, as it politely  
indicates that your answer isn't definitive, but is providing more  
information for the original poster to come to his/her own conclusion  
with.


—Jens

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: [NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1

2008-07-22 Thread [EMAIL PROTECTED]

At 7:50 AM -0400 7/22/08, Kyle Sluder wrote:

On Mon, Jul 21, 2008 at 5:02 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

NSString* csvString = [NSString stringWithContentsOfURL: lookupURL
 encoding: NSUTF8StringEncoding error: lookupError];


This line right here requires an autorelease pool.  Have you created
one for your thread?

It's apparent that you have a memory management issue somewhere in
your code.  Can you post more context?

--Kyle Sluder


kyle,
thanx for the reply. yes, i do have an autorelease pool in place. i 
agree that it looks like some kind of memory management problem. the 
bothersome aspect is that this code used to work without any 
problems. and yes, i know thread problems aren't always reproducible, 
but the code has been in use problem free for sometime, probably 
going back as far as 10.5.3 or earlier. but i can't figure out what 
CFURL/NSURL is causing the problem. i'm not sure exactly what 
additional code is worth posting. given (what i believe is the 
relavent code):


NSURL* lookupURL = [[NSURL alloc] initWithString: urlLookupString];
NSError* lookupError = nil;
	NSString* csvString = [NSString stringWithContentsOfURL: 
lookupURL encoding: NSUTF8StringEncoding error: lookupError];

...
[lookupURL release];

the error occurs during the processing of stringWithContentsOfURL; i 
would assume that it would retain the passed in url as long as it 
needs it; and i retain it (alloc init) before making the call and 
don't release the url until after my call to stringWithContentsOfURL.


ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Garbage Collection Pre-Processor Flag

2008-07-22 Thread Jonathon Mah

Hi all,

Are Xcode build settings exposed as pre-processor variables? I know  
they're available when pre-processing Info.plists, but can't find a  
way to use them in source code files (.m).


I ask because it could be great if you could do something like this:

#ifdef OBJC_GC
#error This code doesn't support garbage collection
#endif

on a per-file basis. For example, you might have an app designed as GC- 
only, but have a few files you've updated from r/r. Then attempting to  
compile as GC-supported should throw an error for the GC-only code.




Jonathon Mah
[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]


Exception thrown when calling NSConnection connectionWithReceivePort:sendPort:

2008-07-22 Thread Chris Backas

Hello all,

This is a little long, the error is summarized at the bottom for  
anyone who wants to skip ahead though ;)


I have an application which is using Distributed Objects to ask a  
remote machine to obtain and interact with certain resources on its  
behalf. This has been working great so far, but recently I've been  
trying to add a new feature to the application. It needs to contact  
the remote resource over DO, perform some actions, then take down DO  
(Because it will be going off-LAN temporarily), perform some actions,  
THEN reconnect to DO and finish with the remote resource.


It's the 'reconnect' part that I'm having trouble with.  Let me share  
some code first though, the error will be at the end.


Here is the code I'm using to connect DO and obtain the remote root  
proxy:


-(id)getServerProxy
{
id ReturnMe = nil;
@try
{
// Establish a connection to the server
		DOConnectionSocket = [[NSSocketPort alloc] initRemoteWithTCPPort: 
[self getHostPort] host:[self getHost]];
		DOConnection = [[NSConnection connectionWithReceivePort:nil  
sendPort:DOConnectionSocket] retain];


// If the connection was succesful..
if (DOConnection != nil)
{
// Setup connection parameters
[DOConnection enableMultipleThreads];
// Allow a good long time for lengthy DB queries to 
complete
[DOConnection setRequestTimeout:60];
[DOConnection setReplyTimeout:60];

// Register to be notified if the connection dies
			[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(connectionDidDie:)  
name:NSConnectionDidDieNotification object:DOConnection];

}
ReturnMe = [DOConnection rootProxy];
}
@catch(NSException* error)
{
// Can't do much. Possibly a timeout?
NSLog(@Failed to get Server Proxy! %@,error);
ReturnMe = nil;
}
return ReturnMe;
}

Here's the code I use to shut down DO:

-(void)disconnectDO
{
connectionOpened = NO;
@synchronized(self)
{
		// Clean up and get rid of both proxy objects, but hang onto our  
connection ID

// So that we can seamlessly reconnect if possible
[serverProxyObject release]; serverProxyObject = nil;
[connectionProxyObject release]; connectionProxyObject = nil;

// Take down the connection too
		[[NSNotificationCenter defaultCenter] removeObserver:self  
name:NSConnectionDidDieNotification object:DOConnection];

[DOConnection invalidate];
[DOConnectionSocket invalidate];
[DOConnection release]; DOConnection = nil;
[DOConnectionSocket release]; DOConnectionSocket = nil;
}
}

So... the problem is that when I try to reconnect to DO, meaning, call  
getServerProxy the second time, I get an exception from the  
DOConnection = [[NSConnection connectionWithReceivePort:nil  
sendPort:DOConnectionSocket] retain]; line.


The exception:
*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil

The backtrace:
#0  0x971f30d7 in objc_exception_throw ()
#1  0x94fc3f2b in +[NSException raise:format:arguments:] ()
#2  0x94fc3f6a in +[NSException raise:format:] ()
#3  0x900ea3d0 in _NSArrayRaiseInsertNilException ()
#4  0x90008a04 in -[NSCFArray insertObject:atIndex:] ()
#5  0x90008914 in -[NSCFArray addObject:] ()
#6  0x90027d2d in -[NSConnection addRunLoop:] ()
#7  0x90027b8f in -[NSConnection initWithReceivePort:sendPort:] ()
#8  0x90042df7 in +[NSConnection connectionWithReceivePort:sendPort:] ()
#9  0x001ecae7 in -[FourDForwarder getServerProxy] (self=0x6be210,  
_cmd=0x1f401c)

*snip*

The exception is internal, but I have to think that it's occurring  
because of some state I'm not appropriately cleaning up when I  
disconnect. I just can't think what that would be. It's related to  
runloops based on the backtrace, and the NSConnection documentation  
says that it tries to register with the Current run loop.  
NSRunLoop's documentation says that if you ask for the current run  
loop and there isn't one, one will be created though... So I can't see  
a situation where it would be trying to add a nil run loop.


Any ideas?

Thanks!
Chris Backas



___

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

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

2008-07-22 Thread Bob Barnes


On Jul 21, 2008, at 9:49 AM, Scott Anguish wrote:



On 21-Jul-08, at 10:48 AM, Bob Barnes wrote:



  I hadn't considered that but I cut and pasted it directly from the 
documentation.


- (void)drawInContext(CGContextRef)ctx {
   NSLog(@drawInContext called);
}


that should be

- (void)drawInContext:(CGContextRef)ctx


(copied and pasted from the reference doc)





   Not sure what happened to the colon, but the signature was correct 
in the code (would it even compile if it wasn't?). At any rate I've 
been able to get this to work by explicitly calling my CALayer's 
setContents method and passing nil immediately before calling the 
setNeedsDisplay method. Since I initialized contents to nil and never 
assigned anything to it, I'm confused as to why that was needed, but at 
this point I'll take it.


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: SBApplication error with iTunes 7.7

2008-07-22 Thread Hengist Podd

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Garbage Collection Pre-Processor Flag

2008-07-22 Thread Marcel Weiher


On Jul 22, 2008, at 9:21 , Jonathon Mah wrote:

Are Xcode build settings exposed as pre-processor variables? I know  
they're available when pre-processing Info.plists, but can't find a  
way to use them in source code files (.m).


It's not Xcode build settings, but gcc does have predefined macros  
that can tell you wether GC is on.



#ifdef OBJC_GC
#error This code doesn't support garbage collection
#endif


Try it with

#if __OBJC_GC__

This also shows up when getting the list of pre-defined macros via

cpp -ObjC -fobjc-gc  -dM  /dev/null

Cheers,

Marcel


___

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

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

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

This email sent to [EMAIL PROTECTED]


Binding TableColumn Programatically

2008-07-22 Thread kiran Sanka

I am adding a NSTableColumn to a tableview

NSTableColumn *aTableColumn = [[NSTableColumn alloc]

initWithIdentifier: @title];
[tableView addTableColumn:aTableColumn];

and Binding the tableColumn to an array controller (which contains  
array of Dictionaries) with key path title.


[aTableColumn bind:NSValueBinding toObject:arrayController  
withKeyPath:@arrangedObjects.title options:nil];


but in the above added tableColumn data is not populated and an  
opening brace is shown in each row of that column.


someone, please, lend me a clue!  What am I missing here?


kiran Sanka
[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: NSTextView overdraw bug in Leopard?

2008-07-22 Thread Gerd Knops


On Jul 21, 2008, at 6:10 PM, Martin Wierschin wrote:


Hi everyone,

We've had a report or two from users where text will incorrectly  
draw in an area it's not supposed to. Basically a line fragment (or  
part of one) from the prior NSTextContainer will draw over text in  
the current container. The odd part is that both line fragments are  
the last ones in each of their respective containers. In other  
words, the glyphs for the fragments are separated from each other by  
quite a bit of content.


I have seen something vaguely similar that may or may not be related:  
I implemented drop caps by having a NSTextContainer subclass counting  
lines and modifying the lineFragmentRect (see below). After migrating  
to Leopard that would occasionally fail, typically only for documents  
that caused the application to launch and documents opened later were  
fine. It was seldom reproducible, and I have not seen it in a while so  
it may or may not have been fixed in a later Leopard version. Spent a  
day debugging it without much luck.


Gerd


@implementation RATETextContainer

- (id)initWithContainerSize:(NSSize)size leftOffset: 
(float)newLeftOffset forNumLines:(int)newNumLines {


if(self=[super initWithContainerSize:size])
{
leftOffset=newLeftOffset;
numOffsetLines=newNumLines;

currentLinesToOffset=newNumLines;
}

return self;
}
- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect  
sweepDirection:(NSLineSweepDirection)sweepDirection movementDirection: 
(NSLineMovementDirection)movementDirection remainingRect:(NSRect  
*)remainingRect {


if(proposedRect.origin.y==0)
{
// reset at the beginning of the container
currentLinesToOffset=numOffsetLines;
}

	NSRect	r=[super lineFragmentRectForProposedRect:proposedRect  
sweepDirection:sweepDirection movementDirection:movementDirection  
remainingRect:remainingRect];


if(numOffsetLines)
{
numOffsetLines--;
r.origin.x+=leftOffset;
r.size.width-=leftOffset;
}

return r;
}
- (BOOL)isSimpleRectangularTextContainer {

 return NO;
}

@end

___

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

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

2008-07-22 Thread Bob Barnes


On Jul 21, 2008, at 12:06 PM, David Duncan wrote:


On Jul 21, 2008, at 9:49 AM, Scott Anguish wrote:


On 21-Jul-08, at 10:48 AM, Bob Barnes wrote:

 I hadn't considered that but I cut and pasted it directly from the 
documentation.


- (void)drawInContext(CGContextRef)ctx {
  NSLog(@drawInContext called);
}


that should be

- (void)drawInContext:(CGContextRef)ctx



Also keep in mind that if you are using a delegate, you implement:

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]






  Right, as I indicated in my original post, I had also tried using a 
delegate. Similarly to the subclassing technique where the display 
method was called, but not drawInContext, when I used a delegate the 
displayLayer method was called, but not the drawLayer method.


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: webDAV (lite) framework?

2008-07-22 Thread Kyle Sluder
On Tue, Jul 22, 2008 at 10:50 AM, em [EMAIL PROTECTED] wrote:
Does it not make sense for you to rely on Finder's built-in WebDAV
support?
 Absoutely not--that wouldn't make sense if I was looking for an
 objective-c framework.

The point I was trying to gently make is that if the OP is attempting
to implement WebDAV for file storage, Finder already does this, and it
may be appropriate to just delegate the WebDAV connectivity.  I
specifically mentioned the Dreamweaver example as an illustration:
Dreamweaver has a very buggy WebDAV plugin that does nothing more than
allow you to specify the remote site as a WebDAV share.  But you can
also specify any directory on any mounted volume, and Finder has a
much more stable WebDAV implementation, so I abandoned the WebDAV
plugin for the extra step of manually mounting the WebDAV share with
Finder.  As a side bonus I got all the functionality that comes with
mounting the share as a volume.

I'm just following the philosophy that the best code is the code you
don't have to write.

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


name and email address parsing

2008-07-22 Thread Wayne Shao
Hi,

Does cocoe libraries support regex for common string parsing?

I want to parse our the user's name from email address such as
  Joe Smith [EMAIL PROTECTED]
  Joe M. Smith [EMAIL PROTECTED]
  Joe M. Smith (joejoe) [EMAIL PROTECTED] joejoe
would be nickname here.

I need to parse out first name, last name, and email address, and
email domain.
This may be a very common task but google search results are not so helpful.

any hints or pointers are appreciated before I start to code with
NSString primitive methods.

-- 
Wayne
___

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

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

2008-07-22 Thread Marco Masser
but in the above added tableColumn data is not populated and an  
opening brace is shown in each row of that column.


To me, this sounds like some data is being read and displayed in the  
table, but it's not quite what you want. If you do an NSLog(@%@,  
someArray), the -description method will be called on someArray.  
NSArray displays an opening bracket, a description of every single  
object, and then a closing bracket. NSDictionary does something  
similar. Are you sure the title property is an NSString or NSNumber?


Try something like this in your code and see what you really got in  
there:


id obj = [[arrayController arrangedObjects] objectAtIndex:0];
NSLog(@object: %@ class: %@, obj, NSStringFromClass([obj class]));

Look whether obj is the thing you want to display in every row, and  
whether it really does have a -title property of type NSString or  
NSNumber.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: name and email address parsing

2008-07-22 Thread Dave DeLong
The RegexKit Framework[1] adds that functionality you're looking for.

Dave

[1]  http://regexkit.sourceforge.net/

On Tue, Jul 22, 2008 at 11:23 AM, Wayne Shao [EMAIL PROTECTED] wrote:
 Hi,

 Does cocoe libraries support regex for common string parsing?
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSbuttonCell's Bound Title Misbehaving

2008-07-22 Thread Ian was here
I have a table with one column. This column uses NSButtonCells.

I have an array controller whose object class is NSMutableDictionary. It uses 
two keys: value and state. Value is the string that will be used as the 
title for a button cell. State is the state of the button cell, which is a 
check box. The states being checked or unchecked (NSOnState or NSOffState).

The table column's value is bound to the array controller. The controller key 
being arrangedObjects and the model key path being value.

The NSButtonCell (which is attached to the column via Interface Builder) has 
its value bound to the array controller as well. The controller key is 
selection and the model key path is state.

Finally, I have a table delegate method which is as follows...


- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell 
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
  NSArray*arrangedObjects = [myArrayController arrangedObjects];
  NSMutableDictionary*anObject = [arrangedObjects objectAtIndex:rowIndex];
  NSString   *myValueString = [anObject objectForKey:@value];


  [aCell setTitle:myValueString];
}


Ideally, this would display all of the check boxes in the table column, with 
their respective titles and their current state (checked or unchecked).

Everything looks perfect when I first run the app. The check boxes show their 
correct state and the titles are correct. The problem is when I click on a 
check box. If I check a box, its title changes to 1 and if I uncheck a box, 
its title changes to 0. Has anyone had this problem before?




  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: NSbuttonCell's Bound Title Misbehaving

2008-07-22 Thread Quincey Morris

On Jul 22, 2008, at 10:56, Ian was here wrote:


I have a table with one column. This column uses NSButtonCells.

I have an array controller whose object class is  
NSMutableDictionary. It uses two keys: value and state. Value is  
the string that will be used as the title for a button cell. State  
is the state of the button cell, which is a check box. The states  
being checked or unchecked (NSOnState or NSOffState).


The table column's value is bound to the array controller. The  
controller key being arrangedObjects and the model key path being  
value.


The NSButtonCell (which is attached to the column via Interface  
Builder) has its value bound to the array controller as well. The  
controller key is selection and the model key path is state.


Finally, I have a table delegate method which is as follows...


- (void)tableView:(NSTableView *)aTableView willDisplayCell: 
(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row: 
(int)rowIndex

{
 NSArray*arrangedObjects = [myArrayController  
arrangedObjects];
 NSMutableDictionary*anObject = [arrangedObjects  
objectAtIndex:rowIndex];
 NSString   *myValueString = [anObject  
objectForKey:@value];



 [aCell setTitle:myValueString];
}


Ideally, this would display all of the check boxes in the table  
column, with their respective titles and their current state  
(checked or unchecked).


Everything looks perfect when I first run the app. The check boxes  
show their correct state and the titles are correct. The problem is  
when I click on a check box. If I check a box, its title changes to  
1 and if I uncheck a box, its title changes to 0. Has anyone had  
this problem before?


You're misusing the column binding. It's the checkbox's current state,  
not its title. So, when you click on the checkbox, the binding updates  
your dictionary's value to 0 or 1 (clobbering the actual title  
string), which you then echo back as the cell's title with the last  
line of the delegate 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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


GetDblTime, 64-bit, and cocoa

2008-07-22 Thread [EMAIL PROTECTED]
i need to set a timer when i get a first mouse click and perform 
something if i don't get another click within the double click time. 
i found this old thread (from 2003) in the archives:

http://www.cocoabuilder.com/archive/message/cocoa/2003/10/22/90328
from that thread, it would appear that the best solution may be to 
use GetDblTime. but this is a 32-bit only solution. is there a 
documented (cocoa) way to do this that may be future/64-bit safe?


thanx,
ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSPredicateEditorRowTemplate and ANY predicate

2008-07-22 Thread Frédéric Testuz

Hello,

Is it possible to prepare a row template for a NSPredicateEditor in IB  
for a predicate like ANY keyPath == 'aValue' ?


Otherwise I found this : http://developer.apple.com/samplecode/PhotoSearch/listing2.html 


If I can't do it in IB, I think it will be the simplest solution :

- (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates
{ /* we only make NSComparisonPredicates */
	NSComparisonPredicate *predicate = (NSComparisonPredicate *)[super  
predicateWithSubpredicates:subpredicates];
 /* construct an identical predicate, but add the  
NSCaseInsensitivePredicateOption flag */
	return [NSComparisonPredicate predicateWithLeftExpression:[predicate  
leftExpression] rightExpression:[predicate rightExpression]  
modifier:NSAnyPredicateModifier type:[predicate predicateOperatorType]  
options:[predicate options]];

}

Thanks
Frédéric___

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

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

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

This email sent to [EMAIL PROTECTED]


Help with Messages without a matching method signature... issue

2008-07-22 Thread Brad Gibbs
I read the Newbie Question on a method signature thread from June 4 a  
few times, but, either that isn't the problem I'm having, or I'm not  
understanding the solution...


Any help would be greatly appreciated.


On compile, I get the following warnings:

warning: 'Class2' may not respond to '+sendMSG:toPort:'
warning: (Messages without a matching method signature will be assumed  
to return 'id' and accept '...' as arguments.




And clicking a button produces the following in the Console:

2008-07-22 11:03:06.824 OSX Interface[37304:10b] *** +[Class2  
sendMSG:toPort:]: unrecognized selector sent to class 0x4080




Below is the offending code:

Class 1 - This class provides IBActions, each of which calls the  
sendMSG: toPort: method of Class 2.  The arguments for the methods in  
this class are used to construct NSStrings in Class 2.
Class 2 - The arguments sent from a button in Class 1 provide two  
strings, which are used to compose a new NSString, which is sent to  
another device on the network.



@interface Class1 : NSObject {
}
- (IBAction)powerOn:(id)sender;


@implementation Class1

- (IBAction)powerOn:(id)sender {
[Class2 sendMSG:@P1P1 toPort:@1];


@interface Class2 : NSObject {
}

- (NSString *)sendString:(NSString *)stringToSend;
- (void)sendMSG:(NSString *)string toPort:(NSString *)port;

@implementation Class2

- (NSString *)sendString:(NSString *)stringToSend {
	NSData *postData = [stringToSend  
dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
	NSString *postLength = [NSString stringWithFormat:@%d, [postData  
length]];


	NSMutableURLRequest *theRequest=[[[NSMutableURLRequest alloc] init]  
autorelease];

...

	response = [[NSString alloc] initWithData:receivedData  
encoding:NSASCIIStringEncoding];

return response;
}


- (void)sendMSG:(NSString *)string toPort:(NSString *)port {
NSString *stringToSend;
	stringToSend = [[NSString alloc]  
initWithFormat:@method=MSGSendparam1=%@param2=%@param3=200, port,  
string];

NSLog(@String being sent: %@, stringToSend);
[self sendString:stringToSend];
}
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help with Messages without a matching method signature... issue

2008-07-22 Thread Steve Bird


On Jul 22, 2008, at 3:28 PM, Brad Gibbs wrote:




Below is the offending code:

Class 1 - This class provides IBActions, each of which calls the  
sendMSG: toPort: method of Class 2.  The arguments for the methods  
in this class are used to construct NSStrings in Class 2.
Class 2 - The arguments sent from a button in Class 1 provide two  
strings, which are used to compose a new NSString, which is sent to  
another device on the network.



@interface Class1 : NSObject {
}
- (IBAction)powerOn:(id)sender;


@implementation Class1

- (IBAction)powerOn:(id)sender {
[Class2 sendMSG:@P1P1 toPort:@1];



--- Where's the closing brace here?




@interface Class2 : NSObject {
}

- (NSString *)sendString:(NSString *)stringToSend;
- (void)sendMSG:(NSString *)string toPort:(NSString *)port;






Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: NSbuttonCell's Bound Title Misbehaving

2008-07-22 Thread Ian was here
Changing the model key path from value to state in the column's value 
binding solved the problem.

Thanks.



--- On Tue, 7/22/08, Quincey Morris [EMAIL PROTECTED] wrote:

 From: Quincey Morris [EMAIL PROTECTED]
 Subject: Re: NSbuttonCell's Bound Title Misbehaving
 To: cocoa-dev@lists.apple.com
 Date: Tuesday, July 22, 2008, 11:30 AM
 On Jul 22, 2008, at 10:56, Ian was here wrote:
 
  I have a table with one column. This column uses
 NSButtonCells.
 
  I have an array controller whose object class is  
  NSMutableDictionary. It uses two keys:
 value and state. Value is  
  the string that will be used as the title for a button
 cell. State  
  is the state of the button cell, which is a check box.
 The states  
  being checked or unchecked (NSOnState or NSOffState).
 
  The table column's value is bound to the array
 controller. The  
  controller key being arrangedObjects and
 the model key path being  
  value.
 
  The NSButtonCell (which is attached to the column via
 Interface  
  Builder) has its value bound to the array controller
 as well. The  
  controller key is selection and the model
 key path is state.
 
  Finally, I have a table delegate method which is as
 follows...
 
 
  - (void)tableView:(NSTableView *)aTableView
 willDisplayCell: 
  (id)aCell forTableColumn:(NSTableColumn *)aTableColumn
 row: 
  (int)rowIndex
  {
   NSArray*arrangedObjects =
 [myArrayController  
  arrangedObjects];
   NSMutableDictionary*anObject = [arrangedObjects  
  objectAtIndex:rowIndex];
   NSString   *myValueString = [anObject  
  objectForKey:@value];
 
 
   [aCell setTitle:myValueString];
  }
 
 
  Ideally, this would display all of the check boxes in
 the table  
  column, with their respective titles and their current
 state  
  (checked or unchecked).
 
  Everything looks perfect when I first run the app. The
 check boxes  
  show their correct state and the titles are correct.
 The problem is  
  when I click on a check box. If I check a box, its
 title changes to  
  1 and if I uncheck a box, its title
 changes to 0. Has anyone had  
  this problem before?
 
 You're misusing the column binding. It's the
 checkbox's current state,  
 not its title. So, when you click on the checkbox, the
 binding updates  
 your dictionary's value to 0 or 1
 (clobbering the actual title  
 string), which you then echo back as the cell's title
 with the last  
 line of the delegate 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/howlewere%40yahoo.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: Help with Messages without a matching method signature... issue

2008-07-22 Thread Brad Gibbs
It's in the file, it's just that the warning message pushed the brace  
down and out of my select -  copy - paste to e-mail.  Sorry for the  
confusion.





On Jul 22, 2008, at 12:35 PM, Steve Bird wrote:



On Jul 22, 2008, at 3:28 PM, Brad Gibbs wrote:




Below is the offending code:

Class 1 - This class provides IBActions, each of which calls the  
sendMSG: toPort: method of Class 2.  The arguments for the methods  
in this class are used to construct NSStrings in Class 2.
Class 2 - The arguments sent from a button in Class 1 provide two  
strings, which are used to compose a new NSString, which is sent to  
another device on the network.



@interface Class1 : NSObject {
}
- (IBAction)powerOn:(id)sender;


@implementation Class1

- (IBAction)powerOn:(id)sender {
[Class2 sendMSG:@P1P1 toPort:@1];



--- Where's the closing brace here?




@interface Class2 : NSObject {
}

- (NSString *)sendString:(NSString *)stringToSend;
- (void)sendMSG:(NSString *)string toPort:(NSString *)port;






Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help with Messages without a matching method signature... issue

2008-07-22 Thread Brad Gibbs

That was it  Feeling foolish, but grateful.


Thanks.



On Jul 22, 2008, at 12:41 PM, Charles Steinman wrote:

-sendMSG:toPort: is an instance method, which should be sent to an  
object. You are sending it to Class2, which is a class rather than  
an instance of that class.


Cheers,
Chuck


--- On Tue, 7/22/08, Brad Gibbs [EMAIL PROTECTED] wrote:


From: Brad Gibbs [EMAIL PROTECTED]
Subject: Help with Messages without a matching method  
signature... issue

To: Cocoa List cocoa-dev@lists.apple.com
Date: Tuesday, July 22, 2008, 12:28 PM
I read the Newbie Question on a method signature thread from
June 4 a
few times, but, either that isn't the problem I'm
having, or I'm not
understanding the solution...

Any help would be greatly appreciated.


On compile, I get the following warnings:

warning: 'Class2' may not respond to
'+sendMSG:toPort:'
warning: (Messages without a matching method signature will
be assumed
to return 'id' and accept '...' as
arguments.



And clicking a button produces the following in the
Console:

2008-07-22 11:03:06.824 OSX Interface[37304:10b] ***
+[Class2
sendMSG:toPort:]: unrecognized selector sent to class
0x4080



Below is the offending code:

Class 1 - This class provides IBActions, each of which
calls the
sendMSG: toPort: method of Class 2.  The arguments for the
methods in
this class are used to construct NSStrings in Class 2.
Class 2 - The arguments sent from a button in Class 1
provide two
strings, which are used to compose a new NSString, which is
sent to
another device on the network.


@interface Class1 : NSObject {
}
- (IBAction)powerOn:(id)sender;


@implementation Class1

- (IBAction)powerOn:(id)sender {
[Class2 sendMSG:@P1P1 toPort:@1];


@interface Class2 : NSObject {
}

- (NSString *)sendString:(NSString *)stringToSend;
- (void)sendMSG:(NSString *)string toPort:(NSString *)port;

@implementation Class2

- (NSString *)sendString:(NSString *)stringToSend {
NSData *postData = [stringToSend
dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSString *postLength = [NSString
stringWithFormat:@%d, [postData
length]];

NSMutableURLRequest *theRequest=[[[NSMutableURLRequest
alloc] init]
autorelease];
...

response = [[NSString alloc] initWithData:receivedData
encoding:NSASCIIStringEncoding];
return response;
}


- (void)sendMSG:(NSString *)string toPort:(NSString *)port
{
NSString *stringToSend;
stringToSend = [[NSString alloc]
initWithFormat:@method=MSGSendparam1=%@param2=%@param3=200,
port,
string];
NSLog(@String being sent: %@, stringToSend);
[self sendString:stringToSend];
}
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/acharlieblue%40yahoo.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: NSTextView overdraw bug in Leopard?

2008-07-22 Thread Martin Wierschin

Hi Gerd,

I have seen something vaguely similar that may or may not be  
related: I implemented drop caps by having a NSTextContainer  
subclass counting lines and modifying the lineFragmentRect (see  
below). After migrating to Leopard that would occasionally fail

...
- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect  
sweepDirection:(NSLineSweepDirection)sweepDirection  
movementDirection:(NSLineMovementDirection)movementDirection  
remainingRect:(NSRect *)remainingRect {


if(proposedRect.origin.y==0)
{
// reset at the beginning of the container
currentLinesToOffset=numOffsetLines;
}

	NSRect	r=[super lineFragmentRectForProposedRect:proposedRect  
sweepDirection:sweepDirection movementDirection:movementDirection  
remainingRect:remainingRect];


if(numOffsetLines)
{
numOffsetLines--;
r.origin.x+=leftOffset;
r.size.width-=leftOffset;
}

return r;
}


In your case I would worry about the call sequence when line  
fragments are calculated. There's no guarantee that each fragment  
will only be swept out once and in an order sorted by vertical  
position. Especially if you have noncontiguous layout enabled. I  
think it would be much safer to have your implementation of  
lineFragmentRectForProposedRect:etc: do some simple geometric tests, eg:


@implementation RATETextContainer

- (id) initWithContainerSize:(NSSize)size dropCapRect:(NSRect)dropRect
{   
if(self=[super initWithContainerSize:size]) {
dropCapRect = dropRect;
}
return self;
}

- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect  
sweepDirection:(NSLineSweepDirection)sweepDirection movementDirection: 
(NSLineMovementDirection)movementDirection remainingRect:(NSRect *) 
remainingRect

{
	NSRect lineRect = [super  
lineFragmentRectForProposedRect:proposedRect  
sweepDirection:sweepDirection movementDirection:movementDirection  
remainingRect:remainingRect];


if( NSIntersectsRect(lineRect, dropCapRect) ) {
lineRect.size.width = NSMaxX(lineRect) - NSMaxX(dropCapRect);
lineRect.origin.x = NSMaxX(dropCapRect);
}

return lineRect;
}

- (BOOL)isSimpleRectangularTextContainer
{   
 return NO;
}

@end

That would make your code behave consistently, regardless of the way  
in which the typesetter decides to sweep out line fragments.


Unfortunately I think my problem is different- but perhaps our code  
too made some bad assumptions that was unexpectedly affected by  
Leopard typesetter changes.


~Martin

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicateEditorRowTemplate and ANY predicate

2008-07-22 Thread Peter Ammon


On Jul 22, 2008, at 12:05 PM, Frédéric Testuz wrote:


Hello,

Is it possible to prepare a row template for a NSPredicateEditor in  
IB for a predicate like ANY keyPath == 'aValue' ?




I'm not sure I understand your question.  How is this different than  
just a normal OR type compound predicate?


-Peter

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: error building against sdk 10.5

2008-07-22 Thread Nick Zitzmann


On Jul 22, 2008, at 2:12 PM, g biss wrote:


This I don't know.  The installer put it there?



Not on my system, it didn't. DictionaryServices is supposed to be part  
of the CoreServices framework.


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

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: error building against sdk 10.5

2008-07-22 Thread Tony Becker

I'm going to make some assumptions here...

This is a project that works under 10.4 and has compile errors when  
the SDK is switched to 10.5


Go into your Targets and select your application, or the first  
dependancy of your target that doesn't build

Double click on the target to get the info screen.
Go to the build tab and look for anything else that is set to 10.4, or  
the 10.4 SDK.
Sometimes, as you develop, the SDK gets hard coded into the project,  
rather then a token.
Sometimes, assumptions are made in the project and there are other  
settings that need to change too.


Mixing the SDK's headers can produce the compile errors you've seen.
Look at the quoted search paths at the very bottom too...

On Jul 22, 2008, at 4:15 PM, Nick Zitzmann wrote:



On Jul 22, 2008, at 2:12 PM, g biss wrote:


This I don't know.  The installer put it there?



Not on my system, it didn't. DictionaryServices is supposed to be  
part of the CoreServices framework.


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

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aebecker%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: NSTextView overdraw bug in Leopard?

2008-07-22 Thread Gerd Knops


On Jul 22, 2008, at 3:13 PM, Martin Wierschin wrote:


Hi Gerd,


[..]

In your case I would worry about the call sequence when line  
fragments are calculated. There's no guarantee that each fragment  
will only be swept out once and in an order sorted by vertical  
position. Especially if you have noncontiguous layout enabled. I  
think it would be much safer to have your implementation of  
lineFragmentRectForProposedRect:etc: do some simple geometric tests,  
eg:


I realize that my example made certain unsafe assumptions, and your  
way is a better one. I had a similar method in place at one time, but  
I ran into some confusion with flipped coordinate systems that has  
since been solved. I made a note to revisit that.


However in the few cases where I was able to reproduce the problem,  
the call order was as expected and identical to the cases when the  
problem does not occur (and even a hardcoded fixed offset for all  
lines was not honored). I simply meant to offer anecdotal evidence  
that under Leopard there appears to have been (or still is) a rarely  
triggered circumstance where text rendering behaves oddly. And in a  
hard to figure out problem every little shred of information might  
lead to a solution...


Thanks for your suggestion!

Gerd

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Duplicate rows appearing in outlineview after creating new Entity in moc, why?

2008-07-22 Thread Sean McBride
On 7/17/08 3:58 PM, Jonathan Dann said:

Yeah come to think of it I saw this behaviour when adopting the
mediator pattern in my app.  In the NSPersistentDoc tutorial you can
create a Dept. object just using NSObjectController, then bind your
array contorller's contentSet binding to the object controller's
dept.employees keypath (or whatever they recommend).I tried to do
the same but with NSTreeController and had the same problems.

I'd file a bug if I were you.

Thanks.  It's always nice to have some peer confirmation of non-
insanity. :) I've filed rdar://6094070.

--

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]


NSTask

2008-07-22 Thread Torsten Curdt

When I do

[NSThread detachNewThreadSelector:@selector(something)
 toTarget:self
   withObject:nil];

How can I get access to the NSThread object??
I would have expected detachNewThreadSelector to return a NSTask object.

cheers
--
Torsten
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask

2008-07-22 Thread Nick Zitzmann


On Jul 22, 2008, at 3:31 PM, Torsten Curdt wrote:


When I do

   [NSThread detachNewThreadSelector:@selector(something)
toTarget:self
  withObject:nil];

How can I get access to the NSThread object??


What are you trying to accomplish?

I would have expected detachNewThreadSelector to return a NSTask  
object.



Why would you expect that? The creation of a new thread doesn't spawn  
a task; it spawns a thread.


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

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask

2008-07-22 Thread Michael Watson
Why would you expect to get a pointer to an object that executes shell  
tasks? Threads aren't shell calls.


What are you trying to do with this other thread?


--
m-s

On 22 Jul, 2008, at 17:31, Torsten Curdt wrote:


When I do

   [NSThread detachNewThreadSelector:@selector(something)
toTarget:self
  withObject:nil];

How can I get access to the NSThread object??
I would have expected detachNewThreadSelector to return a NSTask  
object.


cheers
--
Torsten
___

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

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

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


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask

2008-07-22 Thread Torsten Curdt


On Jul 22, 2008, at 23:35, Nick Zitzmann wrote:



On Jul 22, 2008, at 3:31 PM, Torsten Curdt wrote:


When I do

  [NSThread detachNewThreadSelector:@selector(something)
   toTarget:self
 withObject:nil];

How can I get access to the NSThread object??


What are you trying to accomplish?


I was looking into the cancelation of the thread. (isCanceled/cancel  
since 10.5) And just noticed that I don't have the reference to the  
NSThread - at least not when using detachNewThreadSelector. And then I  
was wondering how you would get access to the instance on 10.4. (10.5  
you can create and start the NSThread via init/start)


I would have expected detachNewThreadSelector to return a NSTask  
object.



Why would you expect that? The creation of a new thread doesn't  
spawn a task; it spawns a thread.


Doh! Sorry ...I meant NSThread of course!

cheers
--
Torsten

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSThread (was Re: NSTask)

2008-07-22 Thread Torsten Curdt

Bah ...sorry for the NSTask/NSThread mix up. Obviously too tired.

cheers
--
Torsten

On Jul 22, 2008, at 23:35, Nick Zitzmann wrote:



On Jul 22, 2008, at 3:31 PM, Torsten Curdt wrote:


When I do

  [NSThread detachNewThreadSelector:@selector(something)
   toTarget:self
 withObject:nil];

How can I get access to the NSThread object??


What are you trying to accomplish?

I would have expected detachNewThreadSelector to return a NSTask  
object.



Why would you expect that? The creation of a new thread doesn't  
spawn a task; it spawns a thread.


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



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?

2008-07-22 Thread Rua Haszard Morris

I need to support arbitrary superscript, not just squared...

I should be clear:
 - I initially only set superscript attribute for the characters that  
are superscript, i.e. part of a larger string.
 - When this attributed string was given to an NSTextField (static  
non editable), the textfield draws it with the baseline offset  
downward, so the text looks incorrectly aligned alongside a  
neighbouring text field.
 - So, I experimented with setting NSBaselineOffsetAttributeName for  
the entire string to correct the problem (as I don't want to get into  
font and individual offset calculations unless I have to).


What I discovered was that baseline offset has three effects: above,  
at or below normal position, corresponding negative, zero, or positive  
values, which seems to conflict with the documentation. However,  
setting a negative value fixes my issue, so I'm happy, if a little  
concerned.


Note I just checked what happens if I set  
NSBaselineOffsetAttributeName and don't set  
NSSuperscriptAttributeName; it has no effect no matter what the value  
is...


Thanks for the info
Rua HM.

On Jul 23, 2008, at 4:43 AM, Ross Carter wrote:

The strange thing is that there only seem to be 3 baseline  
positions supported by NSTextField; any positive value, 0, and any  
negative value.



I assume you've seen this, from http://developer.apple.com/documentation/Cocoa/Conceptual/AttributedStrings/Articles/standardAttributes.html#/ 
/apple_ref/doc/uid/TP40004903


The superscript attribute indicates an abstract level for both  
super- and subscripts. The user of the attributed string can  
interpret this as desired, adjusting the baseline by the same or a  
different amount for each level, changing the font size, or both.


Are you perhaps setting a baseline attribute _and_ a superscript  
attribute? It sounds like the Cocoa text system is adjusting the  
baseline according to its notion of superscripts and ignoring your  
baseline attribute value.


Personally, I don't think NSSuperscriptAttributeName is particularly  
useful. I just adjust the baseline and font size: newFontSize =  
oldFontSize * 0.75, baseline for superscript  += 0.4 * oldFontSize,  
baseline for subscript -= 0.3 * oldFontSize.


If the only thing you need to draw is a superscript 2, I like  
Andrew's solution.


Ross


___

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

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

2008-07-22 Thread Randall Meadows

On Jul 22, 2008, at 3:49 PM, Torsten Curdt wrote:

On Jul 22, 2008, at 23:35, Nick Zitzmann wrote:

On Jul 22, 2008, at 3:31 PM, Torsten Curdt wrote:

I was looking into the cancelation of the thread. (isCanceled/cancel  
since 10.5) And just noticed that I don't have the reference to the  
NSThread - at least not when using detachNewThreadSelector. And then  
I was wondering how you would get access to the instance on 10.4.  
(10.5 you can create and start the NSThread via init/start)


Is that what NSThread's +currentThread gives you?  The docs are not  
exactly verbose on the exact use of this call.


FWIW, I use a library called ThreadWorker for much of my threading  
purposes.

___

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

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

2008-07-22 Thread David Duncan

On Jul 22, 2008, at 2:49 PM, Torsten Curdt wrote:

I was looking into the cancelation of the thread. (isCanceled/cancel  
since 10.5) And just noticed that I don't have the reference to the  
NSThread - at least not when using detachNewThreadSelector. And then  
I was wondering how you would get access to the instance on 10.4.  
(10.5 you can create and start the NSThread via init/start)



Most of the instance methods of NSThread are not available prior to  
10.5. Those that are you would call within the thread by calling  
+currentThread or you would call one of the other class methods of  
NSThread.


Or in other words, prior to 10.5 there isn't anything you can really  
do with an NSThread instance that would warrant needing access to the  
actual instance from outside of the thread itself.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic question on /Library/Application Support

2008-07-22 Thread Kiel Gillard
Hi John,

If you use Carbon, you can use FSFindFolder() to find the application
support folder and have Carbon create it for you by passing kCreateFolder as
an argument. However, if you are using Cocoa, I'm not sure
if NSSearchPathForDirectoriesInDomains() creates folders when you search for
a path, as this is not obvious in the documentation. I would imagine it
would, but I would double check that this is the case. I also would not be
sure if that is a consistent behaviour among releases of Mac OS X, either.
Ideas, anyone else?

Hope this helps,

Kiel

You wrote:

Hello,

A generic install of Leopard produces a file system with NO
/Library/Application Support directory.

Is this directory something that is created by an Xcode install?

John F. Richardson
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Exception thrown when calling NSConnection connectionWithReceivePort:sendPort:

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 10:46 AM, Chris Backas wrote:

So... the problem is that when I try to reconnect to DO, meaning,  
call getServerProxy the second time, I get an exception from the  
DOConnection = [[NSConnection connectionWithReceivePort:nil  
sendPort:DOConnectionSocket] retain]; line.


The exception:
*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil

The backtrace:
#0  0x971f30d7 in objc_exception_throw ()
#1  0x94fc3f2b in +[NSException raise:format:arguments:] ()
#2  0x94fc3f6a in +[NSException raise:format:] ()
#3  0x900ea3d0 in _NSArrayRaiseInsertNilException ()
#4  0x90008a04 in -[NSCFArray insertObject:atIndex:] ()
#5  0x90008914 in -[NSCFArray addObject:] ()
#6  0x90027d2d in -[NSConnection addRunLoop:] ()
#7  0x90027b8f in -[NSConnection initWithReceivePort:sendPort:] ()
#8  0x90042df7 in +[NSConnection  
connectionWithReceivePort:sendPort:] ()
#9  0x001ecae7 in -[FourDForwarder getServerProxy] (self=0x6be210,  
_cmd=0x1f401c)

*snip*

The exception is internal, but I have to think that it's occurring  
because of some state I'm not appropriately cleaning up when I  
disconnect. I just can't think what that would be. It's related to  
runloops based on the backtrace, and the NSConnection documentation  
says that it tries to register with the Current run loop.  
NSRunLoop's documentation says that if you ask for the current run  
loop and there isn't one, one will be created though... So I can't  
see a situation where it would be trying to add a nil run loop.


Any ideas?


I suspect that DOConnectionSocket is nil.  Have you tried logging it?   
While you're at it, try logging the arguments to the initialization of  
that port object: the port and host.


Is anything written to the stderr/stdout/console immediately prior to  
this exception?


If the LAN connection was temporarily disconnected, it may be that  
you're having a domain name resolution failure.  Also, you can try  
using NSHost and/or SCNetworkCheckReachabilityByName to see if the  
system believes the remote host is reachable (for a certain limited  
meaning of that term; it just means, does the local host know how to  
route attempts to communicate with that remote host?).


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: PropertyList - NSBrowser / NSOutlineView?

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 6:09 PM, Joeles Baker wrote:

Any other hints for a really basic NSBrowser or NSOutlineView sample  
(not /Developer/Examples/AppKit/OutlineView) ?


I can't personally vouch for these, but a full-text search of all doc  
sets yields:


http://developer.apple.com/samplecode/SourceView/index.html
http://developer.apple.com/samplecode/AbstractTree/index.html

Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Binding TableColumn Programatically

2008-07-22 Thread Ron Lue-Sang


On Jul 22, 2008, at 1:08 PM, kiran Sanka wrote:


I am adding a NSTableColumn to a tableview

NSTableColumn *aTableColumn = [[NSTableColumn alloc]

initWithIdentifier: @title];
[tableView addTableColumn:aTableColumn];

and Binding the tableColumn to an array controller (which contains  
array of Dictionaries) with key path title.


[aTableColumn bind:NSValueBinding toObject:arrayController  
withKeyPath:@arrangedObjects.title options:nil];


but in the above added tableColumn data is not populated and an  
opening brace is shown in each row of that column.


someone, please, lend me a clue!  What am I missing here?


Establish the binding *after* you've added the table column to the  
tableview.







kiran Sanka
[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/luesang%40apple.com

This email sent to [EMAIL PROTECTED]



--
RONZILLA



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?

2008-07-22 Thread Martin Wierschin
Personally, I don't think NSSuperscriptAttributeName is  
particularly useful. I just adjust the baseline and font size:  
newFontSize = oldFontSize * 0.75, baseline for superscript  += 0.4  
* oldFontSize, baseline for subscript -= 0.3 * oldFontSize.


I do something very similar, but instead of using the font size, the  
baseline is calculated using the ascender/descender:


baseline for superscript = font ascender * 0.4
baseline for subscript = font descender * 0.35  // descender is negative

I have no idea whether this is any better than using the font size-  
both methods seem a bit makeshift.


~Martin

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: error building against sdk 10.5

2008-07-22 Thread g biss


On Jul 22, 2008, at 1:29 PM, Tony Becker wrote:


I'm going to make some assumptions here...

This is a project that works under 10.4 and has compile errors  
when the SDK is switched to 10.5


Thanks Tony,

These are 10.5 projects that don't work under 10.5, where the compile  
errors go away when switched to 10.4.


I reproduce this consistently with new projects, from scratch,  
generated by Xcode and untouched.  They don't compile for me unless I  
set the SDK to 10.4.


Sorry to drag down this list with compile issues. . . I just  
subscribed to the xcode-users list and will take this thread over there.





Go into your Targets and select your application, or the first  
dependancy of your target that doesn't build

Double click on the target to get the info screen.
Go to the build tab and look for anything else that is set to 10.4,  
or the 10.4 SDK.
Sometimes, as you develop, the SDK gets hard coded into the  
project, rather then a token.
Sometimes, assumptions are made in the project and there are other  
settings that need to change too.


I really don't see anything that says 10.4 on that tab . . .  I wish I  
did so I could leave this behind.


Thanks again!




Mixing the SDK's headers can produce the compile errors you've seen.
Look at the quoted search paths at the very bottom too...

On Jul 22, 2008, at 4:15 PM, Nick Zitzmann wrote:



On Jul 22, 2008, at 2:12 PM, g biss wrote:


This I don't know.  The installer put it there?



Not on my system, it didn't. DictionaryServices is supposed to be  
part of the CoreServices framework.


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

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aebecker%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: Avoiding mutual retain cycles

2008-07-22 Thread Marcel Weiher

On Jul 22, 2008, at 11:52 , Philippe Mougin wrote:


Le 22 juil. 08 à 06:21, Marcel Weiher a écrit :


http://portal.acm.org/citation.cfm?id=1035292.1028982


There are also interesting bits in their conclusion:

This explains why highly optimized tracing and reference counting  
collectors have surprisingly similar performance characteristics.
In the process we discovered some interesting things: a write  
barrier is fundamentally a feature of reference counting; and the  
existence of cycles is what makes garbage collection inherently non- 
incremental: cycle collection is “trace-like”.


Yes, it is a very interesting read, as are some of the related  
articles that describe cycle-collectors.


Of course, in Objective-C, one must keep in mind that while they  
share some deep structure, the reference counting model we have is  
manual whereas the tracing collector is automatic.


Semi-manual, yes.  However, the automation axis is actually distinct  
from the tracing vs refcounting axis, which is something that is  
often misrepresented (not that you did):  a distinction is made  
between reference counting and GC.  This distinction is not valid,  
both refcounting and tracing are forms of GC, there is no in- 
principle difference in capabilities, just choices made by specific  
implementations.


To illustrate, I automated my reference counting a long time ago,  
through both coding-practices and actual code:


1.	Only use accessors to set ivars (in general: to access), including  
during object creation  [coding practice)]
2.	Automate accessor generation ( accessor-macros in my case,  
@properties have a similar effect) [code]


Those two elements largely eliminated reference counting from my code- 
base, meaning that code generally looks the same as it would with a  
(tracing) GC.  There are only 2 elements left:  the -dealloc method  
and cyclic references, with the latter being the original subject of  
this thread.  I actually also addressed those two, at least in  
specialized circumstances, through some more code:


3.	Automate the '-release' messages sent from -dealloc via some  
introspection [code]

4.  Build a cycle collector [code]

With those two additional elements in place, the RC implementation  
becomes completely equivalent in functionality and convenience to a  
tracing collector, with the differences now implementation choices  
that affect such things as performance profiles and malleability.


I actually don't use 3+4 in most of my code (4 being part of my  
Postscript interpreter), but they do show that the theoretical  
equivalence given in the paper is not just a theoretical result, but a  
practical option.  It just turned out that neither dealloc methods nor  
cyclic references were enough of a problem for me in the general case  
in order to invest more time in 3+4.


But this was a purely pragmatic choice, not an in-principle limitation.

Cheers,

Marcel

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem on clearing points and paths on a NSView

2008-07-22 Thread Graham Cox

Well, do you actually erase them?

The drawRect: method usually starts with something that paints the  
background colour - if you don't do that then any pixels previously  
drawn are not cleared.


e.g.:


- (void) drawRect:(NSRect) rect
{
[[NSColor whiteColor] set];
NSRectFill( rect );

// the rest of the drawing code...
}


hth,

Graham




On 23 Jul 2008, at 8:03 am, JArod Wen wrote:


Hi,

I met a problem on clearing points and paths on a customized NSView.  
I set four NSBezierPath for drawing: pathForPositionMeasure,  
pathForDistanceMeasure, pathForAngleMeasure and selectedPath, and  
used the following code for clearing:


[pathForPositionMeasure removeAllPoints];
[pathForDistanceMeasure removeAllPoints];
[pathForAngleMeasure removeAllPoints];
[selectedPath removeAllPoints]; 
[self setNeedsDisplay:YES];

And the drawRect is only contained the code to draw these four  
paths. But after these lines are executed, points and paths are  
still there on the view. Is there any way to clear them?


Thanks in advance!
---
JArod Wen


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic question on /Library/Application Support

2008-07-22 Thread Jens Alfke


On 22 Jul '08, at 3:53 PM, Kiel Gillard wrote:


If you use Carbon, you can use FSFindFolder() to find the application
support folder and have Carbon create it for you by passing  
kCreateFolder as

an argument.


FSFindFolder works fine in Cocoa apps too. (That's what  
NSSearchPathForDirectoriesInDomains ends up calling.)


—Jens

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: Problem on clearing points and paths on a NSView

2008-07-22 Thread Jens Alfke


On 22 Jul '08, at 3:03 PM, JArod Wen wrote:

I met a problem on clearing points and paths on a customized NSView.  
I set four NSBezierPath for drawing: pathForPositionMeasure,  
pathForDistanceMeasure, pathForAngleMeasure and selectedPath, and  
used the following code for clearing:


And the drawRect is only contained the code to draw these four  
paths. But after these lines are executed, points and paths are  
still there on the view. Is there any way to clear them?


I think we need to see your -drawRect: method. And where are the four  
path variables declared? They're instance variables of the view class,  
probably?


—Jens

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]

A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Jeff Brown
Hi Guys

What do I need to do in the following code to get theString to take the value 
I'm giving it in foo i.e. Hi there?

- (void) aMethod
{
NSString* theString = @;
[self foo:theString];
}

- (NSString*) foo:(NSString*)aString
{
NSString* stringB = @Hi there;
aString = stringB;
}

Thanks guys.


  Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Graham Cox
NSString is not mutable, so once created, you can't change its  
contents. You can reassign the pointer to another string, as you are  
doing - though without knowing your intentions it doesn't really look  
right (and could cause a memory leak). Your 'foo' method is prototyped  
to return a string but isn't doing that, so maybe that's why you're  
not seeing what you expect?


What are you trying to do? If you want to change the content of a  
string, you could use NSMutableString, but the code you've posted  
isn't a great pattern for string manipulation so the intention of it  
isn't clear (to me, anyway).


cheers, Graham





On 23 Jul 2008, at 11:33 am, Jeff Brown wrote:


Hi Guys

What do I need to do in the following code to get theString to take  
the value I'm giving it in foo i.e. Hi there?


- (void) aMethod
{
   NSString* theString = @;
   [self foo:theString];
}

- (NSString*) foo:(NSString*)aString
{
   NSString* stringB = @Hi there;
   aString = stringB;
}

Thanks guys.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Jeff Brown
Sorry - it should have been:

- (void) aMethod
{
   NSString* string1 = @;
   NSString* string2 = @;
   
   string1 = [self foo:string2];
}

- (NSString*) foo:(NSString*)aString
{
   NSString* stringA = @Hi there;
   NSString* stringB = @Everyone;
   aString = stringB;

   return stringA;
}

I need to get 2 strings back from foo. I can get foo to return one. I need to 
pass the other one in by reference. It seems that since I'm passing a pointer 
to an NSString as the argument, it should be fine but it's not. 

By the way
How do you reply on this mailing list so that the reply remains part of the 
thread?




  Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 8:33 PM, Jeff Brown wrote:

What do I need to do in the following code to get theString to take  
the value I'm giving it in foo i.e. Hi there?


- (void) aMethod
{
   NSString* theString = @;
   [self foo:theString];
}

- (NSString*) foo:(NSString*)aString
{
   NSString* stringB = @Hi there;
   aString = stringB;
}


If you're just inquiring about how to use the language, I think you're  
looking for:


- (void) aMethod
{
	NSString* theString = nil;	// No sense initializing it with a pointer  
to a string, when you're about to reassign it.
	[self foo:theString];	// Don't pass the pointer theString, pass the  
pointer to the pointer theString so that -foo: can write through the  
pointer-to-pointer to modify the pointer.  Makes sense? ;)

}

- (void) foo:(NSString**)aString		// Note the extra asterisk, which  
establishes an additional level of indirection

{
	*aString = @Hi there;	// Use the asterisk to dereference the  
pointer-to-pointer to modify the pointed-to pointer

}


However, that's a pretty uncommon technique when using Cocoa.  More  
common would be for a method to return a string.


Also, keep the memory management guidelines in mind.  They are  
obscured a bit in trivial examples like this, which only involve  
string literals.  The convention is that callers of the -foo: method,  
since they are not invoking +alloc, +new, -copy..., or -mutableCopy...  
need not concern themselves with releasing the returned object.  So, - 
foo: must be implemented to take care of that itself, often by making  
sure the returned object has been autoreleased.


Lastly, the naming conventions for a method like -foo: would be to  
prefix it with get.  Something like getTitle:.  Again, though,  
more common would be just a title method which returned the title  
rather than outputting it via a by-reference parameter.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: PropertyList - NSBrowser / NSOutlineView?

2008-07-22 Thread Joel Norvell
Joeles,

The NIBs and Xcode project files seem to be absent, but you can still see the 
source code for OutlineMe in Google Code Search.

Go to: http://google.com/codesearch

And enter: OutlineMe lang:objectivec

HTH,
Joel




  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Graham Cox


On 23 Jul 2008, at 11:49 am, Jeff Brown wrote:


Sorry - it should have been:

- (void) aMethod
{
  NSString* string1 = @;
  NSString* string2 = @;

  string1 = [self foo:string2];
}

- (NSString*) foo:(NSString*)aString
{
  NSString* stringA = @Hi there;
  NSString* stringB = @Everyone;
  aString = stringB;

  return stringA;
}

I need to get 2 strings back from foo. I can get foo to return one.  
I need to pass the other one in by reference. It seems that since  
I'm passing a pointer to an NSString as the argument, it should be  
fine but it's not.




This is my opinion, so take it FWIW: methods that return one value as  
a result and another by reference really suck. Sometimes you have no  
choice, if what you are returning are scalars, C arrays or simple  
structs, but with objects, there's little excuse for it. What's wrong  
with returning an array of strings?




Anyway, to your problem:

NSStrings are immutable.

If you *really* want to return a string object by reference, your  
method would look like this:


- (void) leakLikeABastard:(NSString**) aString
{
*aString = @new string;
}


a much better way to do what you are apparently trying to do is:

- (NSArray*) foo
{
return [NSArray arrayWithObjects:@Hi there, @Everyone, nil];
}


But since it's not really too clear what your ultimate aim is, this  
may not be the best way either.






By the way
How do you reply on this mailing list so that the reply remains part  
of the thread?



Just hit reply (all) - it worked, your message is in the same thread.


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]


Re: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 8:49 PM, Jeff Brown wrote:


Sorry - it should have been:

- (void) aMethod
{
  NSString* string1 = @;
  NSString* string2 = @;

  string1 = [self foo:string2];
}

- (NSString*) foo:(NSString*)aString
{
  NSString* stringA = @Hi there;
  NSString* stringB = @Everyone;
  aString = stringB;

  return stringA;
}

I need to get 2 strings back from foo. I can get foo to return one.  
I need to pass the other one in by reference.


Alternatives to consider:

*) Have the method return an NSArray* containing the strings
*) Have the method return a struct which has two NSString* fields
*) Have a method such as:

- (void) getGreeting:(NSString**)greeting andAdressee: 
(NSString**)addressee;


That is, if you're going to write a get-style method, probably better  
to have it supply both outputs through by-reference parameters than to  
supply one via by-reference parameter and another via return value.



It seems that since I'm passing a pointer to an NSString as the  
argument, it should be fine but it's not.


It was doing exactly what you told it to.  In your original code, you  
had a variable aString which was a pointer to an NSString object.   
Your code then assigned a different value to the pointer, making it  
point to a different object.  However, aString is local to the -foo:  
method.  Changing what it pointed to did not affect the pointer  
theString in aMethod.  (At the point where -foo: was called, the  
contents of the theString variable was copied to the aString variable  
in the new context.  After that copy the two variables are entirely  
independent.  They both initially pointed to the same object, but that  
changed when you assigned a new pointer to aString.)




By the way
How do you reply on this mailing list so that the reply remains part  
of the thread?


I generally just do a Reply All.

Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 9:07 PM, Graham Cox wrote:


- (void) leakLikeABastard:(NSString**) aString
{
   *aString = @new string;
}


There's nothing about returning an object pointer by reference that's  
inherently prone to leaking.  The more likely problem is in the caller  
of such a method.  If the caller supplies the address of a variable  
which already holds a strong reference to an object, then passing that  
variable by reference to this method would cause the caller to lose  
track of its pointer.  It would thus be unable to later release its  
strong reference, causing a leak.


Cheers,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Ken Thomases

On Jul 22, 2008, at 9:14 PM, Ken Thomases wrote:


Alternatives to consider:

*) Have the method return an NSArray* containing the strings
*) Have the method return a struct which has two NSString* fields
*) Have a method such as:

- (void) getGreeting:(NSString**)greeting andAdressee: 
(NSString**)addressee;


That is, if you're going to write a get-style method, probably  
better to have it supply both outputs through by-reference  
parameters than to supply one via by-reference parameter and another  
via return value.


More alternatives that I forgot to list:

*) Have the method return an NSDictionary* with keys for accessing the  
two strings

*) Have separate methods:

-(NSString*) greeting;
-(NSString*) addressee;

*) The usual justification for returning two values from one method is  
that the two are closely interrelated.  It maybe doesn't make sense  
for them to exist in isolation from one another.  (The trivial  
examples discussed don't illustrate this.)  In such a case, that might  
be a design clue that you need a separate class to represent whatever  
single conceptual idea spans the two tidbits of information.  So, you  
might want a custom class which represents the single concept which  
has two (or more) properties.  Then, -foo (no colon) would return an  
instance of that class.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Graham Cox
I know, the problem lies with the caller. But this approach is bad  
form in my view, and does require that you take more care to avoid  
leaks.


Graham


On 23 Jul 2008, at 12:19 pm, Ken Thomases wrote:

There's nothing about returning an object pointer by reference  
that's inherently prone to leaking.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: A quick one: Passing a reference/pointer to NSString

2008-07-22 Thread Jeff Brown
Thanks guys for all the advice.

Much appreciated.

Jeff





  Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: CA: Are nested 3D transforms supported?

2008-07-22 Thread John Harper


On Jul 22, 2008, at 3:07 PM, Jens Alfke wrote:

When I implement this, I get the wrong results. It looks like the  
pieces do get rotated, but then they're projected flat onto the  
board layer, so when the board tilts back it's clear that it's still  
flat but with distorted pieces drawn on it.


As far as I can tell I'm doing everything correctly. Now I'm worried  
that there's some undocumented limitation in CA itself that prevents  
a layer from lying in a different 3D plane than its superlayer. Is  
that so? Any way to work around it?


It's unfortunate that this is undocumented, but it is the intended  
behavior—layers are projected into their parent's plane when rendered.  
This is because many of the features of the CA compositing model are  
inherently 2D (filters, drop shadows, etc) so the only way to make  
them work is for each layer to be a place in 3D space.


Typically the way one works around this is to make all layers that  
have to live in the same 3D space be children of the same parent  
layer, the one with the sublayerTransform defining the perspective and  
viewing transform.


John


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem on clearing points and paths on a NSView

2008-07-22 Thread Jens Alfke


On 22 Jul '08, at 6:45 PM, JArod Wen wrote:

Now I am considering the possible memory leakage in renderPath,  
since each time the path will be initialized and the previous one  
will cause memory leakage, which may be also the reason why I cannot  
get rid of them from the view. But if so, how about the renderPoint?  
It seems ok but still cannot be removed...


-renderPath does have memory leaks (unless you've turned on garbage  
collection) because it allocs pathPoint but never releases it. You  
just need to add a single [pathPoint release] at the end of that  
block. (Or just use [NSBezierPath bezierPathWithOvalInRect:], which is  
an easier way to create a circle and doesn't require you to release  
the result.)


As Graham pointed out, the reason your shapes don't get erased is that  
you don't erase them. Your -drawRect method needs to begin by clearing  
the passed-in NSRect to the background color, otherwise you may be  
leaving behind the old contents of the view.


—Jens

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: Problem on clearing points and paths on a NSView

2008-07-22 Thread JArod Wen

Thanks for your reply!

drawRect:

-(void)drawRect:(NSRect)rect
{
[self renderCurrentFrame];
}

and renderCurrentFrame:


- (void)renderCurrentFrame
{
if(isMeasured)
switch (measureMethod) {
case 0:
[self renderPoint:singlePoint];
break;
case 1:
[self renderPath:pathForDistanceMeasure];
break;
case 2:
[self renderPath:pathForAngleMeasure];
break;
case 3:
[self renderPath:selectedPath]; 
break;
default:
break;
}
[self needsDisplay];
}

and renderPoint:

- (void)renderPoint:(NSPoint)pointLoc
{
[pathForPositionMeasure appendBezierPathWithArcWithCenter: pointLoc
  radius: BLOB_SIZE / 2.0
  startAngle: 0.0
  endAngle: 360.0];

[[NSColor blackColor] set];
[pathForPositionMeasure fill];
[[NSColor whiteColor] set];
[pathForPositionMeasure stroke];
}

and renderPath:

- (void)renderPath:(NSBezierPath *)pathForRender
{
int i = 0;
float lineDash[3];
lineDash[0] = 3.0;
lineDash[1] = 2.0;
lineDash[2] = 3.0;

for(i=0; i  [pathForRender elementCount]; i++){
NSPoint elementPoint[3];
NSBezierPathElement element;
		element = [pathForRender elementAtIndex:i  
associatedPoints:elementPoint];

NSBezierPath *pathPoint = [[NSBezierPath alloc] init];

[pathPoint appendBezierPathWithArcWithCenter: elementPoint[0]
radius: BLOB_SIZE / 2.0
startAngle: 0.0
endAngle: 360.0];
[[NSColor blackColor] set];
[pathPoint fill];
[[NSColor whiteColor] set];
[pathPoint stroke];
}
[[[NSColor whiteColor] colorWithAlphaComponent:0.5] set];
[pathForRender fill];
[[NSColor blackColor] set];
[pathForRender setLineWidth:1.0];
[pathForRender setLineDash:lineDash count:3 phase:0.0];
[pathForRender stroke];
}

Now I am considering the possible memory leakage in renderPath, since  
each time the path will be initialized and the previous one will cause  
memory leakage, which may be also the reason why I cannot get rid of  
them from the view. But if so, how about the renderPoint? It seems ok  
but still cannot be removed...


Thanks for any suggestions!

On Jul 22, 2008, at 9:10 PM, Jens Alfke wrote:



On 22 Jul '08, at 3:03 PM, JArod Wen wrote:

I met a problem on clearing points and paths on a customized  
NSView. I set four NSBezierPath for drawing:  
pathForPositionMeasure, pathForDistanceMeasure, pathForAngleMeasure  
and selectedPath, and used the following code for clearing:


And the drawRect is only contained the code to draw these four  
paths. But after these lines are executed, points and paths are  
still there on the view. Is there any way to clear them?


I think we need to see your -drawRect: method. And where are the  
four path variables declared? They're instance variables of the view  
class, probably?


—Jens


---
JArod Wen




___

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

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

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

This email sent to [EMAIL PROTECTED]


NSConnection Issue

2008-07-22 Thread Patrick Walker
I was wondering if anyone had any solutions to determine whether or  
not an NSConnection via NSSocketPorts are still valid without each end  
polling to see if it still connects?  Right now, if the client tries  
to access the rootObject it hangs.  While this may may only happen  
occasionally, I don't like it when the only solution is to restart the  
program.  I can live with this issue if I had to because all I seem  
to have to ensure is that the server remains up and hardware plugged in.


Is there any equivalent for NSConnectionDidDieNotification and similar  
notifications that could be gerry-rigged to work on not just NSPort  
but NSSocketPort?  The documentation at the Apple Developer site says  
that NSConnection has two notifications available for it but  
unfortunately neither will work if the sockets are of NSSocketPort.   
It also says that you detect a failure on the next message, but the  
problem is that whenever I try to send a message, the client locks up.


I've sort of tried using a @try/@catch but the spinning beachball of  
death isn't generating an exception so I'm not sure what to do.


Anyone have any ideas?

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]


Core Audio Memory Leak

2008-07-22 Thread Jiva DeVoe

This code:

UInt32 maxPacketSize;
size = sizeof(maxPacketSize);--- LEAKS HERE
AudioFileGetProperty(myInfo.mAudioFile,  
kAudioFilePropertyPacketSizeUpperBound, size, maxPacketSize);


According to instruments, leaks where I pointed it out above.  I cut  
this code almost directly from the AudioQueueTools example code... why  
would Instuments say it leaks there?



--
Jiva DeVoe
http://www.random-ideas.net
PowerCard - Intuitive Project Management for Mac OS X


___

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

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

2008-07-22 Thread Adam R. Maxwell


On Jul 22, 2008, at 9:54 PM, Patrick Walker wrote:

I was wondering if anyone had any solutions to determine whether or  
not an NSConnection via NSSocketPorts are still valid without each  
end polling to see if it still connects?  Right now, if the client  
tries to access the rootObject it hangs.  While this may may only  
happen occasionally, I don't like it when the only solution is to  
restart the program.  I can live with this issue if I had to  
because all I seem to have to ensure is that the server remains up  
and hardware plugged in.


Is there any equivalent for NSConnectionDidDieNotification and  
similar notifications that could be gerry-rigged to work on not just  
NSPort but NSSocketPort?  The documentation at the Apple Developer  
site says that NSConnection has two notifications available for it  
but unfortunately neither will work if the sockets are of  
NSSocketPort.  It also says that you detect a failure on the next  
message, but the problem is that whenever I try to send a message,  
the client locks up.


AFAIK you just have to try connecting if you're using NSSocketPort.   
Have you tried using -[NSConnection setRequestTimeout:]?  I have a  
comment in some of my code which indicates that the default timeout is  
really long.


--
Adam



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Returning exactly what has been promised

2008-07-22 Thread Steve Cronin

Folks;

I find if I have a method which returns an NSString for example, that  
often, in the interior of that method I will use an NSMutableString to  
construct the string I intend to return.   My question concerns the  
actual final return statement.


Is there ANY reason to choose A over B?

A) return [NSString stringWithString:myWorkingMutableString];

B) return myWorkingMutableString;

It just kinda sticks in my craw me that I 'promised' an NSString and  
using (B) I don't return one.
Yeah I do understand inheritance and that a mutable entity  
isKindOfClass of the base class
I looking for reasons like edge cases, compiler optimization, error  
trapping, portability, etc..
Is there ANY benefit to the costs associated with the explicit  
declaration of (A)?


Thanks for helping me better understand!
Steve
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Returning exactly what has been promised

2008-07-22 Thread Damien Cooke

You could return like this

return [myWorkingMutableString copy];

This makes a immutable copy returning an NSString.

Regards
Damien

On 23/07/2008, at 2:24 PM, Steve Cronin wrote:


Folks;

I find if I have a method which returns an NSString for example,  
that often, in the interior of that method I will use an  
NSMutableString to construct the string I intend to return.   My  
question concerns the actual final return statement.


Is there ANY reason to choose A over B?

A) return [NSString stringWithString:myWorkingMutableString];

B) return myWorkingMutableString;

It just kinda sticks in my craw me that I 'promised' an NSString and  
using (B) I don't return one.
Yeah I do understand inheritance and that a mutable entity  
isKindOfClass of the base class
I looking for reasons like edge cases, compiler optimization, error  
trapping, portability, etc..
Is there ANY benefit to the costs associated with the explicit  
declaration of (A)?


Thanks for helping me better understand!
Steve
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/damien.cooke%40internode.on.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: Returning exactly what has been promised

2008-07-22 Thread Graham Cox


On 23 Jul 2008, at 3:38 pm, Damien Cooke wrote:


You could return like this

return [myWorkingMutableString copy];

This makes a immutable copy returning an NSString.



Yes, but it also is leaking the returned string, because you have  
returned a retained object. You should autorelease the string after  
copying it.


Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem on clearing points and paths on a NSView

2008-07-22 Thread Quincey Morris

On Jul 22, 2008, at 18:45, JArod Wen wrote:


drawRect:

-(void)drawRect:(NSRect)rect
{
[self renderCurrentFrame];
}


As both Graham and Jens said, drawRect has to draw *everything* in  
'rect', including the background fill (which effectively erases what  
you drew the last time through). Currently, you're just drawing on the  
top of whatever happens to be in the view at the time 'drawRect' is  
called.



and renderCurrentFrame:


- (void)renderCurrentFrame
{
if(isMeasured)
switch (measureMethod) {
case 0:
[self renderPoint:singlePoint];
break;
case 1:
[self renderPath:pathForDistanceMeasure];
break;
case 2:
[self renderPath:pathForAngleMeasure];
break;
case 3:
[self renderPath:selectedPath]; 
break;
default:
break;
}
[self needsDisplay];


This '[self needsDisplay]' shouldn't be here. It's just an accessor,  
so it doesn't actually do anything. If you meant to write '[self  
setNeedsDisplay: YES]', that would be worse -- you should never  
manipulate the needsDisplay state of a view from within drawRect or  
any method it calls.



   }

and renderPoint:

- (void)renderPoint:(NSPoint)pointLoc
{
   [pathForPositionMeasure appendBezierPathWithArcWithCenter: pointLoc
  radius: BLOB_SIZE / 2.0
  startAngle: 0.0
  endAngle: 360.0];

   [[NSColor blackColor] set];
   [pathForPositionMeasure fill];
   [[NSColor whiteColor] set];
   [pathForPositionMeasure stroke];
}


The first line doesn't look right. Every time you redraw the view,  
you're adding another point to 'pathForPositionMeasure' and in  
particular you'll add the same point over and over again if the view  
is redrawn without the data actually changing. (Unless this is all  
managed properly elsewhere.)



and renderPath:

- (void)renderPath:(NSBezierPath *)pathForRender
{
int i = 0;
float lineDash[3];
lineDash[0] = 3.0;
lineDash[1] = 2.0;
lineDash[2] = 3.0;

for(i=0; i  [pathForRender elementCount]; i++){
NSPoint elementPoint[3];
NSBezierPathElement element;
		element = [pathForRender elementAtIndex:i  
associatedPoints:elementPoint];

NSBezierPath *pathPoint = [[NSBezierPath alloc] init];

[pathPoint appendBezierPathWithArcWithCenter: elementPoint[0]
radius: BLOB_SIZE / 2.0
startAngle: 0.0
endAngle: 360.0];
[[NSColor blackColor] set];
[pathPoint fill];
[[NSColor whiteColor] set];
[pathPoint stroke];
}
[[[NSColor whiteColor] colorWithAlphaComponent:0.5] set];
[pathForRender fill];
[[NSColor blackColor] set];
[pathForRender setLineWidth:1.0];
[pathForRender setLineDash:lineDash count:3 phase:0.0];
[pathForRender stroke];
}


Yes, you're leaking a NSBezierPath in every iteration of the loop  
(unless you're using garbage collection). You can just add a  
'[pathPoint release]' as the last statement inside the loop.


Now I am considering the possible memory leakage in renderPath,  
since each time the path will be initialized and the previous one  
will cause memory leakage, which may be also the reason why I cannot  
get rid of them from the view. But if so, how about the renderPoint?  
It seems ok but still cannot be removed...


___

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

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

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

This email sent to [EMAIL PROTECTED]