Re: UI tool kit gone in IB 3?

2008-05-10 Thread Jonathan Hess

Hey Patrick -

I'm not sure I understand your problem, but it sounds like you're  
looking for the palette from IB 2.0. If so, it's been replaced with  
"The Library". You can access the library from the "Tools" menu or  
with the key equivalent of command+shift+L.


Good Luck -
Jon Hess

On May 10, 2008, at 9:58 PM, Patrick J. Collins wrote:


Hi,

I am just curious, using Interface Builder 3 for the first time...  Am
I missing something or is the tool kit for all of the window items
(text field, text view, button, slider, etc) gone???  Can anyone walk
me through how I can manually add these items to a window if the UI  
toolkit

is no longer available?  Or advise a good book on the subject?

Thank you.

Patrick J. Collins
http://collinatorstudios.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/jhess%40apple.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data: How to Observe "dirty" State?

2008-05-10 Thread Dave Fernandes

Actually, the docs say that you can't do this.

On May 10, 2008, at 9:54 PM, Chris Hanson wrote:


On May 10, 2008, at 12:03 PM, Dave Fernandes wrote:

You can also register for the  
NSManagedObjectContextObjectsDidChangeNotification to get a  
notification when anything in the MOC changes. Presumable you can  
then check [moc hasChanges], but I've never used that method.


I would also expect that you can observe your  
NSManagedObjectContext's "hasChanges" property using KVO.


  -- Chris



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Ilan Volow
Not that I know the original poster's development situation, but for  
those of us writing client-server multi-user enterprise database Cocoa  
apps, there's really no Apple-provided solution right now; running  
SQLLite and Core Data on a local machine isn't going to cut it. Even  
if Apple were to some day include real database support for Core Data  
in 10.9 (or whatever it will be), there'd still be the issue of legacy  
databases that may not take kindly to the idea of extra tables and  
stored procedures being added to the database to support graph  
management (like BaseTen currently does), or that would make use of  
views, stored procedures, and set-returning functions which a future  
database-friendly Core Data may not support. This legacy database  
problem will be especially pressing if the mac gets enough enterprise  
market share and businesses switch their clients for existing  
databases over to the mac.


So I think that having to write your own Cocoa object graph management  
and persistence framework is a realistic and necessary evil, and in  
fact, I'm having to write my own PostgreSQL framework to do this kind  
of thing right now.


-- Ilan

On May 10, 2008, at 9:53 PM, Chris Hanson wrote:


The question is, of course, why not just use Core Data if you're  
going to be doing object-graph management?  It's not a "beginner"  
technology, but that is what it's for, and the original poster would  
probably do well to take a look at it before going to far in the  
direction of implementing a completely different object graph  
management and persistence framework.





___

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

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

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

This email sent to [EMAIL PROTECTED]


UI tool kit gone in IB 3?

2008-05-10 Thread Patrick J. Collins
Hi,

I am just curious, using Interface Builder 3 for the first time...  Am
I missing something or is the tool kit for all of the window items
(text field, text view, button, slider, etc) gone???  Can anyone walk
me through how I can manually add these items to a window if the UI toolkit
is no longer available?  Or advise a good book on the subject?

Thank you.

Patrick J. Collins
http://collinatorstudios.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: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Jens Alfke


On 10 May '08, at 7:29 PM, Western Botanicals wrote:

The reason for using the singleton method was to ensure that I never  
have more than one cache or database access object. Having more than  
one cache or database access object could lead to having the same  
data pulled from the database into more than one object.


What if you later find you need to connect to two databases? This  
actually happened to me in a project. Originally I had made the DB  
object a singleton, but then later it turned out we had to be able to  
migrate data from an older database, which meant being able to open a  
second DB object on that database to read the data out of it, so I had  
to change a bunch of code around.


Or what if you need to have two semi-independent engines in the same  
process that each work on the same database, but in different  
sessions / transactions? This can happen too, e.g. in a web server  
handling concurrent requests*.


—Jens

* This really happens, and can have major repercussions. Ruby doesn't  
work well inside Apache because, in part, the interpreter has global  
state so it can't be instantiated multiple times in a sort of  
mod_ruby. This in turn makes it nearly impossible to run Rails well in  
a shared-hosting environment where you can't run your own server  
process.

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: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Jens Alfke


On 10 May '08, at 6:53 PM, Chris Hanson wrote:

Not necessarily.  You can simply return a constant YES for a read- 
only "dirty" property, and treat the property-change itself as the  
trigger you care about.


A "dirty" property that tells lies half the time doesn't sound like a  
good idea to me... o_O


If listening for a property change is the only way to tell if an  
object's dirty, that means that only objects that have been around as  
long as the target object, and registered as listeners when the target  
was first created, can reliably tell if it's dirty. (And they'd have  
to implement their own flag to remember this state, if they didn't  
want to act on it immediately...)


Worse, KVO sends out a lot of false-alarm property change  
notifications. Calling -setUUID: and passing in the original UUID (or  
an equal string) will trigger a notification, even though the property  
value hasn't changed. You really don't want that to mark the object as  
dirty, if that results in as much work as an UPDATE to a database row.


—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: gathering system information

2008-05-10 Thread Jens Alfke


On 10 May '08, at 6:55 PM, Chris Hanson wrote:

Every week or so, someone asks *exactly* this question.  What is  
everyone doing with this information?


I just want to know why everyone suddenly needs to parse XML and/or  
control other apps' windows. (Hm, maybe they're implementing botnets  
driven by XML commands?)


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

ID3 Album Art

2008-05-10 Thread Mr. Gecko
Hello I am using this ID3 Framework for cocoa http://drewfamily.homemail.com.au/Cocoa_-_ID3Tag_framework.html 
 and I want to add an image from the web which is an jpeg.

I have already tried this.
TagAPI *MP3 = [[TagAPI alloc] initWithGenreList:nil];
[MP3 examineFile:MP3Path];
NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData: 
[NSData dataWithContentsOfURL:[NSURL URLWithString:[object  
objectForKey:@"image";

NSMutableDictionary *imageDict = [NSMutableDictionary dictionary];
[imageDict setObject:image forKey:@"Image"];
[imageDict setObject:@"jpeg" forKey:@"Picture Type"];
[imageDict setObject:@"image/jpeg" forKey:@"Mime Type"];
[imageDict setObject:@"Album Art" forKey:@"Description"];
NSMutableArray *imageArr = [NSMutableArray new];
[imageArr addObject:imageDict];
[MP3 setImages:imageArr];
[MP3 updateFile];
and it did not work.
can anyone give me an example?

Thanks,
Mr. Gecko
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Ilan Volow
Wouldn't an alternative to a "dirty" property for each object would be  
to do a Cocoa version of the Martin Fowler's Unit Of Work pattern (see http://martinfowler.com/eaaCatalog/unitOfWork.html) 
 and every time there's a change observed that affects the dirty  
property, you'd register it as a "dirty" object and throw the object  
into the dirty array that belongs to what ever object has been  
designated as the observer (and avoid creating an actual dirty  
property at all?)


-- Ilan


On May 10, 2008, at 2:40 PM, Jens Alfke wrote:



On 9 May '08, at 7:41 PM, Chris Hanson wrote:

(6) Leverage Cocoa framework features in your own code.  For  
example, you don't need to have setter methods that invoke - 
setDirty:.  You can just write a method like this

  - (NSSet *)keyPathsForValuesAffectingDirty {
  return [NSSet setWithObject:@"UUID"];
  }
and then anything that cares about whether a particular object is  
dirty can observe its "dirty" property.


But you still need to implement the "dirty" property, with a getter  
that returns the corresponding ivar; and the other setters like - 
setUUID: need to set the ivar to true.


So what you're describing comes down to just (a) removing - 
setDirty:, and (b) replacing the internal calls to it with  
"dirty=YES". Is this any simpler or cleaner? It's the same number of  
lines of code, and now if you add a new property to the class you  
have to remember to add its name to the set in  
keyPathsForValuesAffectingDirty. Plus, I'll bet the internal general- 
purpose dependency tracking is less efficient than the hardcoded  
call to -setDirty.


In addition,

* keyPathsForValuesAffectingDirty should be a class method, not an  
instance one


* You didn't point out that this only works on 10.5. On 10.4 it will  
compile without warnings but will be ignored at runtime, causing  
hard-to-debug wrong behavior when your property dependencies fail to  
work.


—Jens___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/listboy%40clarux.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]


custom image unit not working when called from a Cocoa app

2008-05-10 Thread Josh Burnett
I've written a custom image unit and gotten it working satisfactorily  
in Core Image Fun House.  However, when I go to add it to a filter  
chain in my Cocoa app, the filter chain stops working.  It works fine  
without my custom filter added into the mix.  Looks like I'm in a  
similar situation to this earlier post, which didn't get a response:


Custom Image Unit/CIFilter troubles
http://www.cocoabuilder.com/archive/message/cocoa/2005/7/8/141081

As with Petteri's case, I'm using [CIPlugIn loadAllPlugIns] to load  
my plugin, which is stored in ~/Library/Graphics/Image Units.  Then,  
in my view's drawRect method I use the following code in to call the  
filter:


shadowsFilter   = [CIFilter filterWithName: @"ShadowRecovery"
keysAndValues:
@"inputImage", imageOut,
@"inputRange", [NSNumber numberWithFloat: shadowRangeValue],
@"inputBoost", [NSNumber numberWithFloat: shadowBoostValue],
nil];
imageOut = [shadowsFilter valueForKey: @"outputImage"];
[shadowsFilter retain];


My image unit is a non-executable one, with only a cikernel.  As  
such, I haven't defined the 'outputImage' method.  Is there something  
that I'm missing here?  My filter works fine in Core Image Fun House,  
and I don't know how to proceed.


Thanks for any pointers,

Josh
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Adam R. Maxwell


On May 10, 2008, at 8:12 PM, Michael Ash wrote:


Even in this case, all you need to do is override -init to return the
shared object. Apple's sample code, showing overrides to -retain,
-release, and other such methods, just serves to hide bugs in the
calling code.


I'd agree with that; I think it's generally more useful to raise an  
exception on dealloc to catch the memory management errors.  The  
sample code also uses @synchronized in +sharedInstance, which turns  
out to be surprisingly bad for performance if you happen to call  
+sharedInstance in a loop.


There was a very long thread on Apple's singleton example a few years  
ago:


http://www.cocoabuilder.com/archive/message/cocoa/2005/11/25/151080

I don't think the example changed significantly as a result, though.

--
adam

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Michael Ash
On Sat, May 10, 2008 at 10:14 PM, Jim Correia <[EMAIL PROTECTED]> wrote:
> On May 10, 2008, at 1:43 AM, Chris Hanson wrote:
>
>> In general terms though, I'll still state that it's a bad idea to enforce
>> that an object be a singleton — especially if you're new to the framework
>> and memory management rules etc.
>>
>> Rather, I'd treat being a singleton as a code smell, and try to ask
>> whether methods on the singleton instance should be class methods, or
>> whether a "shared" singleton would be useful while leaving room for specific
>> instances in the future (and specific instances to use during unit testing).
>>  For one thing, enforced singletons are hard to subclass and substitute;
>> being able to do so is quite useful in certain circumstances.
>
> In many cases, enforcing the singleton-ness of an object is unecessary.
> Convention + shared instance are often good enough.
>
> I have written a couple of bona-fide, enforced singletons over the course of
> time though. These are typically objects I want to instantiate in a nib so
> that I can easily use target/action (or other IB features) with the object.
> In this case, enforcing that only one ever exist is necessary.

Even in this case, all you need to do is override -init to return the
shared object. Apple's sample code, showing overrides to -retain,
-release, and other such methods, just serves to hide bugs in the
calling code.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: wordRangeForRange implememtation

2008-05-10 Thread Ali Ozer

- (NSRange)wordRangeForRange:(NSRange)range{
	NSString *string = [NSString stringWithString:[[self string]  
substringWithRange:range]];


Why do you make yet another copy of the string; you already have the  
substring?  Maybe you meant to make a mutable copy?



if([string hasPrefix:@" "]){
		[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)  
withString:@""];


"string" is not mutable, but you are mutating it here. You should be  
getting a compiler warning.


Ah, sorry, you are not mutating the string, but creating a copy which  
you are simply discarding.  So no compiler warning.  You should either  
hang on to the result (assign to string?), or use an NSMutableString  
to start with and call replaceCharactersInRange:withString:


Other comments still apply.

Ali






Begin forwarded message:


From: Ali Ozer <[EMAIL PROTECTED]>
Date: May 10, 2008 7:42:11  PDT
To: Lincoln Green <[EMAIL PROTECTED]>
Cc: Ali Ozer <[EMAIL PROTECTED]>, cocoa-dev@lists.apple.com
Subject: Re: wordRangeForRange implememtation

There are a number of problems in this code...


- (NSRange)wordRangeForRange:(NSRange)range{
	NSString *string = [NSString stringWithString:[[self string]  
substringWithRange:range]];


Why do you make yet another copy of the string; you already have the  
substring?  Maybe you meant to make a mutable copy?



if([string hasPrefix:@" "]){
		[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)  
withString:@""];


"string" is not mutable, but you are mutating it here. You should be  
getting a compiler warning. Also, don't you want to check for other  
"white space" characters, such as tab, etc?



range.location++;


You probably would also want to do range.length-- here; otherwise  
your range now pokes outside of the original range that was passed in.



}
NSString *op = [NSString stringWithString:[self string]];


Since you said this is in an NSTextView subclass, [self string] is  
the whole contents of the string; you are making a copy of it, which  
could be wasteful.



int length = range.location;


Best to use NSInteger here, for longer-lasting code (but "int" isn't  
wrong, under 32-bit)



int finished = 0;


BOOL would be a better choice in general (but again, "int" isn't  
wrong)



while(finished != 1){   
//2
if([op substringWithRange:NSMakeRange(length, 1)] == @" "){


You can compare strings for equality with ==; use ieEqual:


finished = 1;
}else{
NSLog([op substringWithRange:NSMakeRange(length, 1)]);  
//1


Don't NSLog a string directly; if your string happens to contain  
"%", you will get into trouble (and may crash).  Instead do  
NSLog(@"%@", str).



length++;
}
}
range.length = length;
return range;   
}


That was sort of a "micro" commentary of your code; but I haven't  
done an overall examination to see whether these fixes would fix  
it.  To extract a word range from a string, it may be easier to use  
something like NSScanner:


// Defining the words
NSCharacterSet *validWordSet = [NSCharacterSet  
alphanumericCharacterSet];		// Or however you want to define words

NSCharacterSet *wordBreakSet = [validWordSet invertedSet];

// Set up a scanner
NSScanner *scanner = [NSScanner scannerWithString:yourString];
[scanner setCharactersToBeSkipped:nil];   // We will manage skipping  
ourselves (since we need to find the beginning of the word)


NSString *word = nil;
NSRange range;
[scanner scanCharactersFromSet:wordBreakSet intoString:nil];//  
Skip

range.location = [scanner scanLocation];// Beginning of the word
if ([scanner scanCharactersFromSet:validWordSet intoString:&word])  
{	// Scan the word; if successful, word will contain it, and range  
will contain the range

   range.length = [scanner scanLocation] - range.location;
}

But better yet, NSAttributeString in AppKit has doubleClickAtIndex:  
and nextWordFromIndex:forward:. These are more for text editing  
purposes, not actually detecting words, but they may very well be  
good enough for your usage (at least as good as the above algorithm).


Or you can use CFStringTokenizer, which does a much better job of  
actually trying to recognize words in different languages.


Ali



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: wordRangeForRange implememtation

2008-05-10 Thread Ali Ozer

There are a number of problems in this code...


- (NSRange)wordRangeForRange:(NSRange)range{
	NSString *string = [NSString stringWithString:[[self string]  
substringWithRange:range]];


Why do you make yet another copy of the string; you already have the  
substring?  Maybe you meant to make a mutable copy?



if([string hasPrefix:@" "]){
		[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)  
withString:@""];


"string" is not mutable, but you are mutating it here. You should be  
getting a compiler warning. Also, don't you want to check for other  
"white space" characters, such as tab, etc?



range.location++;


You probably would also want to do range.length-- here; otherwise your  
range now pokes outside of the original range that was passed in.



}
NSString *op = [NSString stringWithString:[self string]];


Since you said this is in an NSTextView subclass, [self string] is the  
whole contents of the string; you are making a copy of it, which could  
be wasteful.



int length = range.location;


Best to use NSInteger here, for longer-lasting code (but "int" isn't  
wrong, under 32-bit)



int finished = 0;


BOOL would be a better choice in general (but again, "int" isn't wrong)


while(finished != 1){   
//2
if([op substringWithRange:NSMakeRange(length, 1)] == @" "){


You can compare strings for equality with ==; use ieEqual:


finished = 1;
}else{
NSLog([op substringWithRange:NSMakeRange(length, 1)]);  
//1


Don't NSLog a string directly; if your string happens to contain "%",  
you will get into trouble (and may crash).  Instead do NSLog(@"%@",  
str).



length++;
}
}
range.length = length;
return range;   
}


That was sort of a "micro" commentary of your code; but I haven't done  
an overall examination to see whether these fixes would fix it.  To  
extract a word range from a string, it may be easier to use something  
like NSScanner:


// Defining the words
NSCharacterSet *validWordSet = [NSCharacterSet  
alphanumericCharacterSet];		// Or however you want to define words

NSCharacterSet *wordBreakSet = [validWordSet invertedSet];

// Set up a scanner
NSScanner *scanner = [NSScanner scannerWithString:yourString];
[scanner setCharactersToBeSkipped:nil];   // We will manage skipping  
ourselves (since we need to find the beginning of the word)


NSString *word = nil;
NSRange range;
[scanner scanCharactersFromSet:wordBreakSet intoString:nil];// Skip
range.location = [scanner scanLocation];// Beginning of the word
if ([scanner scanCharactersFromSet:validWordSet intoString:&word])  
{	// Scan the word; if successful, word will contain it, and range  
will contain the range

range.length = [scanner scanLocation] - range.location;
}

But better yet, NSAttributeString in AppKit has doubleClickAtIndex:  
and nextWordFromIndex:forward:. These are more for text editing  
purposes, not actually detecting words, but they may very well be good  
enough for your usage (at least as good as the above algorithm).


Or you can use CFStringTokenizer, which does a much better job of  
actually trying to recognize words in different languages.


Ali


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Western Botanicals
Since the use of the singleton method has been a big issue, I'll post  
my reasonings for using it. Not that they are right, but I would like  
some comments on why I shouldn't use it for these reasons.


1. I used this page to implement the singleton method: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_10.html 
 . This is the reason why some of the methods may look like the have  
been overwritten. I just followed the instructions.


2. I see why it would be important to leave the decision up to the  
developer to decide whether or not to have more than one instance of a  
class. The reason for using the singleton method was to ensure that I  
never have more than one cache or database access object. Having more  
than one cache or database access object could lead to having the same  
data pulled from the database into more than one object. Having more  
than one object of the same data could cause the data to become dirty.


Justin Giboney

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Jim Correia

On May 10, 2008, at 1:43 AM, Chris Hanson wrote:

In general terms though, I'll still state that it's a bad idea to  
enforce that an object be a singleton — especially if you're new to  
the framework and memory management rules etc.


Rather, I'd treat being a singleton as a code smell, and try to ask  
whether methods on the singleton instance should be class methods,  
or whether a "shared" singleton would be useful while leaving room  
for specific instances in the future (and specific instances to use  
during unit testing).  For one thing, enforced singletons are hard  
to subclass and substitute; being able to do so is quite useful in  
certain circumstances.


In many cases, enforcing the singleton-ness of an object is  
unecessary. Convention + shared instance are often good enough.


I have written a couple of bona-fide, enforced singletons over the  
course of time though. These are typically objects I want to  
instantiate in a nib so that I can easily use target/action (or other  
IB features) with the object. In this case, enforcing that only one  
ever exist is necessary.


But it is an advanced, or at least specialized, usage; definitely not  
the common case.


Jim

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: gathering system information

2008-05-10 Thread Chris Hanson

On May 10, 2008, at 8:28 AM, Torsten Curdt wrote:


Is there any other way of collection system information like

- OS version
- processor speed and architecture
- RAM


What do you need to collect this information for?

Every week or so, someone asks *exactly* this question.  What is  
everyone doing with this information?


  -- Chris


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data: How to Observe "dirty" State?

2008-05-10 Thread Chris Hanson

On May 10, 2008, at 12:03 PM, Dave Fernandes wrote:

You can also register for the  
NSManagedObjectContextObjectsDidChangeNotification to get a  
notification when anything in the MOC changes. Presumable you can  
then check [moc hasChanges], but I've never used that method.


I would also expect that you can observe your NSManagedObjectContext's  
"hasChanges" property using KVO.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Chris Hanson

On May 10, 2008, at 11:40 AM, Jens Alfke wrote:


On 9 May '08, at 7:41 PM, Chris Hanson wrote:

(6) Leverage Cocoa framework features in your own code.  For  
example, you don't need to have setter methods that invoke - 
setDirty:.  You can just write a method like this

  - (NSSet *)keyPathsForValuesAffectingDirty {
  return [NSSet setWithObject:@"UUID"];
  }
and then anything that cares about whether a particular object is  
dirty can observe its "dirty" property.


But you still need to implement the "dirty" property, with a getter  
that returns the corresponding ivar; and the other setters like - 
setUUID: need to set the ivar to true.


Not necessarily.  You can simply return a constant YES for a read-only  
"dirty" property, and treat the property-change itself as the trigger  
you care about.


Even better, though, would be for code to observe only the properties  
of the object that it actually cares about.


The question is, of course, why not just use Core Data if you're going  
to be doing object-graph management?  It's not a "beginner"  
technology, but that is what it's for, and the original poster would  
probably do well to take a look at it before going to far in the  
direction of implementing a completely different object graph  
management and persistence framework.


Plus, I'll bet the internal general-purpose dependency tracking is  
less efficient than the hardcoded call to -setDirty.


You would be surprised.  For example, in the above case, the  
automatically-generated setters for the "bar" and "baz" properties may  
only post a KVO notification for the "dirty" property if it's actually  
observed.


There are a lot of things that can be done under the hood to be  
efficient when you work declaratively instead of procedurally.  Not  
implementing accessors, and instead using declarative mechanisms like  
KVO, is one of those cases where the system can really help you.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Yann Disser Resizing NSTableView columns

2008-05-10 Thread Peter Hudson
sizeToFit   simply sets the width of a column to the width of the  
header cell - and I suspect that you
want to set the width of each column to suit the widest  cell  of  
data in that column.


Here is the heuristic to achieve that:

( Assuming that you have not changed the font for any of the cells ... )


[A]
get a table column  -   get the dataCell  for the column   -   send  
it the  font  message.

Assume we assign it to a variable  tableFont

[B]
Create an attributes dictionary with tableFont  like this ...

NSMutableDictionary *attributes = [NSMutableDictionary  dictionary];
[attributes  setObject:tableFont  forKey:NSFontAttributeName];


[C]
Then, by using the table data source, you use this attributes  
dictionary to check

the written size of all the data - column by column.
i.e. take each column and iterating over the data for each row in  
that column,

hence deducing the max width of the column

NSSize  writtenSize = [dataString  sizeWithAttributes:attributes];

[D]
Having collected the widths of all the columns, iterate over the columns
and set their widths - then you may need to send the table view a  
tile message

to sort itself out.

Don't forget to set your max width on your columns to something  
sensible.



( P G J H )
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: wordRangeForRange implememtation

2008-05-10 Thread Nathan Kinsinger


On May 10, 2008, at 2:26 PM, Lincoln Green wrote:


- (NSRange)wordRangeForRange:(NSRange)range{
	NSString *string = [NSString stringWithString:[[self string]  
substringWithRange:range]];

if([string hasPrefix:@" "]){
		[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)  
withString:@""];


Not sure why the above line is here, you are not using string after  
this so why are you changing it?




range.location++;
}
NSString *op = [NSString stringWithString:[self string]];
int length = range.location;
int finished = 0;
while(finished != 1){   
//2
if([op substringWithRange:NSMakeRange(length, 1)] == @" "){


try isEqualToString: instead of ==



finished = 1;
}else{
NSLog([op substringWithRange:NSMakeRange(length, 1)]);  
//1
length++;
}
}
range.length = length;
return range;   
}

This code is in an NSTextView subclass.

Can anyone tell why it would not work as a wordRangeForRange:  
implementation?  When I run it, my loop at //2 doesn't stop until  
"length" exceeds my character count, even though at //1, My console  
logs a space. Any suggestions? Also, if this is not clear, post in  
and I will try to explain it more clearly.


Thanks!


Lincoln Green
[EMAIL PROTECTED]
http://www.binkworks.com/


--Nathan
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Anyone used btlsocket framework?

2008-05-10 Thread Ricky Sharp


On May 10, 2008, at 2:11 PM, Jens Alfke wrote:

Anyone got a good socket framework to recommend? (I realize it's not  
that hard to roll your own with NSStreams, as shown in CocoaSockets,  
but a framework with a few more bells & whistles would be nice.)



What about CFNetwork and friends?

___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.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]


Custom Value Transformer for PDFDocument data

2008-05-10 Thread Kevin Ross
Hello, I'm thinking of implementing a Custom Value Transformer to add  
PDFDocument support to a MangedObject.  I just want to see if I'm on  
the right track or not.  The code below works, I'm just not sure if  
this is the proper way to do this.  Thanks for your feedback.


@implementation PDFDataTransformer

+ (Class)transformedValueClass { return [NSData class]; }

+ (BOOL)allowsReverseTransformation { return YES; }


- (id)transformedValue:(id)value
{
   NSData *pdfDocAsData = nil;

   if (value == nil) return nil;

   // Attempt to get a reasonable value from the
   // value object.
   if ([value respondsToSelector: @selector(dataRepresentation)]) {
   pdfDocAsData = [value dataRepresentation];
   } else {
   [NSException raise: NSInternalInconsistencyException
   format: @"Value (%@) does not respond to - 
dataRepresentation.",

 [value class]];
   }

   return [pdfDocAsData autorelease];
}

- (id)reverseTransformedValue:(id)value
{
   PDFDocument *pdfDoc = nil;
pdfDoc = [[PDFDocument alloc] initWithData:value];
return [pdfDoc autorelease];
}

--

My other approach was to add an pdfDoc ivar & property and add this  
code:


- (void) init  { pdfDoc = [[PDFDocument alloc] init]; }
- (void) dealloc { [pdfDoc release]; }

and change - (id)reverseTransformedValue:(id)value   to:
- (id)reverseTransformedValue:(id)value
{
[pdfDoc initWithData:value];
return pdfDoc;
}

Any suggestions?

Thank you all again for you expertise.
___

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

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

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

This email sent to [EMAIL PROTECTED]


set space for window

2008-05-10 Thread Mitchell Livingston

Hello,

I have a window that, when closed, is not released because I want to  
save factors like layout, selected values, etc., but I want it, when  
opened, to be put in the current space since it is being "reopened". I  
cannot find a direct way to do this. Am I missing something or is  
there anything I can do to get this behavior?


Thank you,
Mitchell Livingston
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: gathering system information

2008-05-10 Thread Torsten Curdt

Is there any other way of collection system information like
- OS version
- processor speed and architecture
- RAM
other than calling
 system_profiler -xml > system.plist


This was just asked a few days ago on the darwin-userlevel mailing  
list; search the archives for details. That poster wanted more info  
than you list here, but the answer was that it would be more trouble  
than it's worth to collect it manually.


Well, got it working :) based on this

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

I'll write it up in a blog post soon.

In particular it was stated that determining the user-visible name  
of the processor would require making your own lookup table, since  
those names are based more on marketing than on explicit ID numbers.


Indeed ...but I might not need the marketing names. And I assume all  
processor types that are returned are also defined in the header file.


Note that you don't have to make system_profiler write to a file.  
You can call it with NSTask, attach an NSPipe to its stdout, and  
read that with an NSFileHandle


Ah ...that's a good idea. But how would I init the NSDictionary from  
it? There are only


 dictionaryWithContentsOfFile:
 dictionaryWithContentsOfURL:

that do parsing. Or am I missing something?

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: gathering system information

2008-05-10 Thread Torsten Curdt


On May 10, 2008, at 18:12, Chilton Webb wrote:


Hi Torsten,

Apparently Gestalt is part of CoreServices (I thought it was  
Carbon). That will return a lot of info about the host system. I  
know processor speed, memory, and architecture are in there.


See Gestalt.h for more info.


Thanks, Chilton! That was the missing pointer!

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: Problem getting subclass of NSTextContainer working

2008-05-10 Thread Gordon Apple
One thing it doesn't do for you is keep track of the earlier rect
heignts on the same line, as I showed at .  You have
to keep track of that yourself to keep it from overwriting itself on the
next line.

Here is part of my solution. Note that it still doesn't line up the
baselines in the correct place.  You have to have the ability to backtrack
to the beginning of the line to do that, and I don't know how to do it yet.
This code also solves the problem of the layout balking when it encounters a
space too narrow for any text. It keeps moving down until it either finds a
wide enough space or hits the end of the container.  There is also some
logic that determines when you are starting a new line.  "prMaxY" keeps
track of the max segment height on the line.

- (NSRect)myLineFragmentRectForProposedRect:(NSRect)proposedRect
sweepDirection:(NSLineSweepDirection)sweepDirection
movementDirection:(NSLineMovementDirection)movementDirection
remainingRect:(NSRectPointer)remainingRect
{
//This routine is necessary due to having to iteratively find a
viable text line to return

r = proposedRect;
pr = proposedRect;
prMaxY = r.origin.y + r.size.height;
prMinY = r.origin.y;

[xa clear];//Dump any previous ranges.
int n = [spa count];
int i;
for(i = 0; i < n; i++) {
SubpathInfo* info = [spa objectAtIndex:i];
//[spa element:&info
//atIndex:i];
NSRect test = info -> bounds;
test.origin.x = pr.origin.x;
if(EDIntersectsRect(test, pr)) {
[self ClipSubpathToRectHeight:info -> subpath];
[self determineXRanges];
}
}

[self clipToXRange];

*remainingRect = rr;
return r;
}

- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect
   
sweepDirection:(NSLineSweepDirection)sweepDirection
   
movementDirection:(NSLineMovementDirection)movementDirection
remainingRect:(NSRectPointer)remainingRect
{
if(!hasContainer)//Nothing to do here
return [super lineFragmentRectForProposedRect:proposedRect
   sweepDirection:sweepDirection
movementDirection:movementDirection
remainingRect:remainingRect];

float increment = proposedRect.size.height / 2;
NSRect myProposedRect = proposedRect;
NSRect myRect;

//*
//*** Workaround for areas of container that aren't wide enough
//*** to contain text and where the layout manager balks
while(1) {
//Keep moving down until a viable range is found or we hit bottom
//(Why the hell doesn't the LayoutManager do this?)
myRect = [self myLineFragmentRectForProposedRect:myProposedRect
  sweepDirection:sweepDirection
   movementDirection:movementDirection
   remainingRect:remainingRect];

if(myRect.size.width < minWidth &&
   (myProposedRect.origin.y + myProposedRect.size.height) < [self
containerSize].height)
myProposedRect = NSOffsetRect(myProposedRect, 0, increment);
else break;//Our exit cue
}


> Thanks Kyle, that seems to be the correct interpretation - my code is
> working great now.
> 
> If anyone's interested in this, I can post the code here if requested.
> 
> 
> G.
> 

___

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

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

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

This email sent to [EMAIL PROTECTED]


wordRangeForRange implememtation

2008-05-10 Thread Lincoln Green

- (NSRange)wordRangeForRange:(NSRange)range{
	NSString *string = [NSString stringWithString:[[self string]  
substringWithRange:range]];

if([string hasPrefix:@" "]){
		[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)  
withString:@""];

range.location++;
}
NSString *op = [NSString stringWithString:[self string]];
int length = range.location;
int finished = 0;
while(finished != 1){   
//2
if([op substringWithRange:NSMakeRange(length, 1)] == @" "){
finished = 1;
}else{
NSLog([op substringWithRange:NSMakeRange(length, 1)]);  
//1
length++;
}
}
range.length = length;
return range;   
}

This code is in an NSTextView subclass.

Can anyone tell why it would not work as a wordRangeForRange:  
implementation?  When I run it, my loop at //2 doesn't stop until  
"length" exceeds my character count, even though at //1, My console  
logs a space. Any suggestions? Also, if this is not clear, post in and  
I will try to explain it more clearly.


Thanks!


Lincoln Green
[EMAIL PROTECTED]
http://www.binkworks.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: NSStream blocking behavior?

2008-05-10 Thread Michael Gardner
Responding to my own message here, but from looking at the  
CFWriteStreamWrite documentation, that function does have the  
semantics I was looking for (blocks until at least one byte has been  
written). I would assume that NSOutputStream's -write:maxLength: has  
the same behavior, though the docs don't specify this. Can anyone  
confirm?


Is anyone else doing networking the same way I'm planning to? Is there  
anything wrong with the following strategy?


-Put the reader and writer in their own threads
-Ignore events from the NSOutputStream and just do blocking writes
-Use -performSelector:onThread:withObject:waitUntilDone: to pass data  
to/from the main thread


-Michael

On May 8, 2008, at 12:00 PM, Michael Gardner wrote:

Okay, then next question: what will happen if I call - 
write:maxLength: on an NSOutputStream without having received a  
NSStreamEventHasSpaceAvailable event? Is is guaranteed to block  
until it has written at least one byte (assuming we're not dealing  
with a fixed-length stream that has reached its capacity)?


I ask because, given that run-loop scheduling is not a guarantee  
against blocking, I plan to put my NSOutputStream writing code in a  
separate thread. It would be nice if I can ignore the stream events  
entirely and just call -write:maxLength: whenever the thread  
receives data to write, with something like:


- (void)sendLine: (NSString*)line {
NSUInteger bytesWritten = 0;
	NSUInteger bytesToWrite = [line lengthOfBytesUsingEncoding:  
NSUTF8StringEncoding];

char const * bytes = [line UTF8String];
while (bytesWritten < bytesToWrite) {
		NSInteger result = [outputStream write: bytes + bytesWritten  
maxLength: bytesToWrite - bytesWritten];

if (result <= 0)
			@throw [NSException exceptionWithName: @"WriterThreadException"  
reason: @"Error writing to output stream" userInfo: nil];

bytesWritten += result;
}
}

I would then use -performSelector:onThread:withObject:waitUntilDone:  
from my main thread to queue data for sendLine to write. Is this a  
viable approach?


-Michael

On May 8, 2008, at 2:58 AM, Stefan Haller wrote:


Michael Ash <[EMAIL PROTECTED]> wrote:


NSStream matches the semantics of the UNIX read/write calls. In both
cases, if you are informed that data or space is available, you can
issue a read or write for an arbitrary amount of data and be
guaranteed that it will not block.


I would have thought so too, but the NSStream documentation seems to
disagree (this is from the "Stream Programming Guide for Cocoa"
document):

: It should be pointed out that neither the polling nor run-loop
: scheduling approaches are airtight defenses against blocking. If  
the

: NSInputStream hasBytesAvailable method or the NSOutputStream
: hasSpaceAvailable method returns NO, it means in both cases that  
the
: stream definitely has no available bytes or space. However, if  
either

: of these methods returns YES, it can mean that there is available
: bytes or space or that the only way to find out is to attempt a  
read

: or a write operation (which could lead to a momentary block). The
: NSStreamEventHasBytesAvailable and NSStreamEventHasSpaceAvailable
: stream events have identical semantics.

I'm not sure exactly what "momentary block" means here.


--
Stefan Haller
Ableton
http://www.ableton.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/gardnermj 
%40gmail.com


This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: iChat theater

2008-05-10 Thread Chilton Webb
Hi Ben,

I've been looking for the same answer for some time now. 

-Chilton
 
On Saturday, May 10, 2008, at 01:49PM, "Ben Lachman" <[EMAIL PROTECTED]> wrote:
>Hey everybody.  Quick question; Does anyone know a way to start an  
>iChat theater session programatically?  The IMAVManger needs to be in  
>IMAVRequested state, but seemingly there is no way for an app to  
>request an session, the user actually has to select "share a file via  
>iChat Theater" or whatever from iChat.  Apple script doesn't seem to  
>have access to the iChat theater option either.  Calling -start on  
>the manager doesn't do anything is a session hasn't been requested  
>(as documented). Thoughts?
>
>Thanks,
>->Ben
>
>--
>Ben Lachman
>Acacia Tree Software
>
>http://acaciatreesoftware.com
>
>email: [EMAIL PROTECTED]
>twitter: @benlachman
>mobile: 740.590.0009
>
>
>
>___
>
>Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/cocoa-dev/chilton%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: Anyone used btlsocket framework?

2008-05-10 Thread Michael Gardner
I've used SmallSockets (http://smallsockets.sourceforge.net/) in a  
small project, with good results. It doesn't do run loop events, but  
in my opinion it's better to just use threads with blocking I/O anyway.


-Michael

On May 10, 2008, at 2:11 PM, Jens Alfke wrote:



On 10 May '08, at 11:59 AM, Wade Tregaskis wrote:

I haven't used it directly, but I did notice when looking at it  
that it seems to rely on you polling it... that's terrible, given  
you can setup a socket as a runloop source very easily and it  
operates very efficiently.


By Jove, you're right! From BTLSocketManager:

//! \brief Updates the sockets.
//!
//! This method should be called often. Managed sockets will not  
recieve data or
//! finish pending connections until this method is called. NSTimer  
can be used

//! to call this method on a regular basis.

- (void)select

That is just absurd. It might have been excusable ten years ago in  
the classic OS, when threading and asynchrony were so difficult, but  
as you point out, you pretty much have to go out of your way to be  
this badly-behaved on Mac OS X.


Let us never speak of it again :-/

Anyone got a good socket framework to recommend? (I realize it's not  
that hard to roll your own with NSStreams, as shown in CocoaSockets,  
but a framework with a few more bells & whistles would be nice.)


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Anyone used btlsocket framework?

2008-05-10 Thread Robert Claeson


On 10 May 2008, at 21:11, Jens Alfke wrote:

Anyone got a good socket framework to recommend? (I realize it's not  
that hard to roll your own with NSStreams, as shown in CocoaSockets,  
but a framework with a few more bells & whistles would be nice.)


I haven't used it myself, but supposedly OmniFramework contains some  
good network classes.


Robert

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Anyone used btlsocket framework?

2008-05-10 Thread Jens Alfke


On 10 May '08, at 11:59 AM, Wade Tregaskis wrote:

I haven't used it directly, but I did notice when looking at it that  
it seems to rely on you polling it... that's terrible, given you can  
setup a socket as a runloop source very easily and it operates very  
efficiently.


By Jove, you're right! From BTLSocketManager:

//! \brief Updates the sockets.
//!
//! This method should be called often. Managed sockets will not  
recieve data or
//! finish pending connections until this method is called. NSTimer  
can be used

//! to call this method on a regular basis.

- (void)select

That is just absurd. It might have been excusable ten years ago in the  
classic OS, when threading and asynchrony were so difficult, but as  
you point out, you pretty much have to go out of your way to be this  
badly-behaved on Mac OS X.


Let us never speak of it again :-/

Anyone got a good socket framework to recommend? (I realize it's not  
that hard to roll your own with NSStreams, as shown in CocoaSockets,  
but a framework with a few more bells & whistles would be nice.)


—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: Core Data: How to Observe "dirty" State?

2008-05-10 Thread Dave Fernandes
You can also register for the  
NSManagedObjectContextObjectsDidChangeNotification to get a  
notification when anything in the MOC changes. Presumable you can  
then check [moc hasChanges], but I've never used that method.


Dave

On May 10, 2008, at 2:46 PM, Keary Suska wrote:


Does anyone know how to "watch" for the dirty state of an
NSManagedObjectContext (if that's where it is applicable)? I  
imagine the

same way that NSPersistentDocument can do it, if that is feasible.

I know I can observe all of the properties in a managed object and  
set a
flag when a change occurs (and also check NSUndoManager so I know  
when I get
to a properly "clean" state), but I was hoping there was a cleaner  
and more

robust way.

TIA,

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


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes% 
40utoronto.ca


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: Anyone used btlsocket framework?

2008-05-10 Thread Wade Tregaskis
btlsocket  is a new open-source  
Cocoa framework that provides a high-level API for TCP and UDP  
sockets. On first glance it looks quite nice, definitely a step up  
compared to using NSStreams directly (a la the CocoaEcho sample.)  
But it's so new that I can't find anything about it other than the  
actual project page and source code.


Has anyone used this yet? Does it seem solid?


I haven't used it directly, but I did notice when looking at it that  
it seems to rely on you polling it... that's terrible, given you can  
setup a socket as a runloop source very easily and it operates very  
efficiently.  It seems to me that this API requires you to do a lot  
more work. :/


Wade
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data: How to Observe "dirty" State?

2008-05-10 Thread I. Savant

Does anyone know how to "watch" for the dirty state of an
NSManagedObjectContext (if that's where it is applicable)? I imagine  
the

same way that NSPersistentDocument can do it, if that is feasible.


NSManagedObjectContextObjectsDidChangeNotification

http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/Reference/Reference.html#/ 
/apple_ref/doc/uid/TP30001182-BAJJHDFC


--
I.S.

___

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

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

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

This email sent to [EMAIL PROTECTED]


iChat theater

2008-05-10 Thread Ben Lachman
Hey everybody.  Quick question; Does anyone know a way to start an  
iChat theater session programatically?  The IMAVManger needs to be in  
IMAVRequested state, but seemingly there is no way for an app to  
request an session, the user actually has to select "share a file via  
iChat Theater" or whatever from iChat.  Apple script doesn't seem to  
have access to the iChat theater option either.  Calling -start on  
the manager doesn't do anything is a session hasn't been requested  
(as documented). Thoughts?


Thanks,
->Ben

--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: [EMAIL PROTECTED]
twitter: @benlachman
mobile: 740.590.0009



___

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

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

2008-05-10 Thread Keary Suska
Does anyone know how to "watch" for the dirty state of an
NSManagedObjectContext (if that's where it is applicable)? I imagine the
same way that NSPersistentDocument can do it, if that is feasible.

I know I can observe all of the properties in a managed object and set a
flag when a change occurs (and also check NSUndoManager so I know when I get
to a properly "clean" state), but I was hoping there was a cleaner and more
robust way.

TIA,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Jens Alfke


On 9 May '08, at 7:41 PM, Chris Hanson wrote:

(6) Leverage Cocoa framework features in your own code.  For  
example, you don't need to have setter methods that invoke - 
setDirty:.  You can just write a method like this

   - (NSSet *)keyPathsForValuesAffectingDirty {
   return [NSSet setWithObject:@"UUID"];
   }
and then anything that cares about whether a particular object is  
dirty can observe its "dirty" property.


But you still need to implement the "dirty" property, with a getter  
that returns the corresponding ivar; and the other setters like - 
setUUID: need to set the ivar to true.


So what you're describing comes down to just (a) removing -setDirty:,  
and (b) replacing the internal calls to it with "dirty=YES". Is this  
any simpler or cleaner? It's the same number of lines of code, and now  
if you add a new property to the class you have to remember to add its  
name to the set in keyPathsForValuesAffectingDirty. Plus, I'll bet the  
internal general-purpose dependency tracking is less efficient than  
the hardcoded call to -setDirty.


In addition,

* keyPathsForValuesAffectingDirty should be a class method, not an  
instance one


* You didn't point out that this only works on 10.5. On 10.4 it will  
compile without warnings but will be ignored at runtime, causing hard- 
to-debug wrong behavior when your property dependencies fail to work.


—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: gathering system information

2008-05-10 Thread Jens Alfke


On 10 May '08, at 8:28 AM, Torsten Curdt wrote:


Is there any other way of collection system information like
- OS version
- processor speed and architecture
- RAM
other than calling
  system_profiler -xml > system.plist


This was just asked a few days ago on the darwin-userlevel mailing  
list; search the archives for details. That poster wanted more info  
than you list here, but the answer was that it would be more trouble  
than it's worth to collect it manually. In particular it was stated  
that determining the user-visible name of the processor would require  
making your own lookup table, since those names are based more on  
marketing than on explicit ID numbers.


Note that you don't have to make system_profiler write to a file. You  
can call it with NSTask, attach an NSPipe to its stdout, and read that  
with an NSFileHandle.


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

Anyone used btlsocket framework?

2008-05-10 Thread Jens Alfke
btlsocket  is a new open-source  
Cocoa framework that provides a high-level API for TCP and UDP  
sockets. On first glance it looks quite nice, definitely a step up  
compared to using NSStreams directly (a la the CocoaEcho sample.) But  
it's so new that I can't find anything about it other than the actual  
project page and source code.


Has anyone used this yet? Does it seem solid?

—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: gathering system information

2008-05-10 Thread Chilton Webb
Hi Torsten,

Apparently Gestalt is part of CoreServices (I thought it was Carbon). That will 
return a lot of info about the host system. I know processor speed, memory, and 
architecture are in there.

See Gestalt.h for more info.

-Chilton
___

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

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

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

This email sent to [EMAIL PROTECTED]


gathering system information

2008-05-10 Thread Torsten Curdt

Hey guys,

Is there any other way of collection system information like

 - OS version
 - processor speed and architecture
 - RAM

other than calling

   system_profiler -xml > system.plist
   system_profiler -detailLevel mini -xml > system.plist
   system_profiler SPHardwareDataType SPMemoryDataType -xml >  
system.plist


and then reading and accessing that dictionary?

For OS version I found

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

Any other suggestions? Calling the system profiler and reading/parsing  
a temp file feels quite clumsy.


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: Problem getting subclass of NSTextContainer working properly [SOLVED]

2008-05-10 Thread John Joyce

Graham, that would be very cool to have posted here!
If nothing else, it will be in the archive for others who run into it.
(I'm in agreement about the clarity of a large number of docs...  
there often seems to be a circular relationship of what you need to  
understand before being able to understand docs on many topics.)
Otherwise, it would make a great blog post with the graphics you  
linked earlier too.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Resizing NSTableView columns

2008-05-10 Thread Yann Disser
How can I resize all but the last column of a NSTableView in order to  
fit its content perfectly? (I don't care about the resulting size of  
the last column)
If I call sizeToFit  on each but the last column, my columns end up  
not being wide enough. Do I have to set the minWidth of each column?


Thank you,
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: Problem getting subclass of NSTextContainer working properly [SOLVED]

2008-05-10 Thread Graham Cox
Thanks Kyle, that seems to be the correct interpretation - my code is  
working great now.


If anyone's interested in this, I can post the code here if requested.


G.



On 10 May 2008, at 4:57 pm, Graham Cox wrote:

Ok, I understand what you're saying - I'll try a reimplementation  
based on that.


If that's what the docs are supposed to convey then they are poorly  
worded IMO.



Thanks though,

G.


On 10 May 2008, at 4:42 pm, Kyle Sluder wrote:

On Sat, May 10, 2008 at 2:19 AM, Graham Cox  
<[EMAIL PROTECTED]> wrote:
What this suggests to me is that the text container needs to keep  
track of
the previous non-zero remainder rect that it set, and if the  
proposedRect is
the same, then it should return it unchanged, resetting the  
remainderRect.


I'm pretty sure you're interpreting this incorrectly.  Instead, it
sounds like you should, when given a proposed rectangle, move the  
left
edge of that rectangle to where the text may begin for your shape,  
and

then split that rectangle where the text may end.  The framework will
then recursively invoke your method on the remainder rectangle until
it equals NSZeroRect.

It's a standard greedy approach that should require no 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/graham.cox%40bigpond.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: Did I reinvent the wheel?

2008-05-10 Thread Uli Kusterer

Am 09.05.2008 um 22:34 schrieb Western Botanicals:

That is wierd, because Xcode hasn't given me any warnings.



 Leaks are semantic errors, not syntax errors. Xcode can not validate  
your algorithm, it can only make sure that the commands in it are well- 
formed. Since memory allocation and deallocation happens at runtime,  
the compiler would have to run your program to actually find the  
leaks, and would have to try out every code path in it, which is not  
(yet?) possible for a computer.


 You may want to look at chapter 6 of my C tutorial if you're not  
sure about memory management and leaks. It doesn't address Cocoa and  
CoreFoundation memory rules, but it explains the inner workings of  
memory, which should be of some help in making it more obvious why  
Xcode can't detect leaks.


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





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Did I reinvent the wheel?

2008-05-10 Thread Stéphane Sudre


On May 9, 2008, at 10:34 PM, Western Botanicals wrote:



[...]
PS: I didn't look in detail at all your classes, but I did notice  
that the UUID methods in BusinessObject have leaks.


That is wierd, because Xcode hasn't given me any warnings.


There's no reason for Xcode to do this. You would notice this with  
'leaks' or Instruments (or the previous incarnation of the memory  
checking utilties).





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sort

2008-05-10 Thread norio

Chuck,

Thanks for the help.


Suppose that you have these 9
strings:0001,0002,0003,001,002,003,01,02,03.
I'd like to sort them as
0001,001,01,0002,002,02,0003,003,03 as Finder.


If you use one of the compare methods that allows you
to supply options, NSNumericSearch will do what you
want.



However, unfortunately, that didn't make it for the sort.

Norio
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa coding style (was Re: Did I reinvent the wheel?)

2008-05-10 Thread Clark Cox
On Fri, May 9, 2008 at 7:41 PM, Chris Hanson <[EMAIL PROTECTED]> wrote:
> On May 9, 2008, at 11:10 AM, Western Botanicals wrote:
>
>
> (5) The Objective-C type is BOOL, not bool.  The latter is a C++ type.

A minor nit to pick: bool (aka _Bool) is not exclusive to C++(as of
C99 it's a C type as well), and has some useful properties, especially
when assigning to/from other integer types.

> It
> will be unfamiliar to Objective-C developers and what's vastly more
> important, it may @encode differently than the Objective-C type does.

Not only may it @encode differently, it *will* do so. _Bool/bool is
guaranteed to be a different type than BOOL (which is typedef'd to
char).

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

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

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

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

This email sent to [EMAIL PROTECTED]