Re: NSBitMapRepresentation --> JPEG compression?

2009-06-29 Thread Marco S Hyman

On Jun 29, 2009, at 4:12 PM, Chris Tracewell wrote:

The issue is that when using writeToFile my images have an extra 3  
to 10 KB of size whether the image is really small or really big -  
ie 5KB or 300KB. I am suspecting that my XCode generated images are  
bigger for one of two reasons...


1) Adobe's JPEG compression is just plain better and unless I  
develop my own JPEG compression algorithm I am hosed.
2) My Objective-C created images contain extra file meta data /  
headers that are inflating the size a bit


Possible.  Grab a copy of exiftool and run it against a both a
photoshop image and one saved using your method.   It will tell
you what metadata is in each image.

I know that very old versions of photoshop would not save the
exif/iptc/whatever metadata which annoyed me no end as I find
the info quite worthwhile to have around.  On the other hand,
my "prepare images for web page" script makes a point of stripping
everything out of thumbnail images.

If you can't figure out how to do it in your app take a look
at jhead.   Your app could call "jhead -se -purejpg "
to do the job for you.

// marc
___

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

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

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

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


Input for CIFilter

2009-06-29 Thread Mahaboob
Hi,
I can apply almost all filter effects to my graphics except Generator and
Gradient effects. I'm applying filters in drawRect: method. This method is
calling a function for applying filters. This function checks all the
filters in effect stack and assigns input graphics for the input key named
"inputImage" and return the output after applying the filters. For those
filters (Generator and Gradient) there is no input keys named "inputImage".
So how can I assign input graphics?

 I'm using code in this function is :

-(CIImage*)CIImageResultForEffectStack:(CIImage*)iimage {

NSMutableArray* arr = [self effectStack];

CIImage* result = nil;

CIFilter* tFilter;

JPFilter* tJPFilter;

NSString *key, *classstring;

NSArray *inputKeys;

NSDictionary *attr;

NSEnumerator *enumerator;

int i;
for(i = 0 ; i< [arr count] ; i++)
{
tJPFilter = [ arr objectAtIndex:i];

if([tJPFilter isEnabled])
{
tFilter = [tJPFilter filter];

attr = [tFilter attributes];

inputKeys = [tFilter inputKeys];

enumerator = [inputKeys objectEnumerator];

while ((key = [enumerator nextObject]) != nil)
{
id parameter = [attr objectForKey:key];

if ([parameter isKindOfClass:[NSDictionary class]])
{
classstring = [(NSDictionary *)parameter objectForKey:
kCIAttributeClass];
   
if ([classstring isEqualToString:@"CIImage"] )
{
   [tFilter setValue:[self
imageMask] forKey:key];
 }
}
}

if([inputKeys containsObject:@"inputImage"])
{
if(result!=nil)
   [tFilter setValue:result
forKey:@"inputImage"];
   else
  [tFilter setValue:iimage
forKey:@"inputImage"];
   
   }
   result = [tFilter valueForKey: @"outputImage"];
 }
  }

 return result;
}


___

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

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

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

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


Re: Load File Faster.

2009-06-29 Thread mmalc Crawford


On Jun 29, 2009, at 8:55 PM, Dave Keck wrote:


Don't abuse property lists; if you need a database, use a database.


Indeed. And if you can/aren't already, use a binary plist. And load
the data in a background thread, to keep the UI snappy.


Without any additional information, I would suggest instead using Core  
Data and a SQLite store.  This will allow you to load your data on- 
demand.  (There may be reasons why using it may not be appropriate  
here, but in general if you're dealing with any reasonable size  
dataset in a pure Cocoa application, you should typically be using  
Core Data.)


mmalc

___

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

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

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

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


Re: Load File Faster.

2009-06-29 Thread Dave Keck
> Don't abuse property lists; if you need a database, use a database.

Indeed. And if you can/aren't already, use a binary plist. And load
the data in a background thread, to keep the UI snappy.
___

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

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

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

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


Re: Load File Faster.

2009-06-29 Thread Scott Ribe
> How can I make the application load that 6,3MB property list file
> faster?

Don't abuse property lists; if you need a database, use a database.

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Re: Re[4]: NSApp problem outside of bundle

2009-06-29 Thread Michael Ash
On Mon, Jun 29, 2009 at 8:11 PM, Kyle Sluder wrote:
>> IF Apple start requiring ALL apps to be code signed (and presumably, charge 
>> for the privilege), watch as support from smaller developers disappears. 
>> Even MS aren't going to do that.
>
> I doubt that.  Code signing is easy for anyone to do.  Every single
> iPhone app is code signed, for example.

Given how tremendously difficult it can be to set up and maintain the
code signing in an iPhone project, I would not use the iPhone as proof
that code signing is "easy"

Mike
___

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

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

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

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


Re: Re[4]: NSApp problem outside of bundle

2009-06-29 Thread Michael Ash
On Mon, Jun 29, 2009 at 6:56 PM, Peter
Mulholland wrote:
> This is exactly the kind of attitude that means game dev does *not* happen on 
> OS X.

What, that the free help doesn't feel like helping you implement a
proprietary DRM scheme makes it impossible to develop games on OS X?

You're free to develop whatever scheme you wish. Expecting people to
help you with it even when they don't think it will be effective is a
little over the top, though.

Mike
___

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

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

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

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


Re: disabling grammar checking

2009-06-29 Thread Martin Wierschin
i'm not happy that the framework is changing the name of my menu  
item from "Show SpellingŠ" (as i've specified in IB) to "Show  
Spelling and Grammar". is there some way to globally "fix" this? (i  
know i can provide my overrides of showGuessPanel: and  
validateMenuItem: in specific field editors, etc., but i'm hoping  
for something that doesn't require me to provide a custom field  
editor only to fix this.)


I think the best solution is to change the menu item's action to a  
selector only you know about, eg: "showKensSpellingPanel:". You could  
add a category to NSTextView that simply forwards the action to the  
normal "showGuessPanel:". Validation wouldn't work though, unless you  
want to swizzle the validator method for NSTextView.


Perhaps it would be best to have something higher up the responder  
chain exclusively pick up your custom action, say an NSApplication  
delegate. That could inspect the first responder and do validation as  
necessary.


It's an unfortunately messy thing any way you do it, especially for  
such a trifle.


~Martin

___

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

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

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

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


Re: Question about font managing (NSFont).

2009-06-29 Thread Graham Cox


On 30/06/2009, at 2:10 AM, Anders Lassen wrote:

Is a font a large object that requires a lot of memory usage and CPU  
time for initial loading, etc. ??? or should I just think of it, as  
an small object pointer.


(my object tree will in average contain about 100-300 objects).


I hope someone can help on this.



In fact your objects are not going to "contain" individual font  
instances, they are merely going to reference one. I believe the Font  
Manager will cache fonts it loads as needed so you don't have to worry  
about it. If you ask for a variation of a font, the FM will cache it  
and return the same instance again for an identical request from  
another object. In effect it's already implementing the "look up  
table" scheme you're considering.


In general, implement the simplest approach that solves your problem  
then, if necessary, optimise later.


--Graham


___

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

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

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

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


(as you type) spell checking of an attributed string

2009-06-29 Thread kvic...@pobox.com
in my app, i use a NSTableView to let the user specify 
headers/footers for use in reports. a row in the table corresponds to 
a single header/footer line. a single header/footer line is an 
NSAttributedString, and i allow the user to specify the text and font 
and size and text color. additionally, the user can select "tags" 
from a popup to insert tags in the line that get evaluated when the 
report is printed. (these tags correspond to things like the print 
date, user's name, report name, etc.) my model (persistent copy) of a 
header/footer line stores these tags as a 4 character sequence: %XX% 
(where XX corresponds to the particular tag). for display in the 
table, i replace the 4 character sequence with:

\x0001\x0001
ie, a unicode "1", a string meaningful to the user, a unicode "1". 
this expanded sequence is given its own custom attribute and the 
string is displayed with a unique background color. (i suspect this 
is sorta like a token string, but my implementation pre-dates my 
knowledge of NSTokenField).


this has worked well for me, and i successfully deal with my tags as 
words as far as selection and drag and drop.


now i'd like to be able to support spell checking when the user is 
specifying header/footer lines. and i'd like to be able to support 
both manually requested spell checking and continuous/as-you-type 
spell checking. and when performing either form of spell checking, a 
tag should be treated as a series of space characters.


as i already have my own custom field editor for the table, i believe 
by overriding of -[NSText checkSpelling], i can get user requested 
spell checking to work. i would simply perform the appropriate call 
to NSSpellChecker to check a string in which i've replaced my tags 
with spaces, and i could set the spell state and selection as needed.


but i can't think of anyway to have continuous spell checking treat 
my tags as a sequence of spaces. can anyone (Mr. Davidson? :-)) offer 
some suggestions?


one thing i thought of thus far is to have the spell checker learn 
and unlearn my sequences whenever my custom field editor becomes the 
first responder and the user has requested continuous spell checking. 
this almost works, but fails if the user doesn't have a word break 
character between my tag and his/her typing.


thanx for any help/advice/suggestions/any thing,
ken
___

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

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

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

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


Re: CalendarStore and delegated calendars

2009-06-29 Thread Steven Riggs
Any takers on the subject of iCal delegated calendars and the  
CalendarStore?  I may file a bug.


-Steve

On Jun 22, 2009, at 11:47 PM, Steven Riggs wrote:


Hello all,

Is it a bug or by design that the CalendarStore will not pick up  
delegated calendars?  I've googled all night without an answer.  
Thanks in advance!


-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/steven.riggs%40me.com

This email sent to steven.ri...@me.com


___

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

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

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

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


Re: Re[6]: NSApp problem outside of bundle

2009-06-29 Thread Kyle Sluder
On Mon, Jun 29, 2009 at 5:30 PM, Peter
Mulholland wrote:
> I'll see how it goes. If necessary I'll put RegDialog.app inside Resources 
> and then just have the loader run that instead.

You really might just want to save yourself the effort and do it now.
Things break in extremely subtle ways when apps aren't in bundles.
[[NSBundle mainBundle] executablePath] doesn't actually point to the
main binary, among other things...

>> They don't, currently.  Apple has not said anything beyond "we'll be
>> using this more in the future than we are right now."
>
> Making it so all apps must be signed would be incredibly foolish. Look at how 
> much fuss requiring all drivers to be signed on Vista has kicked up, for 
> example.

Except that OS X developers are usually willing to play by the rules.
Raymond Chen's blog at http://blogs.msdn.com/oldnewthing is a great
insight into the shockingly non-compliant world of Windows software.

>> I doubt that.  Code signing is easy for anyone to do.  Every single
>> iPhone app is code signed, for example.
>
> If anyone can sign code, what's the point in signing it ? Unless it's signed 
> by a central authority, there is no point.

That's a bit naive.  Code signing has benefits even when there's no
central authority:
http://developer.apple.com/documentation/security/Conceptual/CodeSigningGuide/Introduction/Introduction.html

Code signatures are not guarantees of the code's safety.  A code
signature simply guarantees that two different things came from
someone with access to the same private key.  This is very powerful in
and of itself.

--Kyle Sluder
___

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

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

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

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


Re[6]: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello Kyle,

Tuesday, June 30, 2009, 1:11:02 AM, you wrote:

> I'm referring to your use of NSApplication in an app that's not
> bundled.  You can't do that.  Apps must be in app bundles.

Technically it is. While it does execute on the command line without the nib in 
a bundle, its not really designed for that. It's just a bit naughty and it's 
really inside the original apps bundle.

I'll see how it goes. If necessary I'll put RegDialog.app inside Resources and 
then just have the loader run that instead.

> You mean aside from the whole idea of non-executable pages?  Or do you
> write the contents out to disk and execute them from there?

The loader uses mmap() to allocate the pages, and decrypt code into them, in a 
similar manner to what the kernel does when it loads a Mach-O file. I don't 
want to go into too much detail for obvious reasons! Needless to say, non 
executable pages are honored. Writing the contents out to disk would be foolish 
as it would be an obvious attack vector.

> Well yes, but that's not saying much.  This is UNIX, after all.  It's
> a bit like saying "Besides, what do you think Quartz does?
> Eventually, it shoves data over PCI-Express.  It just adds some
> friendly fluff over the top of it."

Exactly, it's UNIX, and that's why i use execve() :)

> They don't, currently.  Apple has not said anything beyond "we'll be
> using this more in the future than we are right now."

Making it so all apps must be signed would be incredibly foolish. Look at how 
much fuss requiring all drivers to be signed on Vista has kicked up, for 
example.

> I doubt that.  Code signing is easy for anyone to do.  Every single
> iPhone app is code signed, for example.

If anyone can sign code, what's the point in signing it ? Unless it's signed by 
a central authority, there is no point.

> I highly doubt that.  I would imagine the fact that the Mac doesn't
> run DirectX or expose a Win32 API has a lot to with that.

We have a layer for that ;)

> There's a rather large OT argument to be had here.  For Scott's sake,
> I'm going to avoid it.

Good. At the end of the day, if the original publisher demands we protect, we 
protect. The alternative is - no titles.

> Fair enough.  But these kinds of copy protection schemes are always
> fraught with peril.

SO far, we've had only one conflict - Instant Hijack, and that has been known 
to cause problems in other apps, anyway.


-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


disabling grammar checking

2009-06-29 Thread kvic...@pobox.com
while it is meaningful to do spell checking in my 
app, it is never meaningful to check grammar. 
therefore, i would like the "Check grammar" 
checkbox to not appear in the guess panel, or at 
least be disabled/grayed out. how can i 
accomplish this?


additionally, i'm not happy that the framework is 
changing the name of my menu item from "Show 
SpellingŠ" (as i've specified in IB) to "Show 
Spelling and Grammar". is there some way to 
globally "fix" this? (i know i can provide my 
overrides of showGuessPanel: and 
validateMenuItem: in specific field editors, 
etc., but i'm hoping for something that doesn't 
require me to provide a custom field editor only 
to fix this.)


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


Re: nib-object retaining question

2009-06-29 Thread Roland King
and note also that the answer is slightly different depending on whether 
you are targeting OSX or iPhone, so make sure you read the correct piece 
of the documentation for the platform of interest.


mmalc Crawford wrote:


On Jun 29, 2009, at 3:58 PM, WT wrote:


I have three questions:



The answers are all contained in the documentation.
You should take some time to read "Nib Files" in "Resource Programming  
Guide" and "Memory Management Programming Guide for Cocoa".


mmalc

___

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

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

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

This email sent to r...@rols.org

___

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

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

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

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


Re: Re[4]: NSApp problem outside of bundle

2009-06-29 Thread Kyle Sluder
On Mon, Jun 29, 2009 at 3:56 PM, Peter
Mulholland wrote:
> If you are referring to me not using NSApplicationMain(), how is that 
> unsupported? In fact the code is based on things I've seen in Apple samples. 
> [NSApplication sharedApplication] is a documented API. So is loading your own 
> NIB. I'm not doing anything illegal there.

I'm referring to your use of NSApplication in an app that's not
bundled.  You can't do that.  Apps must be in app bundles.

>> Then perhaps you should be considering a refactor.
>
> No. Effectively, the code functions like an executable unpacker. In fact, I 
> got the idea from the source code to the UPX executable packer. There is 
> nothing wrong with this approach provided the methods are fully understood.

You mean aside from the whole idea of non-executable pages?  Or do you
write the contents out to disk and execute them from there?

> Besides, what do you think Launch Services does? Eventually, it calls 
> vfork()/execve(). It just adds some friendly fluff over the top of it.

Well yes, but that's not saying much.  This is UNIX, after all.  It's
a bit like saying "Besides, what do you think Quartz does?
Eventually, it shoves data over PCI-Express.  It just adds some
friendly fluff over the top of it."

>> You don't know what Apple has in store for code signing requirements
>> on post-Leopard operating systems.  It is known that code signing
>> requirements will be stricter in the future than they are now.  How
>> and when is still unknown, but trying to decrypt and execute an
>> application like this might result in irking the security gods.
>
> Since when do apps running on OS X *have* to be code signed?

They don't, currently.  Apple has not said anything beyond "we'll be
using this more in the future than we are right now."

> IF Apple start requiring ALL apps to be code signed (and presumably, charge 
> for the privilege), watch as support from smaller developers disappears. Even 
> MS aren't going to do that.

I doubt that.  Code signing is easy for anyone to do.  Every single
iPhone app is code signed, for example.

> This is exactly the kind of attitude that means game dev does *not* happen on 
> OS X.

I highly doubt that.  I would imagine the fact that the Mac doesn't
run DirectX or expose a Win32 API has a lot to with that.

> We reserve the right to attempt to protect our investment and hard work! More 
> to the point, we do a lot of porting work, and it is a requirement of the 
> original publisher/developer that we protect the port as much as possible.

There's a rather large OT argument to be had here.  For Scott's sake,
I'm going to avoid it.

> The aim is not to prevent cracking - that will happen. The aim is to make it 
> as difficult as possible, and delay it so that our product has a chance to 
> sell. Also, it means we can make thinks awkward for those people using 
> cracked copies.

Fair enough.  But these kinds of copy protection schemes are always
fraught with peril.

--Kyle Sluder
___

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

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

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

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


Re[4]: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello Steve,

Tuesday, June 30, 2009, 12:42:31 AM, you wrote:


> It's actually described very clearly in Xcode's developer docs for  
> TransformProcessType:

> ...
> Parameters

> PSN

> The serial number of the process you want to transform. You can also  
> use the constant kCurrentProcess to refer to the current process. See  
> ProcessSerialNumber for more information.
> ...

Which makes me think TransformProcessType(kCurrentProcess, ...);

Anyway, it's all OK now :)

-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Re: Re[2]: NSApp problem outside of bundle

2009-06-29 Thread Steve Christensen

On Jun 29, 2009, at 3:22 PM, Peter Mulholland wrote:


Monday, June 29, 2009, 11:12:20 PM, you wrote:


You don't use kCurrentProcess as an argument. You use it like this:

ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType( &psn, ... );


I see. It isn't really explained all that clearly.


It's actually described very clearly in Xcode's developer docs for  
TransformProcessType:


...
Parameters

PSN

The serial number of the process you want to transform. You can also  
use the constant kCurrentProcess to refer to the current process. See  
ProcessSerialNumber for more information.

...

___

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

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

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

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


NSBitMapRepresentation --> JPEG compression?

2009-06-29 Thread Chris Tracewell

--- Using GC ---

I am saving images to file from an NSImage dropped into an NSImageView  
using JPEG as the file format via the code below.


-(IBAction)saveImages:(id)sender
{
	TKProduct *theProduct = [[myProductArrayController selectedObjects]  
objectAtIndex:0];


	NSBitmapImageRep *theBitMapImageRep = [NSBitmapImageRep  
imageRepWithData:[[theProduct myImage] TIFFRepresentation]];
	NSDictionary *thePropertyDictionary = [NSDictionary  
dictionaryWithObjectsAndKeys:[theProduct  
myImageCompression],NSImageCompressionFactor,[NSNumber  
numberWithInteger:0],NSImageProgressive,nil];
	NSString *theFileName = [NSString stringWithFormat:@"%...@-%@.jpg", 
[theProduct myID],[theProduct myImageCompression]];


	NSData *theData = [theBitMapImageRep representationUsingType:  
NSJPEGFileType properties: thePropertyDictionary];
	[theData writeToFile:[@"/volumes/MyHardDrive/Users/myname/Desktop/ 
XCode-Image-Tests/" stringByAppendingString:theFileName]  
atomically:YES];

}

Ideally I am wanting to achieve quality and file size comparable with  
what I get out of Photoshop's File->Save For Web command. I am  
satisfied with the comparative quality of matching settings I get -  
that is an image saved from PS at JPEG quality 50 and non progressive  
is close enough (although not quite as good) as what I get from the  
same image run through the method above using NSImageCompressionFactor  
of 0.5. The issue is that when using writeToFile my images have an  
extra 3 to 10 KB of size whether the image is really small or really  
big - ie 5KB or 300KB. I am suspecting that my XCode generated images  
are bigger for one of two reasons...


1) Adobe's JPEG compression is just plain better and unless I develop  
my own JPEG compression algorithm I am hosed.
2) My Objective-C created images contain extra file meta data /  
headers that are inflating the size a bit


I mention scenario 2 because a few versions back, before "Save For  
Web" was in PS, you could uncheck an option for "Include Extra File  
Headers" (or something like that) when saving to JPEG and your files  
would always shrink by a few KB. The file size is important because  
the images will load on a a busy web site up to a hundred per page  
load and so 100 4KB image thumbnails loads a lot quicker than 100 8KB  
thumbnails. I have always used ImageReady and AppleScript to process  
these files in the past but want to skip that and do it solely in my  
App.


Does anyone have any suggestions as to how to squeeze a little more  
file size reduction out of these JPEG's without having to dive into  
JPEG compression algorithms (probably over my head, but willing to  
look if you want to point in a direction :-) ? I guess I am hoping  
there is something I have missed in NSData and writeToFile that allows  
me to not include custom OS X meta data / headers / Icons.


 I should also mention that if you have any pointers for PNG  
optimization, tutorials, tech docs, I would love the links as PNG is a  
format I would like to use down the road as well and the docs and  
Google didn't provide anything about how to actually produce a reduced  
color pallete (I know its probably right in front of me, please feel  
free to point out the obvious :-)


Thank you.
___

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

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

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

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


Re: nib-object retaining question

2009-06-29 Thread mmalc Crawford


On Jun 29, 2009, at 3:58 PM, WT wrote:


I have three questions:



The answers are all contained in the documentation.
You should take some time to read "Nib Files" in "Resource Programming  
Guide" and "Memory Management Programming Guide for Cocoa".


mmalc

___

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

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

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

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


Re: NSObjectController, content outlet and content object question

2009-06-29 Thread Michael de Haan


 Quincey Morris wrote:


On Jun 29, 2009, at 15:23, Michael de Haan wrote:

Given this simple appwhich keeps a slider and textField's value  
synchronized.


1) View consisting of a slider and a textField
2) Model (Foo) with a single property "number"
3) NSObjectController

I am able to use 2 configurations to get the app to work.


Config (1).

In IB, Bind the textField's and Slider's values to the model Key  
Path "selection.number".

Connect the NSOjectController's outlet ( cntrl-drag to foo).


Config (2)

As config (1) ...first line only   now Bind NSObjectController  
to Foo, with the model Key Path = self.



Could someone please explain why both work, and any reason for  
choosing one over the other.


Is File's Owner of class Foo?



No...it's of class NSApplication.





(I'm not sure how you'd bind to Foo otherwise.)



NSObjectController bindings offer both File's Owner and Foo , (amongst  
others) as an option for binding.





If so, the two methods are exactly identical.

Method (1) is what you'd normally use for objects inside the NIB  
file. Method (2) is what you'd normally use for objects not in the  
NIB file. File's Owner is not actually in the NIB file, but it  
pretends to be, so you have a choice.






Thanks for your insight.

___

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

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

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

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


Re: NSTableView -setDataCell confusion

2009-06-29 Thread Raleigh Ledet


On Jun 28, 2009, at 10:05 PM, Quincey Morris wrote:


On Jun 27, 2009, at 13:18, Chase Meadors wrote:

I'm using AMIndeterminateProgressIndicatorCell (at least the  
drawing code) to imitate a progress indicator in the table view. To  
get it to use the custom cell, I've been calling


[myTableColumn setDataCell:[[MyCustomClass alloc] init]];

However, I've run into a 'slight' problem. Apparently, ALL of the  
cells in this column are that one, same, object. When I tested with  
F-script, I found that they have the exact same description, and  
same memory address. This explains why bindings affecting one cell  
would affect all of them...


So, in short, is there a +setCellClass method or similar for  
NSTableColumn? Any way to make it use different objects?


You can use the table view delegate method:

tableView:dataCellForTableColumn:row:

to implement different cells for different rows.


Yes, but that won't really solve his problem. NSTableView likes to use  
the exact same cell over and over again to draw row/column contents  
very quickly. While Chase can use  
tableView:dataCellForTableColumn:row:, NSTableView won't retain that  
cell. Chase would need to retain the cell in the delegate. However,  
even doing that, you won't get the animation that Chase is looking for.


So your choices kinda come down to the following:
a) Give up on the animation. Then you can use the same cell for the  
entire column. Each row will return the correct value that the  
progress indicator should draw. Be sure to invalidate the row/column  
as the value changes to redraw the cell with the new value.


b) Place actual NSProgressIndicator views into the table view. This is  
somewhat tricky to do and maintain an acceptable level of performance.  
The basic outline is that you should create your own NSTableView  
subclass, override viewWillDraw: and add / remove views such that you  
only have indicator subviews for the visible rows. With actual views  
in place, the animation will be done properly.


-raleigh
___

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

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

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

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


Re: NSObjectController, content outlet and content object question

2009-06-29 Thread Quincey Morris

On Jun 29, 2009, at 15:23, Michael de Haan wrote:

Given this simple appwhich keeps a slider and textField's value  
synchronized.


1) View consisting of a slider and a textField
2) Model (Foo) with a single property "number"
3) NSObjectController

I am able to use 2 configurations to get the app to work.


Config (1).

In IB, Bind the textField's and Slider's values to the model Key  
Path "selection.number".

Connect the NSOjectController's outlet ( cntrl-drag to foo).


Config (2)

As config (1) ...first line only   now Bind NSObjectController  
to Foo, with the model Key Path = self.



Could someone please explain why both work, and any reason for  
choosing one over the other.


Is File's Owner of class Foo? (I'm not sure how you'd bind to Foo  
otherwise.) If so, the two methods are exactly identical.


Method (1) is what you'd normally use for objects inside the NIB file.  
Method (2) is what you'd normally use for objects not in the NIB file.  
File's Owner is not actually in the NIB file, but it pretends to be,  
so you have a choice.



___

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

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

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

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


nib-object retaining question

2009-06-29 Thread WT

Hello list,

suppose I have a nib file where the File Owner's class has outlets to  
some of the objects in the nib. When the nib is loaded, the  
connections are established and the outlet ivars in the (now actual)  
file owner point to the unarchived objects they're supposed to point  
to. All fine and dandy.


I have three questions:

1. Are the nib objects retained by the file owner object?

2. Does the answer to (1) change if the outlet ivars have been defined  
as properties? By that I mean, if the outlet ivars are defined as  
assigned or copied properties, rather than retained properties, does  
the nib-loading process respect those definitions?


3. What if the outlet ivars are not defined as properties?

Thanks in advance.
Wagner
___

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

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

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

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


Re[4]: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello Kyle,

Monday, June 29, 2009, 11:36:54 PM, you wrote:

> Because it directly violates quite a few requirements of working on OS
> X?  And you're resorting to pretty convoluted workarounds to try to
> get things working again.  That should be a pretty good clue that
> you're doing things incorrectly.

Such as what?

If you are referring to me not using NSApplicationMain(), how is that 
unsupported? In fact the code is based on things I've seen in Apple samples. 
[NSApplication sharedApplication] is a documented API. So is loading your own 
NIB. I'm not doing anything illegal there.

> You need NSApplication?  It's an application.  It needs its own
> bundle.  That bundle can live in Resources (or this mythical, unnamed
> "Support" directory referred to in the code signing documentation).

I might well move it to a bundle and put it in Resources, anyway. If we get any 
more problems, I will do so. Originally I had written the dialog in Carbon to 
avoid this hassle.

> Then perhaps you should be considering a refactor.

No. Effectively, the code functions like an executable unpacker. In fact, I got 
the idea from the source code to the UPX executable packer. There is nothing 
wrong with this approach provided the methods are fully understood.

Besides, what do you think Launch Services does? Eventually, it calls 
vfork()/execve(). It just adds some friendly fluff over the top of it.

> You don't know what Apple has in store for code signing requirements
> on post-Leopard operating systems.  It is known that code signing
> requirements will be stricter in the future than they are now.  How
> and when is still unknown, but trying to decrypt and execute an
> application like this might result in irking the security gods.

Since when do apps running on OS X *have* to be code signed?
IF Apple start requiring ALL apps to be code signed (and presumably, charge for 
the privilege), watch as support from smaller developers disappears. Even MS 
aren't going to do that.

> Frequently people come to this list asking for help with their
> copy-protecting scheme.  The consensus is that it is not worth the
> time and money you will invest in the process, or the frustration you
> will (not may, will; I dare anyone to prove that there is absolutely
> no circumstance under which their copy protection can fail) cause for
> your users.  Meanwhile, someone's going to strip off your copy
> protection, upload your game to the web, and pirates who never would
> have purchased your game in the first place will enjoy it hassle-free.

> By all means, make a pass at it.  Do a simple check on startup, and if
> it fails, guilt and shame the user into purchasing the app.  But
> attempting to intervene in the loading process is not going to bode
> well for your code health.

This is exactly the kind of attitude that means game dev does *not* happen on 
OS X.

We reserve the right to attempt to protect our investment and hard work! More 
to the point, we do a lot of porting work, and it is a requirement of the 
original publisher/developer that we protect the port as much as possible.

The aim is not to prevent cracking - that will happen. The aim is to make it as 
difficult as possible, and delay it so that our product has a chance to sell. 
Also, it means we can make thinks awkward for those people using cracked copies.

-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Re: Re[2]: NSApp problem outside of bundle

2009-06-29 Thread Kyle Sluder
On Mon, Jun 29, 2009 at 3:20 PM, Peter
Mulholland wrote:
> Monday, June 29, 2009, 9:17:35 PM, you wrote:
>
>> Woah... this is kinda nuts.
>
> How exactly?

Because it directly violates quite a few requirements of working on OS
X?  And you're resorting to pretty convoluted workarounds to try to
get things working again.  That should be a pretty good clue that
you're doing things incorrectly.

>> 1) Applications need to be in their own app bundle.
>
> Really, this isn't an application, its a component. There's probably a better 
> way to do it, but I can't think of one.

You need NSApplication?  It's an application.  It needs its own
bundle.  That bundle can live in Resources (or this mythical, unnamed
"Support" directory referred to in the code signing documentation).

>> 2) Don't fork/exec to launch an application.  Use LaunchServices instead.
>
> At the low level that this is executed, only BSD stuff is usable. This stuff 
> is executed before main() is even called.

Then perhaps you should be considering a refactor.

>> 3) Your "protection" will be easy to break, and probably won't play
>> nice with code signing. Is it worth the effort?
>
> Our app's aren't code signed and are Intel only.
> We're a games dev company, so yes, it's worth the effort.

You don't know what Apple has in store for code signing requirements
on post-Leopard operating systems.  It is known that code signing
requirements will be stricter in the future than they are now.  How
and when is still unknown, but trying to decrypt and execute an
application like this might result in irking the security gods.

Frequently people come to this list asking for help with their
copy-protecting scheme.  The consensus is that it is not worth the
time and money you will invest in the process, or the frustration you
will (not may, will; I dare anyone to prove that there is absolutely
no circumstance under which their copy protection can fail) cause for
your users.  Meanwhile, someone's going to strip off your copy
protection, upload your game to the web, and pirates who never would
have purchased your game in the first place will enjoy it hassle-free.

By all means, make a pass at it.  Do a simple check on startup, and if
it fails, guilt and shame the user into purchasing the app.  But
attempting to intervene in the loading process is not going to bode
well for your code health.

--Kyle Sluder
___

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

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

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

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


NSObjectController, content outlet and content object question

2009-06-29 Thread Michael de Haan
May I indulge the group with an issue I have been trying to understand  
for a few days. I have tried to read the extensive literature and  
correspondence to the group, but so far have not seen an answer that  
is specific to this question.



Given this simple appwhich keeps a slider and textField's value  
synchronized.


1) View consisting of a slider and a textField
2) Model (Foo) with a single property "number"
3) NSObjectController

I am able to use 2 configurations to get the app to work.


Config (1).

In IB, Bind the textField's and Slider's values to the model Key Path  
"selection.number".

Connect the NSOjectController's outlet ( cntrl-drag to foo).


Config (2)

As config (1) ...first line only   now Bind NSObjectController to  
Foo, with the model Key Path = self.



Could someone please explain why both work, and any reason for  
choosing one over the other.



Thanks in advance.






___

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

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

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

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


Re[2]: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello Stephen,

Monday, June 29, 2009, 11:12:20 PM, you wrote:

> You don't use kCurrentProcess as an argument. You use it like this:

> ProcessSerialNumber psn = { 0, kCurrentProcess };
> TransformProcessType( &psn, ... );

I see. It isn't really explained all that clearly.

I'll give that a shot.


-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Re[2]: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello Kyle,

Monday, June 29, 2009, 9:17:35 PM, you wrote:

> Woah... this is kinda nuts.

How exactly?

> 1) Applications need to be in their own app bundle.

Really, this isn't an application, its a component. There's probably a better 
way to do it, but I can't think of one.

> 2) Don't fork/exec to launch an application.  Use LaunchServices instead.

At the low level that this is executed, only BSD stuff is usable. This stuff is 
executed before main() is even called.

> 3) Your "protection" will be easy to break, and probably won't play
> nice with code signing. Is it worth the effort?

Our app's aren't code signed and are Intel only.
We're a games dev company, so yes, it's worth the effort.


-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Re: NSApp problem outside of bundle

2009-06-29 Thread Stephen J. Butler
On Mon, Jun 29, 2009 at 3:03 PM, Peter
Mulholland wrote:
> BTW Yes I know about kCurrentProcess. It doesn't work. Passing that to 
> TransformProcessType() causes a crash.

You don't use kCurrentProcess as an argument. You use it like this:

ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType( &psn, ... );
___

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

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

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

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


Re: NSApp problem outside of bundle

2009-06-29 Thread Stephen J. Butler
On Mon, Jun 29, 2009 at 10:21 AM, Peter
Mulholland wrote:
> I am not using NSApplicationMain() as this would attempt to load the original 
> app's nib. Instead I do this:
>
> int main(int argc, char *argv[])
> {
>[[NSAutoreleasePool alloc] init];
>[NSApplication sharedApplication];
>
>if ([NSBundle loadNibNamed:@"RegDialog" owner:NSApp])   // Load our 
> bundle
>{
>NSData *icon_data = [NSData dataWithBytes:Security_icns_data 
> length:sizeof(Security_icns_data)];
>NSImage *icon = [[NSImage alloc] initWithData:icon_data];
>
>if (icon)
>[NSApp setApplicationIconImage:icon];
>
>[NSApp run];
>}
>else
>{
>ShowDialog(NSCriticalAlertStyle, "Couldn't load 
> RegDialog.nib\n\nTry reinstalling the application. If this fails please 
> contact Support.");
>return 1;   // Stop stub relaunching us
>}
>
>return 0;
> }

I agree this is a little nuts. But you should be calling
NSApplicationLoad() to initialize NSApplication before doing any Cocoa
stuff.
___

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

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

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

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


Re: Two threads, two managed object contexts. Do I need locking?

2009-06-29 Thread Adam Swift


On Jun 29, 2009, at 1:18 PM, Adam Swift wrote:

No, if the only time/place you access the persistent store  
coordinator is when you create it and then pass it into  
[[NSManagedObjectContext alloc]  
initWithPersistentStoreCoordinator:psc], then you should be fine  
without any additional locking.


Sigh - coffee failure - that should be [moc  
setPersistentStoreCoordinator:psc];

___

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

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

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

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


Re: Two threads, two managed object contexts. Do I need locking?

2009-06-29 Thread Adam Swift


On Jun 29, 2009, at 6:24 AM, Michael Greiner wrote:

My application uses a Core Data model on two threads - the main UI  
thread and a worker thread. Each thread has its own private managed  
object context as per Apple's recommendation. The managed object  
contexts share a single persistent store coordinator.


Only my worker thread modifies the managed objects.  The main thread  
just displays them in the UI (using bindings) where none of the  
properties are editable.


I'm uncertain about whether or not I should be locking that  
persistent store coordinator. Under "General Guidelines" of the  
"Multi-Threading with Core Data" section of the "Core Data  
Programming Guide", it mentions 3 patterns. I am using pattern #1  
which says about locking:


"If you want to aggregate a number of operations in one context  
together as if a virtual single transaction, you can lock the  
persistent store coordinator to prevent other managed object  
contexts using the persistent store coordinator over the scope of  
several operations."



I don't need transaction support since as I said, the UI thread  
never modifies the objects. Further on, in the "Locking" section of  
the document, it says this:


"Generally, you only need to lock a managed object context (and not  
even then if you ensure that each thread has its own private  
context, as described in “General Guidelines”). If you do choose to  
share a managed object context or a persistent store coordinator  
between threads, you must ensure that any method invocations are  
made from a thread-safe scope."


The only time I "share" a persistent store coordinator between the  
threads is when I first create the two managed object contexts.



So do I still need to lock the persistent store coordinator?


No, if the only time/place you access the persistent store coordinator  
is when you create it and then pass it into [[NSManagedObjectContext  
alloc] initWithPersistentStoreCoordinator:psc], then you should be  
fine without any additional locking.


You can (and should) ensure that your mutli-threaded access is correct  
by running your app against the debug version of the core data  
framework and enabling the multi-threaded assertions (see http://lists.apple.com/archives/cocoa-dev/2008/Mar/msg01098.html 
)




I'd appreciate any feedback.

Thanks,
Mike
___

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

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

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

This email sent to asw...@apple.com


___

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

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

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

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


Re: NSApp problem outside of bundle

2009-06-29 Thread Kyle Sluder
On Mon, Jun 29, 2009 at 8:21 AM, Peter
Mulholland wrote:
> A typical protected app bundle looks like so:

Woah... this is kinda nuts.

1) Applications need to be in their own app bundle.
2) Don't fork/exec to launch an application.  Use LaunchServices instead.
3) Your "protection" will be easy to break, and probably won't play
nice with code signing. Is it worth the effort?

--Kyle Sluder
___

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

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

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

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


Re: NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello,

> What's going on? What is NSApp trying to do that falls over when it's not in 
> a bundle, or in another apps bundle on 10.4?

I've solved it. The problem was that [NSApplication sharedApplication] did not 
add the app to the Dock for some reason. The following code solves that:

ProcessSerialNumber psn;
GetCurrentProcess(&psn);
TransformProcessType(&psn, kProcessTransformToForegroundApplication);

This is probably naughty, but it does work. I do this directly after the call 
to [NSApplication sharedApplication].

BTW Yes I know about kCurrentProcess. It doesn't work. Passing that to 
TransformProcessType() causes a crash.

-- 
Best regards,
 Petermailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Re: Load File Faster.

2009-06-29 Thread Nick Zitzmann


On Jun 29, 2009, at 9:35 AM, Philip Juel Borges wrote:

		I have an app that where a toolbar button loads a property list  
file into 3 tableviews, which in turn updates a webview. The file is  
6,3MB. Whenever I press the button it takes roughly 2 seconds.
		How can I make the application load that 6,3MB property list file  
faster?



Use Shark to get your answer. Shark will tell you which functions/ 
methods are taking the longest to run.


Nick Zitzmann


___

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

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

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

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


Question on generating mouse events with modifier keys

2009-06-29 Thread Andrew Wu
Hello,

I'm interested in creating a utility that can generate mouse clicks
with modifier keys (e.g. Ctrl + Primary button), ideally in python
(taking advantage of the python-cocoa bridge).  This would first be
for machines running Leopard, and ideally later with Snow Leopard.

I've looked at some of the Cocoa documentation and tried some of the
examples, but b/c I'm not familiar with Cocoa development or
Objective-C a lot of it is going over my head.  For instance some
references I've found include:

http://www.osxbook.com/book/bonus/chapter2/altermouse/
http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventCreateKeyboardEvent

I've read up on CGEventCreateKeyboardEvent and CGEventCreateMouseEvent
and CGEventPost. I have tried the example in
CGEventCreateKeyboardEvent to output a 'Z' (although for me the sample
continues to output a 'z' (lower-case 'z') in python with:

from Quartz import *
event1 = CGEventCreateKeyboardEvent (None, 56, True);
event2 = CGEventCreateKeyboardEvent (None, 6, True);
event3 = CGEventCreateKeyboardEvent (None, 6, False);
event4 = CGEventCreateKeyboardEvent (None, 56, False);

I then tried creating a double-click event based upon
http://lists.apple.com/archives/quartz-dev/2008/Jun/msg1.html but
continue to see only a single-click (verified by having a Terminal
window open with some lines populating the window.  Normally a
double-click would highlight the string under the mouse cursor, but
what I've seen so far has been the mouse cursor moving to that
location only and no highlight).

Here is a snippet of what I'd tried to create the double-click event with:

evRef = []
# The lines commented out were an experimentation to send a
Ctrl+Primary mouse click
#evRef.append(CGEventCreateKeyboardEvent(None, 59, True))
evRef.append(CGEventCreateMouseEvent(None, kCGEventOtherMouseDown,
CGPointMake(720, 450), kCGMouseButtonLeft))
evRef.append(CGEventCreateMouseEvent(None, kCGEventOtherMouseUp,
CGPointMake(720, 450), kCGMouseButtonLeft))
#evRef.append(CGEventCreateKeyboardEvent(None, 59, False))

# Set double-click:
# Doesn't work?
count = 2
CGEventSetIntegerValueField(eventRef, kCGMouseEventClickState, count)

for i in range(2):
   CGEventPost(kCGHIDEventTap, evRef[0])
   CGEventPost(kCGHIDEventTap, evRef[1])


Any help / tips would be much appreciated.  I tried searching the
Cocoa-dev list archives with terms "sending mouse events", "generate
mouse events", "CGEventCreateMouseEvent" with little success.  Also,
b/c I am a new subscriber, I'm not entirely sure this is the
appropriate list to use - apologies if that is the case.



Many thanks!

Andrew
___

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

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

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

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


Re: Columns widths specified programmatically seem to be wider.

2009-06-29 Thread Laurent Etiemble
Hello,

Take a look at "setIntercellSpacing:" in NSTableView Class Reference.
The default intercell spacing is (3.0, 2.0), so it may explains the
delta you see.

Regards, Laurent Etiemble.

Monobjc : A .NET/Objective-C Bridge
More info at http://www.monobjc.net/

2009/6/29 Nor :
> Although total of the widths should be the same as the width in-between the
> left edge of the scrollview and the right edge minus the width of the
> vertical scroller,
> so although it should see all columns fully, the most right column can't see
> it whole content unless mouse-wheeling right.
>
>
> The following code is all I wrote. I put an NSTableView on a window which
> came in the Cocoa Application template, and an object which was called
> MyTableSizer.
>
> @interface MyTableSizer : NSObject {
>  IBOutlet NSTableView* _tableview;
> }
> @end
>
> @implementation MyTableSizer
> - (void) awakeFromNib
> {
>  float aScrollViewWidth = NSWidth([[_tableview enclosingScrollView]
> frame]);
>  float aTableViewWidth = aScrollViewWidth - [NSScroller scrollerWidth];
>
>  NSLog (@"ScrollView width : %f", aScrollViewWidth);
>  NSLog (@"TableView width  : %f", aTableViewWidth);
>
>  NSEnumerator* enm = [[NSArray arrayWithArray:[_tableview tableColumns]]
> objectEnumerator];
>  id col;
>  while (col = [enm nextObject])
> [_tableview removeTableColumn:col];
>
>
>  int counter = 5;
>  float quotient = aTableViewWidth / counter;
>  NSLog (@"Each Column's width: %f", quotient);
>  while (counter > 0)
>  {
> NSTableColumn* col = [[NSTableColumn alloc] initWithIdentifier:
>                     [NSString stringWithFormat:@"%d",counter]];
> [col setWidth:quotient];
> [_tableview addTableColumn:[col autorelease]];
> counter--;
>  }
> }
> @end
>
> That's all.
>
> The TableSizer is allocated and initialized in Nib file.
>
>
> 2009-06-29 18:06:47.302 TEST[2649:813] ScrollView width : 480.00
> 2009-06-29 18:06:47.304 TEST[2649:813] TableView width  : 465.00
> 2009-06-29 18:06:47.305 TEST[2649:813] Each Column's width: 93.00
>
>
> The log seems to be correct, but actual tableview is actually wider.
>
> What do you think I'm missing?
>
> Any suggestions, advices, and workarounds would be very appreciated. I
> really need our help.
>
> Thank you,
> 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/laurent.etiemble%40gmail.com
>
> This email sent to laurent.etiem...@gmail.com
>
___

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

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

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

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


Load File Faster.

2009-06-29 Thread Philip Juel Borges

Hi!

		I have an app that where a toolbar button loads a property list file  
into 3 tableviews, which in turn updates a webview. The file is 6,3MB.  
Whenever I press the button it takes roughly 2 seconds.
		How can I make the application load that 6,3MB property list file  
faster?


/Philip



___

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

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

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

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


NSApp problem outside of bundle

2009-06-29 Thread Peter Mulholland
Hello,

I've made a program that handles doing a registration dialog for our protected 
apps. The protection works by encrypting the original Mach-O executable and 
attaching a stub. This stub attempts to load a licence file. If it's not 
present, it vfork()/execve()'s this app.

A typical protected app bundle looks like so:

ProtectedApp.app
+- Contents
   +- MacOS
   |  +- ProtectedApp (the original app's binary, now protected)
   |  +- RegDialog (the binary for the registration dialog)
   +- Resources
  +- RegDialog.nib
  +- 

The info.plist remains unchanged from the original ProtectedApp.app. The only 
changes are to the app's executable, and the addition of the RegDialog 
executable and it's nib.

On 10.5, this works fine, when the protected app invokes RegDialog it functions 
normally.

On 10.4, when RegDialog is run, no icon appears in the Dock, and although the 
window in RegDialog appears, the window does not get made frontmost and does 
not get focus. Keyboard focus doesn't work even if you click in text fields, 
and as such the dialog is unusable.

I am not using NSApplicationMain() as this would attempt to load the original 
app's nib. Instead I do this:

int main(int argc, char *argv[])
{
[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];  

if ([NSBundle loadNibNamed:@"RegDialog" owner:NSApp])   // Load our 
bundle
{
NSData *icon_data = [NSData dataWithBytes:Security_icns_data 
length:sizeof(Security_icns_data)];
NSImage *icon = [[NSImage alloc] initWithData:icon_data];

if (icon)
[NSApp setApplicationIconImage:icon];

[NSApp run];
}
else
{
ShowDialog(NSCriticalAlertStyle, "Couldn't load 
RegDialog.nib\n\nTry reinstalling the application. If this fails please contact 
Support.");
return 1;   // Stop stub relaunching us
}

return 0;
}

As you can see, I load  the nib myself. I also set a custom icon from data 
embedded in the executable, but that's not important. ShowDialog is a routine 
that uses an NSAlert to display a dialog.

A similar effect occurs on 10.5 if i just have a RegDialog binary and 
RegDialog.nib in the same folder, and I run RegDialog from Terminal. It opens 
and loads but the window doesn't get focus.

Inside it's own bundle, RegDialog.app, it all works, but I don't really want to 
have to drop an app bundle inside the protected app's bundle to make it work.

What's going on? What is NSApp trying to do that falls over when it's not in a 
bundle, or in another apps bundle on 10.4?

-- 
Best regards,
 Peter  mailto:darkmat...@blueyonder.co.uk

___

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

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

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

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


Two threads, two managed object contexts. Do I need locking?

2009-06-29 Thread Michael Greiner
My application uses a Core Data model on two threads - the main UI thread and a 
worker thread. Each thread has its own private managed object context as per 
Apple's recommendation. The managed object contexts share a single persistent 
store coordinator. 

Only my worker thread modifies the managed objects.  The main thread just 
displays them in the UI (using bindings) where none of the properties are 
editable. 

I'm uncertain about whether or not I should be locking that persistent store 
coordinator. Under "General Guidelines" of the "Multi-Threading with Core Data" 
section of the "Core Data Programming Guide", it mentions 3 patterns. I am 
using pattern #1 which says about locking: 

"If you want to aggregate a number of operations in one context together as if 
a virtual single transaction, you can lock the persistent store coordinator to 
prevent other managed object contexts using the persistent store coordinator 
over the scope of several operations." 


I don't need transaction support since as I said, the UI thread never modifies 
the objects. Further on, in the "Locking" section of the document, it says 
this: 

"Generally, you only need to lock a managed object context (and not even then 
if you ensure that each thread has its own private context, as described in 
“General Guidelines”). If you do choose to share a managed object context or a 
persistent store coordinator between threads, you must ensure that any method 
invocations are made from a thread-safe scope." 

The only time I "share" a persistent store coordinator between the threads is 
when I first create the two managed object contexts. 


So do I still need to lock the persistent store coordinator? 

I'd appreciate any feedback. 

Thanks, 
Mike
___

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

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

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

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


Re: display Mac id

2009-06-29 Thread Kiran Kumar

thanks for reply

And one more thing that ,i want to display MACID first two characters in one 
textfield,and next two characters in next textfield .
The maximum length of textfield should be 2 characters,and then focus to next 
textfield. Can u help me plz...

thanks,
kiran

On 24-Jun-09, at 12:28 PM, Laurent Cerveau wrote:

You can use IOKit UserLibg  get the MAC hardware address. I did not retest it 
though (it comes from older code) so you probably have to check for small bugs.

laurent

kern_return_t kernResult;
mach_port_t masterPort;
io_service_t tmpService, controllerService;
CFDataRef macAddressData;
CFMutableDictionaryRef classesToMatch;
//Get the master port
kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
//Find the etherner 0 card criteria
classesToMatch = IOBSDNameMatching(masterPort,0,"en0");
//find the corresponding service
tmpService = IOServiceGetMatchingService(masterPort, classesToMatch);
   // by asking for it specifically.
kernResult = IORegistryEntryGetParentEntry( tmpService, kIOServicePlane, 
&controllerService );

//now we get the data and do something with them
macAddressData = (CFDataRef) IORegistryEntryCreateCFProperty( 
controllerService,CFSTR(kIOMACAddress), kCFAllocatorDefault, 0);

//release what is needed
CFRelease(macAddressData);
IOObjectRelease(controllerService);
IOObjectRelease(tmpService);

On Jun 23, 2009, at 9:04 AM, Kiran Kumar wrote:

Hi all,

i am doing project to change MAC Address ,i want to display MACID in
a single textbox like 00:15:e9:4c:c3:d7

or 00-15-e9-4c-c3-d7 can any one help me plz ...




Thanks,
kiran

The information contained in this email and any attachments is confidential and 
may be subject to copyright or other intellectual property protection. If you 
are not the intended recipient, you are not authorized to use or disclose this 
information, and we request that you notify us by reply mail or telephone and 
delete the original message from your mail system.
___

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

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

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

This email sent to lcerv...@me.com




The information contained in this email and any attachments is confidential and 
may be subject to copyright or other intellectual property protection. If you 
are not the intended recipient, you are not authorized to use or disclose this 
information, and we request that you notify us by reply mail or telephone and 
delete the original message from your mail system.
___

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

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

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

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


Web cam: "Camera used by another application"

2009-06-29 Thread Deepa

Hi,

I am using QTKit APIs for streaming from webcam. I get the error  
message 'Camera used by another application' for some of the webcams.  
But, no other application was using this webcam. The applications like  
Photobooth, iChat can stream properly from this webcam


Following are the steps to stream from the device:

1. Open the input device: [inputDevice open: &error]

It opens the device successfully without any error.

2. add input device to capture session: [captureSession addInput:  
inputDevice error: &error]



3. Call [captureSession startRunning]

But, it displays a message 'Camera used by another application' in  
QTCaptureView( We are not sure whether it is put up by QTkit framework  
or the webcam driver). We also get the following console log:



"usbConnectToCam-USBDeviceOpen: Error: kIOReturnExclusiveAccess -  
exclusive access and device already open"


Can anyone help me out to solve this problem.

Thanks in advance,
Deepa
de...@robosoftin.com





---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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

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

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

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


Finding objects in a NSDocument

2009-06-29 Thread Jeff Schriebman
I have a NSDocument class that has a large number of NSTextField  
objects in it.
I would like to get at each of the tag fields in the NSTextField  
objects using the tag instance.


Is there a simple way to iterate over the top level objects in the  
NSDocument and find all of the NSTextField objects?


Jeff Schriebman



___

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

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

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

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


Re: How to get a fully transparent hit-testable window?

2009-06-29 Thread Michael Ash
On Fri, Jun 26, 2009 at 4:14 PM, Pranav Goel wrote:
> Hi
> I am writing a Cocoa application which has a WebView in a NSWindow. I want to 
> be able to put this window onscreen and have it be completely transparent 
> i.e. nothing should be drawn on the screen. But I still want the WebView to 
> respond to mouse input when a mouse action happens within its window rect. Is 
> there a way to do this?
>
> I tried setting Opacity on the window to 0, I don't see anything on the 
> screen which is great. But the window (and the WebView) don't respond to 
> input anymore, apparently a NSWindow becomes transparent to mouse input for 
> opacity values less than 0.05 or so.

[window setIgnoresMouseEvents:NO];

Mike
___

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

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

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

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


Re: External Drives Questions

2009-06-29 Thread Fred Baker

On Jun 29, 2009, at 5:17 AM, Ammar Ibrahim wrote:


How can I do the following in Cocoa:
1- Get the list of mounted drives?
2- Get the serial number of the mounted drive/disk


Since serial numbers tend to be associated more with devices rather  
than volumes, your best bet would be to use IOKit to get this  
information. Like Disk Arbitration, IOKit can provide notifications  
when a volume appears or disappears, or its status changes.


___

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

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

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

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


NSURL URLWithString:relativeToURL: generates an extra /

2009-06-29 Thread Fritz Anderson
I've worked around this by simply building my URL string completely by  
hand, but I'd like to learn...


iPhone OS 3.0.

At +initialize time, my class sets up a static NSURL object:

sBaseURL = [[NSURL alloc] initWithScheme: @"http"
host: @"www.example.com:8080"
path: @"/"];

NSURL treats an empty or nil path as illegal.

Later, I build up a path:

NSMutableString *	path = [NSMutableString stringWithString: @"calendar/ 
join?"];
[path appendFormat: @"start_date=%@", [sDirserverParamFormat  
stringFromDate: start]];
[path appendFormat: @"&end_date=%@", [sDirserverParamFormat  
stringFromDate: finish]];


(sDirserverParamFormat is an NSDateFormatter static.)

And then I construct the URL I want to load from:

NSURL *			queryURL = [NSURL URLWithString: path relativeToURL:  
sBaseURL];


However, the resulting URL chokes my server (Rails 2.x, if it  
matters). The URL string generated by this method is like


http://www.example.com:8080//calendar/join?start_date=20090601&end_date=20090630

Note the doubled slash before "calendar." My server is perfectly happy  
if it's a single slash.


Is this a nonconformity in my server, or should I be able to use  
relative paths in NSURL to generate paths without double slashes? If  
the latter, how do I do that?


I've Googled "NSURL double slash," and found an "openradar" bug that's  
similar. If nobody has guidance on this, I'll file a real radar.


— F

___

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

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

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

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


Re: External Drives Questions

2009-06-29 Thread Gregory Weston

Ammar Ibrahim wrote:


How can I do the following in Cocoa:
1- Get the list of mounted drives?


[[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]


2- Get the serial number of the mounted drive/disk


Don't know about serial number, but for UUID you use the Disk  
Arbitration framework. Create a DADiskRef and get its description  
dictionary, then examine the keys. The volume ID is  
kDADiskDescriptionVolumeUUIDKey.


But note that not all volumes have UUIDs.
___

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

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

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

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


Re: Disabling buttons in NSSavePanel

2009-06-29 Thread Steve Christensen
A question about disabling the Save button was just asked on this  
list a few days ago. The thread is archived here: . Google is your  
friend...


steve


On Jun 29, 2009, at 6:45 AM, Michael Domino wrote:

I use an NSSavePanel to select a file, enter and confirm a  
password, encrypt
it and save a copy with a new extension. There is an accessory view  
for

entering and confirming a password. I would like the OK button to be
disabled while there is no file selection, and if the password/confirm
password fields are empty and/or don’t match. I use  
NSNotificationCenter to

observe the text fields to check whenever the user enters text and
enable/disable the OK button. This all nearly works, the only  
problem is
that when you select a file, the OK button is enabled and I have  
not been
able to find a hook or delegate method that will allow me to  
override this
behavior. I tried observing for changes to _nameField, to see if  
maybe I

could set the enabled state for the button there, but my method is not
called even though the delegate is set.

What about finding the NSButton view in the dialog window (search  
for the
view title “OK”), replacing it with my own subclass of NSButton to  
override

setEnable to include the additional criteria?

The other thing is that I’m referencing the _okButton and  
_nameField outlets
in NSSavePanel that do not have accessors, so I get the warning  
about that

being a hard error in the future, which makes me nervous.

Has anyone needed to solve this problem, and if so how did you do it?

___

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

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

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

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


Question about font managing (NSFont).

2009-06-29 Thread Anders Lassen

Hi,

I am working on a project that uses a lot of fonts.

To be more precise. I have an object tree consisting of many small  
objects that draw themselves to a view. Each object can either use a  
default font setup or make local variations to the default font setup.  
By local variations, I mean weight and italic style.


I can now decide to have only one instance of the default fonts and  
then create local variations, which are stored in each object in the  
tree. I can also decide to store the local font (variations) globally  
and make som kind of lookup system. This of course requires a lot more  
business-logic, and hope to avoid this.


My problem is, that I do not know much a about fonts and how they are  
handled by the system.


Is a font a large object that requires a lot of memory usage and CPU  
time for initial loading, etc. ??? or should I just think of it, as an  
small object pointer.


(my object tree will in average contain about 100-300 objects).


I hope someone can help on this.


Anders Lassen
___

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

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

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

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


Re: Objective C Compiler Settings

2009-06-29 Thread Michael Ash
On Sun, Jun 28, 2009 at 8:08 PM, Graham Cox wrote:
>
> On 29/06/2009, at 9:18 AM, Michael Ash wrote:
>
>> Not an exception, but you can get the runtime to log any replaced
>> methods by setting the OBJC_PRINT_REPLACED_METHODS environment
>> variable when running your app. This and other environment variables
>> can be found by running an ObjC program with the OBJC_HELP enviroment
>> variable set. This will print out a brief bit of documentation about
>> all the debugging variables supported by the runtime.
>
> Cool, that's really useful and previously unknown to me - where did you get
> to know about this? Can you point to documentation? Seems I'm missing a
> whole bunch of stuff that others know about.

Honestly I have no idea where I found out about it. It's just one of
those things I had rattling around in my brain. The technote that
Gerriet linked to is a good candidate, though.

Mike
___

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

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

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

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


Columns widths specified programmatically seem to be wider.

2009-06-29 Thread Nor
Although total of the widths should be the same as the width in-between the
left edge of the scrollview and the right edge minus the width of the
vertical scroller,
so although it should see all columns fully, the most right column can't see
it whole content unless mouse-wheeling right.


The following code is all I wrote. I put an NSTableView on a window which
came in the Cocoa Application template, and an object which was called
MyTableSizer.

@interface MyTableSizer : NSObject {
  IBOutlet NSTableView* _tableview;
}
@end

@implementation MyTableSizer
- (void) awakeFromNib
{
  float aScrollViewWidth = NSWidth([[_tableview enclosingScrollView]
frame]);
  float aTableViewWidth = aScrollViewWidth - [NSScroller scrollerWidth];

  NSLog (@"ScrollView width : %f", aScrollViewWidth);
  NSLog (@"TableView width  : %f", aTableViewWidth);

  NSEnumerator* enm = [[NSArray arrayWithArray:[_tableview tableColumns]]
objectEnumerator];
  id col;
  while (col = [enm nextObject])
[_tableview removeTableColumn:col];


  int counter = 5;
  float quotient = aTableViewWidth / counter;
  NSLog (@"Each Column's width: %f", quotient);
  while (counter > 0)
  {
NSTableColumn* col = [[NSTableColumn alloc] initWithIdentifier:
 [NSString stringWithFormat:@"%d",counter]];
[col setWidth:quotient];
[_tableview addTableColumn:[col autorelease]];
counter--;
  }
}
@end

That's all.

The TableSizer is allocated and initialized in Nib file.


2009-06-29 18:06:47.302 TEST[2649:813] ScrollView width : 480.00
2009-06-29 18:06:47.304 TEST[2649:813] TableView width  : 465.00
2009-06-29 18:06:47.305 TEST[2649:813] Each Column's width: 93.00


The log seems to be correct, but actual tableview is actually wider.

What do you think I'm missing?

Any suggestions, advices, and workarounds would be very appreciated. I
really need our help.

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


Disabling buttons in NSSavePanel

2009-06-29 Thread Michael Domino
Hi,

I use an NSSavePanel to select a file, enter and confirm a password, encrypt
it and save a copy with a new extension. There is an accessory view for
entering and confirming a password. I would like the OK button to be
disabled while there is no file selection, and if the password/confirm
password fields are empty and/or don¹t match. I use NSNotificationCenter to
observe the text fields to check whenever the user enters text and
enable/disable the OK button. This all nearly works, the only problem is
that when you select a file, the OK button is enabled and I have not been
able to find a hook or delegate method that will allow me to override this
behavior. I tried observing for changes to _nameField, to see if maybe I
could set the enabled state for the button there, but my method is not
called even though the delegate is set.

What about finding the NSButton view in the dialog window (search for the
view title ³OK²), replacing it with my own subclass of NSButton to override
setEnable to include the additional criteria?

The other thing is that I¹m referencing the _okButton and _nameField outlets
in NSSavePanel that do not have accessors, so I get the warning about that
being a hard error in the future, which makes me nervous.

Has anyone needed to solve this problem, and if so how did you do it?

Thanks,
Michael

-- 
Michael Domino
michael.dom...@identityfinder.com

___

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

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

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

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


External Drives Questions

2009-06-29 Thread Ammar Ibrahim
How can I do the following in Cocoa:
1- Get the list of mounted drives?
2- Get the serial number of the mounted drive/disk

I would assume when you plugin a disk drive that was already configured to
use Time Machine. Time machine would check the serial number, and start
backing up if it's already "paired". I'm interested to know how this
actually works.
___

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

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

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

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


Re: Dispose pattern (was: Re: GC pros and cons)

2009-06-29 Thread Konrad Neitzel
Hi Stephen,

thank you very much for taking the time to look at the given link and writing 
this very nice response to me.

Think I was little confused so I mixed a few things that simply should stay 
seperate.
(Managing resources in close() has simply nothing to do GarbageCollection. Some 
activities may help the GC but it is not, what the main discussion was about 
and it is (normaly) not required. And if something is required, there are 
better ways e.g.  collectIfNeeded message gives a hint to the Garbage 
Collector. )

The Garbage Collection Programming Guide from Apple holds a lot of nice 
information and I simply should have readed that before I bothered the Mailling 
List.
Sorry, if I confused anybody and thank you who tried to help me with their time 
and answers.

With kind regards,

Konrad

___

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

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

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

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


Dock refuses dropped files

2009-06-29 Thread Keith Duncan
I'm trying to figure out how to inform launch services that my  
application can handle all file types.
Dragging files to the application icon in the Finder works as  
expected, but the Dock icon refuses to accept drops(!)
I've added the following to the info.plist (the actual document type  
has been changed):



http://www.apple.com/DTDs/PropertyList-1.0.dtd 
">



CFBundleTypeName
com.myidentifier.product
LSItemContentTypes

public.data
public.content

CFBundleTypeRole
Editor
LSHandlerRank
None
NSDocumentClass
DSDocument




___

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

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

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

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


Columns widths specified programmatically seem to be wider.

2009-06-29 Thread norio ota
Although total of the widths should be the same as the width in- 
between the left edge of the scrollview and the right edge minus the  
width of the vertical scroller,
so although it should see all columns fully, the most right column  
can't see it whole content unless mouse-wheeling right.



The following code is all I wrote. I put an NSTableView on a window  
which came in the Cocoa Application template, and an object which was  
called MyTableSizer.


@interface MyTableSizer : NSObject {
   IBOutlet NSTableView* _tableview;
}
@end

@implementation MyTableSizer
- (void) awakeFromNib
{
   // _tableview is specified in Nib file
   float aScrollViewWidth = NSWidth([[_tableview enclosingScrollView]  
frame]);
   float aTableViewWidth = aScrollViewWidth - [NSScroller  
scrollerWidth];


   NSLog (@"ScrollView width : %f", aScrollViewWidth);
   NSLog (@"TableView width  : %f", aTableViewWidth);

   NSEnumerator* enm = [[NSArray arrayWithArray:[_tableview  
tableColumns]] objectEnumerator];

   id col;
   while (col = [enm nextObject])
[_tableview removeTableColumn:col];


   int counter = 5;
   float quotient = aTableViewWidth / counter;
   NSLog (@"Each Column's width: %f", quotient);
   while (counter > 0)
   {
	NSTableColumn* col = [[NSTableColumn alloc] initWithIdentifier: 
[NSString stringWithFormat:@"%d",counter]];

[col setWidth:quotient];
[_tableview addTableColumn:[col autorelease]];
counter--;
   }
}
@end

That's all.

The TableSizer is allocated and initialized in Nib file.


2009-06-29 18:06:47.302 TEST_NSTableColumnWidth[2649:813] ScrollView  
width : 480.00
2009-06-29 18:06:47.304 TEST_NSTableColumnWidth[2649:813] TableView  
width  : 465.00
2009-06-29 18:06:47.305 TEST_NSTableColumnWidth[2649:813] Each  
Column's width: 93.00



The log seems to be correct, but actual tableview is actually wider.

What do you think I'm missing?

Any suggestions, advices, and workarounds would be very appreciated. I  
really need our help.


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


Re: Force NSTextField to update (and transform)

2009-06-29 Thread Michał Glenc

Hi,
Thanks for the advice. I was using bindings just to create a simple  
application.
I found a simple workaround for this problem. I added an IBAction in  
controller, which handles value change in ComboBox. When user picks up  
a currency, a message to the transformer is sent in order to set the  
value of ivar (the one that TextField is binded to) to the value of  
the same TextField. Now everything works fine.


On 2009-06-29, at 07:00, mmalc Crawford wrote:


On Jun 26, 2009, at 5:37 AM, Michał Glenc wrote:

I'm a beginner in Cocoa world and I have some problems with  
bindings, NSValueTransformer etc.


Cocoa bindings is not a beginner technology.  You are encouraged to  
gain some experience with Cocoa before using bindings.


My application performs basic currency transforming. I have two  
NSComboBoxes (where I change currency) and two NSTextFields.  
Everything works fine, the values get transformed. However, when I  
change currency in one of ComboBoxes (after values in TextField  
have been already entered), value in TextField stays unchanged.  
What I want to achieve is to send the TextField (or perhaps the  
NSValueTransformer) a message that it's value has been changed (so  
that it retransforms) when the currency in ComboBox is changed.  
Could you advise me something?


What value is the combo box changing?  If it is simply changing a  
value that the value transformer uses, then this will not effect a  
change in the text fields.  The text fields will only update if the  
model value they represent -- or a value upon which the model value  
depends -- is updated.


(I may be missing something obvious here, but offhand...) If you had  
a controller object that manages the values in the text field and  
the exchange rate, then you could make the converted amount  
dependent on the values of the source amount and the exchange rate  
-- you probably wouldn't need a value transformer, though.


mmalc


___

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

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

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

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


Re: GC pros and cons

2009-06-29 Thread James Gregurich

you're right.

I do make the assumption that only sane exceptions are  
thrown...meaning subclasses of NSException & std::exception. Certainly  
any code that I control only throws proper exceptions. For C++  
functions, I use exception specifiers. so, if any function throws the  
wrong type of exception, it fails very early in the stack unwinding so  
that I have a good idea of where the problem is.




On Jun 28, 2009, at 7:23 PM, Chris Idou wrote:








From: James Gregurich 

3) I don't allow exceptions of any kind to propagate into alien  
codeparticularly the cocoa runtime.




Given that Objective-C doesn't have declared exceptions (like Java),  
it seems more likely that you "hope" exceptions are not propagated  
into alien code.


Unless that is you are in the unusual situation that you use no  
third party libraries, or you have full and perfect knowledge of  
where and when they might throw an exception.



 Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail
___

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

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

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

This email sent to bayoubenga...@mac.com


___

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

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

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

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


Re: NSRuleEditor

2009-06-29 Thread Ashley Clark

On Jun 28, 2009, at 8:29 PM, Loukas Kalenderidis wrote:

There's no sample code for NSRuleEditor, right? Or am I missing  
something?


I saw someone ask this on a list last year and the answer was "no,  
but I've got a sample I can send you" - does anyone have anything  
they're willing to share? I remember seeing in the "companion  
guides" section of the NSRuleEditor class reference a reference to a  
guide that sounded actually relevant but it wasn't actually linked,  
and has disappeared since updating my documentation. Bummer.


Check out the example code mentioned in this message: 
http://www.cocoabuilder.com/archive/message/cocoa/2008/6/20/210710

It shows how to use a NIB to create your views for use within an  
NSRuleEditor. I *believe* it is the mysterious missing sample code.  
Whether it is or it isn't, please file a bug requesting sample code  
for NSRuleEditor.



Ashley
___

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

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

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

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


Re: Intersection of CGPath and CGRect

2009-06-29 Thread Martin Hewitson
Graham, thanks a lot for your thoughts on this. The 1x1 bitmap is a  
nice idea; I'll have a go at that. I've grabbed the drawkit source and  
will have a look at how you got that working.


Thanks again,

Martin

On 29 Jun 2009, at 01:07, Graham Cox wrote:



On 28/06/2009, at 4:43 AM, Martin Hewitson wrote:

Does anyone know a good way to test if a CGPathRef intersects a  
CGRect at any point?



This can be a hard problem.

First, naturally discard the trivial case of the bounding rect of  
the path not intersecting the rect you're testing. The further  
approach you take will probably best be dictated by what you're  
trying to actually do.


If the purpose is to simply test whether a rect has hit a path, for  
hit-testing purposes, I've found one of the fastest general methods  
is to render the path into a 1 x 1 bitmap context with only an alpha  
channel. Using the rect for hit-testing against as a source rect,  
the portion of the path bounding rect that intersects that is scaled  
down using a suitable transform into the bitmap. If the outcome is  
some non-transparent alpha value, you got a hit, otherwise, you  
didn't. Somewhat surprisingly, I found this technique faster than  
any other I tried and very nice for hit-testing, as it takes into  
account what was actually rendered - strokes, fills, alpha and anti- 
aliasing. (Thanks due here to Ken Ferry who first suggested this  
approach to me).


If on the other hand you actually need to find the points at which  
the rect intersects the path, you'll need a very different approach.  
In this case testing a line segment against the path can be done, so  
you'd need to break the rect down into four line segments then test  
each one. It's hard to quickly find the intersection of a line  
segment with an arbitrary bezier curve, but somewhat easier if the  
curve is first flattened so you're just testing line segments  
against other line segments. It can still be an expensive operation  
though - it's well worth breaking a path down into its elements and  
first finding the bounding rects of each element, and trivially  
eliminating all those that don't intersect, then doing the more  
brute-force intersection test on what remains.


DrawKit ( http://apptree.net/drawkitmain.htm ) contains code for  
doing both kinds of testing - feel free to use what's there.


--Graham





Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

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