Re: Send files from iphone

2009-07-03 Thread Development
It's the smallest errors that create the greatest frustration. I left  
out a semi colon. and misspelled boundary. Which makes me wonder why  
the examples I found didnt work.


On Jul 3, 2009, at 9:34 PM, Development wrote:


Ok I have made a tiny bit of progress.

The problem is that the _POST and _FILE arrays are still empty  
Well... the _POST array on the server is filled with a mix of the  
data it should have scrambled in with jpeg data. I desperately need  
help I cannot find the answer for this for some reason. I've been  
googling for hours now and the example code doesn't work either.


Below is the sending code:

NSMutableData * sendData= [[NSMutableData alloc]init];
NSMutableData * body= [[NSMutableData alloc]init];
NSString * boundry = @"@@##$$rew**&&^%^";
NSString * name=[path lastPathComponent];
NSString * dir= [path stringByDeletingLastPathComponent];

	[body appendData:[[NSString stringWithFormat:@"-...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"%...@\"\r\n\r 
\n",@"fileName"]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString  
stringWithFormat:@"%@",name]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"%...@\"\r\n\r 
\n",@"directory"]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString  
stringWithFormat:@"%@",dir]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"image_file\" filename=\"%...@\"\r\n\r 
\n",name]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[@"Content-Type: application/octet-stream\r\n"  
dataUsingEncoding:NSUTF8StringEncoding]];

[body appendData:imageData];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@--\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];


int totalSize =[body length];
NSLog(@"Total size: %i",totalSize);
	[sendData appendData:[@"Content-Type: multipart/form-data;  
boundary=@@##$$rew**&&^%^\r\n"  
dataUsingEncoding:NSUTF8StringEncoding]];
	[sendData appendData:[[NSString stringWithFormat:@"Content-Length:  
%i\r\n\r\n",totalSize]dataUsingEncoding:NSUTF8StringEncoding]];

[sendData appendData:body];
[self startConnection];
[self sendMainHeadersForPage:@"/image.php"];
[self sendData:sendData];

___

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

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

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

This email sent to developm...@fornextsoft.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: looks like my syntax is wrong. Does not compile

2009-07-03 Thread Andrew Farmer

On 3 Jul 2009, at 21:29, Agha Khan wrote:

Aobject is type of Myobject*

it has an array for 6 intergers

Aobject.myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt: 
1], [NSNumber numberWithInt: 2],[NSNumber numberWithInt:3],  
[NSNumber numberWithInt:4], [NSNumber numberWithInt:5],[NSNumber  
numberWithInt:6], nil];


Now I would like to randomize it.

for (int j = 0; j < 6; j++)
{
NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
   // looks like my syntax is wrong. Does not compile
}


Your syntax is indeed incorrect - you may want to review Apple's  
Objective-C documentation [1]. Moreover, it's not clear how this is  
supposed to randomize the array, as no random numbers are involved.


[1]: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
___

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

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

2009-07-03 Thread Development

Ok I have made a tiny bit of progress.

The problem is that the _POST and _FILE arrays are still empty Well...  
the _POST array on the server is filled with a mix of the data it  
should have scrambled in with jpeg data. I desperately need help I  
cannot find the answer for this for some reason. I've been googling  
for hours now and the example code doesn't work either.


Below is the sending code:

NSMutableData * sendData= [[NSMutableData alloc]init];
NSMutableData * body= [[NSMutableData alloc]init];
NSString * boundry = @"@@##$$rew**&&^%^";
NSString * name=[path lastPathComponent];
NSString * dir= [path stringByDeletingLastPathComponent];

	[body appendData:[[NSString stringWithFormat:@"-...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"%...@\"\r\n\r 
\n",@"fileName"]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString  
stringWithFormat:@"%@",name]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"%...@\"\r\n\r 
\n",@"directory"]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString  
stringWithFormat:@"%@",dir]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithFormat:@"Content-Disposition:  
form-data; name=\"image_file\" filename=\"%...@\"\r\n\r 
\n",name]dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[@"Content-Type: application/octet-stream\r\n"  
dataUsingEncoding:NSUTF8StringEncoding]];

[body appendData:imageData];
	[body appendData:[[NSString stringWithFormat:@"\r\n...@--\r 
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];


int totalSize =[body length];
NSLog(@"Total size: %i",totalSize);
	[sendData appendData:[@"Content-Type: multipart/form-data;  
boundary=@@##$$rew**&&^%^\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
	[sendData appendData:[[NSString stringWithFormat:@"Content-Length: %i 
\r\n\r\n",totalSize]dataUsingEncoding:NSUTF8StringEncoding]];

[sendData appendData:body];
[self startConnection];
[self sendMainHeadersForPage:@"/image.php"];
[self sendData:sendData];

___

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

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


looks like my syntax is wrong. Does not compile

2009-07-03 Thread Agha Khan

Aobject is type of Myobject*

it has an array for 6 intergers

Aobject.myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt: 
1], [NSNumber numberWithInt: 2],[NSNumber numberWithInt:3], [NSNumber  
numberWithInt:4], [NSNumber numberWithInt:5],[NSNumber numberWithInt: 
6], nil];


Now I would like to randomize it.

for (int j = 0; j < 6; j++)
{
NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
// looks like my syntax is wrong. Does not compile

}

___

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

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


[Moderator] Re: Securely limit the running an application by serial number

2009-07-03 Thread Scott Anguish
the discussion of software protection is off-limits for this list.  
take to to the mac small business list.


[moderator]

On 2009-07-03, at 6:48 PM, Peter Mulholland wrote:

I want my application to run on specific computers that are  
licensed to use
the software. This is for limited use, and isn't a product for the  
masses.
I've realized that you can limit the software to run on specific  
computers
by limiting using the serial number of the machine. how secure is  
it? can
someone crack the software by avoiding the "if statement" that does  
the

check? How can I secure my checks.


First thing - Apple and their devout followers will tell you "don't  
do that" when it comes to ANY protection. Ironic since as they have  
DSMOS and PT_DENY_ATTACH on iTunes etc.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Changing content of object inside NSMutableArray

2009-07-03 Thread Ken Thomases

On Jul 2, 2009, at 5:36 PM, Agha Khan wrote:

I have saved some objects inside GameArray (type NSMutableArray) and  
I would like to change of content of an object inside that array.


GameObj is type of UIView so it has a frame.

GameObj* p = [GameArray objectAtIndex:0];
p.frame = frame;

This works, but this is not changing the content inside the GameArray.


What do you mean it "is not changing the content inside the  
GameArray"?  By what means are you detecting this?


It is most definitely the case that the above code snippet is changing  
the frame of the object at index 0 of the array.  An array contains  
references to objects.  It doesn't really contain the objects  
themselves.  So, the pointer 'p' in your snippet is a reference to the  
same object that the array has a reference to.  There's no way for the  
change you make through 'p' to not affect the object referred to by  
the array, since they are the same object.


If you think it is not changing the object in the array, then you are  
confused or mistaken.


Regards,
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: Send files from iphone

2009-07-03 Thread Development
I also tried this and it fails. The form never gets any post variables  
or files:


	[self sendText:@"Content-Type: multipart/form-data; boundry=@@##$$- 
rew-**&&^%^\n"];

[self sendText:boundry];
	[self sendText:[NSString stringWithFormat:@"Content-Length: %i\n 
\n",totalSize]];
	[self sendText:[NSString stringWithFormat:@"Content-Disposition: form- 
data; name=\"%...@\"\r\n\r\n",@"fileName"]];

[self sendText:[NSString stringWithFormat:@"%@",name]];
[self sendText:boundry];
	[self sendText:[NSString stringWithFormat:@"Content-Disposition: form- 
data; name=\"%...@\"\r\n\r\n",@"directory"]];

[self sendText:[NSString stringWithFormat:@"%@",dir]];
[self sendText:boundry];
	[self sendText:[NSString stringWithFormat:@"Content-Disposition: form- 
data; name=\"imagefile\" filename=\"%...@\"\r\n",name]];

[self sendText:@"Content-Type: application/octet-stream\r\n\r\n"];
[self sendData:imageData];
[self sendText:boundry];

On Jul 3, 2009, at 8:00 PM, Luke Hiesterman wrote:


Check out documentation on NSURLRequest and NSURLConnection.

Luke

Sent from my iPhone.

On Jul 3, 2009, at 7:20 PM, Development  
 wrote:


I need to be able to upload the data from a UIImage to a server via  
http POST however I simply cannot find a good example of how to  
arrange the headers or how to make this post.
The only data I need to send to the server is the file's name, the  
user's name and the data itself and I simply cannot seem to get it  
to work. Can any of you offer a helping hand?

___

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

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

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

This email sent to luket...@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: NSString stringWithFormat: and strings

2009-07-03 Thread Andy Lee

On Jul 3, 2009, at 11:20 PM, KK wrote:

Hello,
I have a NSString (from a property list file) that has the %@  
formats in

it... So.. I do something like this:

NSString *stringFromPlistFile;
NSString *newString = [NSString stringWithFormat:stringFromPlistFile,
@"Hello"];

But that doesn't work...


What do you mean "doesn't work"?  What *happens*?

Are you sure you're loading the plist file correctly?  Are you sure  
you're extracting stringFromPlistFile correctly from the plist (in  
particular, is it nil)?


--Andy

___

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

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


NSString stringWithFormat: and strings

2009-07-03 Thread KK
Hello,
I have a NSString (from a property list file) that has the %@ formats in
it... So.. I do something like this:

NSString *stringFromPlistFile;
NSString *newString = [NSString stringWithFormat:stringFromPlistFile,
@"Hello"];

But that doesn't work...

Keita
___

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

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

2009-07-03 Thread Development
I have been trying to write my headers for multipart form data. I'm  
then sending the data over a NSStream. If it would be easier however  
to compact this somehow into a url request that would work fine too. I  
just need to figure out how to get the file to the server.


On Jul 3, 2009, at 7:31 PM, Kyle Sluder wrote:


What have you tried? Or at least looked at trying?


___

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

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

2009-07-03 Thread Luke Hiesterman

Check out documentation on NSURLRequest and NSURLConnection.

Luke

Sent from my iPhone.

On Jul 3, 2009, at 7:20 PM, Development   
wrote:


I need to be able to upload the data from a UIImage to a server via  
http POST however I simply cannot find a good example of how to  
arrange the headers or how to make this post.
The only data I need to send to the server is the file's name, the  
user's name and the data itself and I simply cannot seem to get it  
to work. Can any of you offer a helping hand?

___

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

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

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

This email sent to luket...@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: Send files from iphone

2009-07-03 Thread Kyle Sluder
What have you tried? Or at least looked at trying?
___

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

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


Send files from iphone

2009-07-03 Thread Development
I need to be able to upload the data from a UIImage to a server via  
http POST however I simply cannot find a good example of how to  
arrange the headers or how to make this post.
The only data I need to send to the server is the file's name, the  
user's name and the data itself and I simply cannot seem to get it to  
work. Can any of you offer a helping hand?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread I. Savant

On Jul 3, 2009, at 6:48 PM, Peter Mulholland wrote:

First thing - Apple and their devout followers will tell you "don't  
do that" when it comes to ANY protection. Ironic since as they have  
DSMOS and PT_DENY_ATTACH on iTunes etc.


  I call trollshit.

  There's a whole thread-worth of responses before yours that more or  
less make your very same points:




Second, to make it really effective, you have to get hardcore.

...

I'm also under no illusions - it'll be cracked ...


  In essence: it takes a lot of effort to make your scheme reasonably  
difficult to crack but it will never be crack-proof. Sounds like 90%  
of the responses on this list across all similar threads to me.



Simply saying "why bother they will crack it anyway" gets your stuff  
spread on day 0, instead of a few weeks or a month later


  Your quote is not the same as "don't do it". It only highlights  
that some people don't view it as "worth it" at all. Many on this list  
are business owners or represent a business and are interested in  
protecting their work - present company included. The majority merely  
warn that:


1 - Increasing investments of effort to protect your code has  
diminishing returns.

2 - Nothing is 100% crack-proof.
3 - It's unlikely (though not impossible*) you're smarter than the  
smartest, so it's pretty likely that your best efforts will still be  
cracked.
4 - Any Objective-C-based protection mechanism is trivial to crack  
because it's practically self-documenting and easily modified by (the  
language's) design.
5 - There are a number of resources outlining the weaknesses of an  
Objective-C application in this regard as well as many approaches for  
increasing security (ie, making it very difficult for casual crackers  
to crack).




Of course, I have ways and means, but I won't give away my secrets ;)



  The funny thing about point #5 above is that, in this thread alone,  
there were some direct links to specific and relevant information.


--
I.S.


* ... then again, if you were smarter than the smartest, you wouldn't  
need to ask how to do this, so we can safely assume you're probably  
somewhere near the mean. If you *are* among the smartest and asking  
this question, you're just weird.



___

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

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


Font matching

2009-07-03 Thread Gideon King
Hi, I have an application where I need to be able to find the closest  
equivalent font should a font be missing. e.g. someone creates a file  
and sends it to someone else, who doesn't have the font that was used  
to create the original file installed on their system.


I thought that maybe saving the NSFontDescriptor in the file should be  
able to allow me to find the best font using the  
matchingFontDescriptorsWithMandatoryKeys method passing nil as the  
mandatory keys, but I have no idea what it would do if the font was  
either there or missing:
- if the font was there, would it return just one font descriptor, or  
potentially multiple?
- if it was able to be exactly matched, is there some way of knowing  
this (e.g. is isEqual: implemented on NSFontDescriptor?)
- if the font is not there, will it continue to fall back until it  
finds a suitable font? If so, will it return only one item in the  
array? What does it try to match in the algorithm?
- if it does return multiple descriptors, are they ordered so that I  
know which one is considered the best match?
- if I pass in nil as the mandatory keys, will it *always* return at  
least one descriptor?


Now sometimes my file is edited by someone using windoze, and the font  
name doesn't exactly match what you see on the Mac even though it is  
essentially the same font and usually the name of one is a substring  
of the other. Is there an elegant way to handle this?


Thanks

Gideon
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread Peter Mulholland
Hello Ammar,

Friday, July 3, 2009, 8:49:32 PM, you wrote:

> I want my application to run on specific computers that are licensed to use
> the software. This is for limited use, and isn't a product for the masses.
> I've realized that you can limit the software to run on specific computers
> by limiting using the serial number of the machine. how secure is it? can
> someone crack the software by avoiding the "if statement" that does the
> check? How can I secure my checks.

First thing - Apple and their devout followers will tell you "don't do that" 
when it comes to ANY protection. Ironic since as they have DSMOS and 
PT_DENY_ATTACH on iTunes etc.

Second, to make it really effective, you have to get hardcore. I've just 
written a system for the company I work for that actually encrypts the whole 
executable, and only decrypts it at run time with the right licence file (keyed 
to the user's system serial) in place. This meant writing a "stub" program and 
a tool to parse a Mach-O and encrypt it suitably. Expect to have to get 
friendly with BSD API's, syscalls, and assembly language.

You have a lot of ground to cover to make any checks etc hidden. IOKit is the 
only way to get the system serial, and it's easy to spot in the Mach-o load 
commands and symbol table - as soon as a cracker spots it, they can say "aha", 
and at best, forge the answer to a known good system serial. Opening it 
dynamically with dlopen() and looking up symbols helps - especially if you 
rot13 or xor the symbol name strings.

If you go my route, you've also got to think about other things, such as 
process dumping. Once the code's decrypted you can easily do something like 
enable coredumps, then send a SIGABRT and grab the decrypted app (Mach-O header 
and all) out of the core dump. You then two routes 1) thwart the dumping 2) 
make it so that the app can detect if it was dumped, and break.

Of course, I have ways and means, but I won't give away my secrets ;) I'm also 
under no illusions - it'll be cracked, but you have to try and protect your 
stuff. Simply saying "why bother they will crack it anyway" gets your stuff 
spread on day 0, instead of a few weeks or a month later


-- 
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: Animation Did Stop - Works For OS3 but not OS2.2

2009-07-03 Thread Dave DeLong

Hi Chunk,

You're missing the third parameter of the selector (the context  
parameter).  Also, I believe that OS 2.2 didn't send parameters along  
in the animation selectors.  The selector you're providing  
(animationHasFinished:finished:) will need at least two (the docs for  
3.0 say you need 3), but IIRC, OS 2.2 needs the selector to be more  
like: @selector(animationDidStop).


HTH,

Dave

On Jul 2, 2009, at 10:25 PM, Chunk 1978 wrote:


this works fine in OS 3, but it doesn't call fade out in OS2.2?  what
is the problem?

- (void)animationHasFinished:(NSString *)animationID finished:(BOOL) 
finished

{
if ((animationID == @"FadeIn") && finished)
{
[self fadeOut];
}
}

- (void)fadeIn
{
[UIView beginAnimations:@"FadeIn" context:NULL];
[UIView setAnimationDelegate:self];
	[UIView setAnimationDidStopSelector:@selector 
(animationHasFinished:finished:)];

[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.05];
[self.flashView setAlpha:1.0];
[UIView commitAnimations];
}

- (void)fadeOut
{
[UIView beginAnimations:@"FadeOut" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.45];
[self.flashView setAlpha:0.0];
[UIView commitAnimations];
}
___

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

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

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

This email sent to davedel...@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: How do I get the version of AppKit.framework available in Cocoa Application Framework 10.5? Probably a dumb question I know..

2009-07-03 Thread Dave DeLong

Hi Max,

First off, AppKit is distributed with the system.  It may or may not  
get updated during an OS update (such as the rumored 10.5.8 update),  
but that's it.  You can't download a different version.


As for the initWithCIImage: method, the page you linked to is  
describing the API changes between 10.4 and 10.5.  If you're running  
10.5, you should have that initializer available to you.  If you  
don't, what error are you getting when trying to compile?


Finally, if you need to have this work at runtime, and you want to  
maintain Tiger (10.4) compatibility, there's been a long discussion  
recently on how to determine the OS version at runtime:  http://www.cocoabuilder.com/archive/message/cocoa/2009/7/2/240095


HTH,

Dave

On Jul 3, 2009, at 2:41 AM, maxwellma...@gmail.com wrote:


Hi Folks,
sorry I know this is probably a dumb question. I'm new to Mac OS X
development being a jaded Java bod coming over to the light. Very nice
it is too.

My problem is I need to call this method that seems to be in a later
version of the AppKit.framework than is on my machine.

The method is "initWithCIImage" as follows:

 NSBitmapImageRep *bitmapImage = [NSBitmapImageRep  
initWithCIImage:image];



From what I can find, "initWithCIImage" is included in the 10.5

release of Cocoa...

http://developer.apple.com/releasenotes/Cocoa/AppKit.html#//apple_ref/doc/uid/TP3741

In Xcode, the AppKit headers show the method, but if I examine
/System/Library/Frameworks/AppKit.framework, it looks like an old
version (see below).

I've tried googling all the obvious stuff but I just can't find where
to download an updated AppKit.framework. Is it only available to ADC
paid subscribers?

I'm running Xcode 3.1.3, and OS X 10.5.7

Any advice would be much appreciated.

Thanks,
Max



nm AppKit | more

0019ab9f t +[NSBitmapImageRep TIFFRepresentationOfImageRepsInArray:]
003f2762 t +[NSBitmapImageRep
TIFFRepresentationOfImageRepsInArray:usingCompression:factor:]
0015bfd0 t +[NSBitmapImageRep  
_imageRepWithData:hfsFileType:extension:]

0012ba68 t +[NSBitmapImageRep
_imageRepsWithData:hfsFileType:extension:expandImageContentNow:]
003f2905 t +[NSBitmapImageRep _imagesFromIcon:inApp:zone:]
003f29ca t +[NSBitmapImageRep  
_imagesFromURL:forImage:fileType:extension:]

003f28ae t +[NSBitmapImageRep
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:]
0012bafc t +[NSBitmapImageRep
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:includeAllReps 
:]

0012fafa t +[NSBitmapImageRep canInitWithData:]
003f2166 t +[NSBitmapImageRep getTIFFCompressionTypes:count:]
002ed4b6 t +[NSBitmapImageRep imageRepWithData:]
0012fb8c t +[NSBitmapImageRep imageRepsWithData:]
00117837 t +[NSBitmapImageRep imageUnfilteredFileTypes]
0004fb26 t +[NSBitmapImageRep imageUnfilteredPasteboardTypes]
003f51e8 t +[NSBitmapImageRep imageUnfilteredTypes]
5adc t +[NSBitmapImageRep initialize]
003f2185 t +[NSBitmapImageRep localizedNameForTIFFCompressionType:]
0019abdf t +[NSBitmapImageRep(NSBitmapImageFileTypeExtensions)
representationOfImageRepsInArray:usingType:properties:]
004893e0 t +[NSBitmapImageRep(NSDragManagerFix)  
_setEnableFlippedImageFix:]

___

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

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

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

This email sent to davedel...@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


Core Data, migrate a model split into two files

2009-07-03 Thread Dan Waltin

Hi,

I have a Core Data application, with the model split into  
two .xcdatamodel files, inspired by Chris Hanson at http://chanson.livejournal.com/187540.html 
. The application is only supported on 10.5.


The application is usd to track patient records and the to xcdatamodel  
files are called "MetaData" and "PatientData".
In the MetaData model meta data about information collected about  
patients is stored, and in the PatientData model
the actual patient data is stored. During startup these model files  
are merged into one NSManagedObjectModel

instance, as described by Chris Hanson.

Now, I want to update the model and hence migrate the application data.

I'm familiar with how to migrate a model in the more "normal" case  
where you only have one xcmodeldata file.


Adding a new version to e.g. the PatientData.xcdatamodel file and  
doing the necessary changes to the model
is of course easy, but then what? Do I create a regular mapping model,  
or do I have to do the migration
manually? Or do I have to go back to having the model in only one  
xcdatamodel file?


Is there anyone who have done this, or have any idea on how to proceed?

Kind regards
Dan Waltin
___

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

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


Animation Did Stop - Works For OS3 but not OS2.2

2009-07-03 Thread Chunk 1978
this works fine in OS 3, but it doesn't call fade out in OS2.2?  what
is the problem?

- (void)animationHasFinished:(NSString *)animationID finished:(BOOL)finished
{
if ((animationID == @"FadeIn") && finished)
{
[self fadeOut];
}
}

- (void)fadeIn
{
[UIView beginAnimations:@"FadeIn" context:NULL];
[UIView setAnimationDelegate:self];
[UIView 
setAnimationDidStopSelector:@selector(animationHasFinished:finished:)];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.05];
[self.flashView setAlpha:1.0];
[UIView commitAnimations];
}

- (void)fadeOut
{
[UIView beginAnimations:@"FadeOut" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.45];
[self.flashView setAlpha:0.0];
[UIView commitAnimations];
}
___

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

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


How do I get the version of AppKit.framework available in Cocoa Application Framework 10.5? Probably a dumb question I know..

2009-07-03 Thread maxwellmac99
Hi Folks,
sorry I know this is probably a dumb question. I'm new to Mac OS X
development being a jaded Java bod coming over to the light. Very nice
it is too.

My problem is I need to call this method that seems to be in a later
version of the AppKit.framework than is on my machine.

The method is "initWithCIImage" as follows:

  NSBitmapImageRep *bitmapImage = [NSBitmapImageRep initWithCIImage:image];

>From what I can find, "initWithCIImage" is included in the 10.5
release of Cocoa...

 
http://developer.apple.com/releasenotes/Cocoa/AppKit.html#//apple_ref/doc/uid/TP3741

In Xcode, the AppKit headers show the method, but if I examine
/System/Library/Frameworks/AppKit.framework, it looks like an old
version (see below).

I've tried googling all the obvious stuff but I just can't find where
to download an updated AppKit.framework. Is it only available to ADC
paid subscribers?

I'm running Xcode 3.1.3, and OS X 10.5.7

Any advice would be much appreciated.

Thanks,
Max



nm AppKit | more

0019ab9f t +[NSBitmapImageRep TIFFRepresentationOfImageRepsInArray:]
003f2762 t +[NSBitmapImageRep
TIFFRepresentationOfImageRepsInArray:usingCompression:factor:]
0015bfd0 t +[NSBitmapImageRep _imageRepWithData:hfsFileType:extension:]
0012ba68 t +[NSBitmapImageRep
_imageRepsWithData:hfsFileType:extension:expandImageContentNow:]
003f2905 t +[NSBitmapImageRep _imagesFromIcon:inApp:zone:]
003f29ca t +[NSBitmapImageRep _imagesFromURL:forImage:fileType:extension:]
003f28ae t +[NSBitmapImageRep
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:]
0012bafc t +[NSBitmapImageRep
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:includeAllReps:]
0012fafa t +[NSBitmapImageRep canInitWithData:]
003f2166 t +[NSBitmapImageRep getTIFFCompressionTypes:count:]
002ed4b6 t +[NSBitmapImageRep imageRepWithData:]
0012fb8c t +[NSBitmapImageRep imageRepsWithData:]
00117837 t +[NSBitmapImageRep imageUnfilteredFileTypes]
0004fb26 t +[NSBitmapImageRep imageUnfilteredPasteboardTypes]
003f51e8 t +[NSBitmapImageRep imageUnfilteredTypes]
5adc t +[NSBitmapImageRep initialize]
003f2185 t +[NSBitmapImageRep localizedNameForTIFFCompressionType:]
0019abdf t +[NSBitmapImageRep(NSBitmapImageFileTypeExtensions)
representationOfImageRepsInArray:usingType:properties:]
004893e0 t +[NSBitmapImageRep(NSDragManagerFix) _setEnableFlippedImageFix:]
___

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

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


Long term performance of NSConnection

2009-07-03 Thread Kevin Brock
We've got an application that uses some NSConnection objects to call 
between binaries.  An application calls interfaces of an object which is 
vended by a daemon.


The calls between modules are made frequently, and during some testing I 
noticed a steady drop in perfomance of the application.  I ran Shark, 
and saw that after a lot (> 1,000,000) calls across the API more than 
95% of the time was being spent in 5 calls, all of which look like 
they're related to distributed objects:


lookUpConnectionForProxy
30.5%
lookUpLocalProxyForWireID
26.5%
lookUpLocalObjectForProxy
22.8
lookUpOrCreateLocalProxyForObject
8.2%
lookUpWireIDForProxy
7.6%


I can't find any references to these functions on the net, and don't see 
anything in the docs that would explain this.


We use a long term, persistent connection.  The degradation starts very 
soon. 


Call
Startup
~10,000 calls
~20,000 Calls
lookUpConnectionForProxy0.4%
4.2%
14.6%
lookUpLocalProxyForWireID   0.8%
12.4%
15.7%
lookUpLocalObjectForProxy   0.3%
2.8%
8.8%
lookUpOrCreateLocalProxyForObject   0.5%
3.3%
4.8%
lookUpWireIDForProxy0.1%
0.7%
3.3%



Is there something we are missing about the usage of the connection 
object?  It looks like there's some table internal to the connection 
that's not being cleaned up.  When I graph the actual perormance hit 
taken by the application (secs/1000 connections) it's essentially linear 
increase in time from 0 to 500,000 connections.


When I run Shark on the daemon side for the > 1,000,000 call case it 
shows three calls consuming >97% of the time


Call
Time
lookUpConnectionForProxy58%
lookUpWireIDForProxy28.9%
lookUpOrCreateLocalProxyForObject   11.2%


I'd really appreciate any suggestions about why this might be happening.

Kevin Brock
ap...@kevin.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: in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread colo
> This one uses OpenGL:
> 
>
> You could use a similar technique to create CGPaths to represent the
> strokes, but performance with OpenGL is considerably better.
>
> mmalc


Oh awesome! Thank you. This is a perfect start that I was after.
___

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

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


Sorting an editable tableView of managed object

2009-07-03 Thread Steve Cronin

Folks;

I have a simple one column tableView of a managed object.
The text field in the table view is editable.
I want to keep the table sorted when the user manually changes a value,

I have registered for the notification:
	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(myRefreshManagedObjects:)  
name:NSManagedObjectContextObjectsDidChangeNotification object:[self  
managedObjectContext]];


This notification is called at appropriate times.
I iterate over the updated  set NSUpdatedObjectsKey checking for the  
entity.
If I find a match I determine what tableView is to be updated and call  
a method which does the following;


- (void) sortManagedTable:(NSTableView *)tableView; {
//array controllers use 'prepare content' and a fetch predicate
	//there is NO binding to a sortDesctiptor - the tableView handles the  
header clicks correctly without one
	NSSortDescriptor *titleDescriptor = [[tableView  
tableColumnWithIdentifier:@"titleValue"] sortDescriptorPrototype];
	NSMutableArray *newSortDescriptors = [NSMutableArray arrayWithArray: 
[tableView sortDescriptors]];

[newSortDescriptors removeObject:titleDescriptor];
[newSortDescriptors insertObject:titleDescriptor atIndex:0];
[tableView setSortDescriptors:newSortDescriptors];  
	[tableView scrollRowToVisible:[[tableView selectedRowIndexes]  
firstIndex]];

[tableView setNeedsDisplay];
}

But the tableView does not update to reflect the new ordering.
What am I missing?
Steve


___

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

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

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

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


Re: in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread mmalc Crawford


On Jul 3, 2009, at 2:15 PM, colo wrote:


I am seeking a bare bones beginner source or tutorial for building
painting apps on the iphone.


This one uses OpenGL:



You could use a similar technique to create CGPaths to represent the  
strokes, but performance with OpenGL is considerably better.


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: Design for custom tableviewcell button action

2009-07-03 Thread mmalc Crawford


On Jul 3, 2009, at 2:45 PM, Brian Slick wrote:

So now I either need to figure out how to make my scenarios all work  
with a single identifier, or I may just go ahead with the code-only  
cell I just built in response to the performance issue.  If would be  
nice if there was some kind of queueWithReuseIdentifier: method for  
these XIB cases.



Oh, you can have as many identifiers as you want.
For a nib-based approach, simply have as many nib files as you want --  
where each nib file has a single cell but a different identifier --  
and you probably(*) have an outlet for each type.



// Caveat: Typed in Mail
- (UITableViewCell *)tableView:(UITableView *)tableView  
cellForRowAtIndexPath:(NSIndexPath *)indexPath {


if (condition1) {
static NSString *CellType1Identifier = @"CellType1Identifier";

		CellType1 *cell = (CellType1 *)[tableView  
dequeueReusableCellWithIdentifier:CellType1Identifier];

if (cell == nil) {
			[[NSBundle mainBundle] loadNibNamed:@"CellType1" owner:self  
options:nil];

cell = cellType1;
self. cellType1 = nil;
// configure cell ...
return cell;
}

if (condition2) {
static NSString *CellType12dentifier = @"CellType12dentifier";

		CellType1 *cell = (CellType1 *)[tableView  
dequeueReusableCellWithIdentifier:CellType2Identifier];

if (cell == nil) {
			[[NSBundle mainBundle] loadNibNamed:@"CellType2" owner:self  
options:nil];

cell = cellType2;
self. cellType2 = nil;
// configure cell ...
return cell;
}

// ...


(*) You wouldn't actually *need* a different outlet for each type,  
since the outlet is used only very briefly for each load, and each  
load happens sequentially, but you may prefer to identify each type  
nevertheless.



Incidentally, that's what is wrong with TaggedLocations... it also  
does not have the identifier in the XIB.  I manually added it, then  
retested, and saw dramatically better performance (for my own  
program, too).

[...]
All this aside, please file a performance bug against the  
TaggedLocations sample.
Done, although I'm not sure if I did so correctly.  Thank you for  
your help.




Ah, thanks.
If you could send the bug number, that would be useful.

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: in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread colo
Thank you all. I however am not a beginner at the programing side of
things now.

I was more looking for some type of possible common article or reading
material that is on the web from others that have tinkered with
painting apps for iphone in particular. Since there seem to be so many
in the store. I had to figure that there was some common thread that
was being utilized for these developers as a starter kit of sorts.

That's why I don't have a particular question of said feature, nor am
I asking for free work. Just checking to see if theres might be
something popular that I may have missed.

As example. I know that iphone sdk does not support Core Image yet. Of
which I would assume that a normal desktop app would use to draw with.
So another avenue must be taken in iphone for now. I might be wrong.

Just checking.
___

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

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


Negative values in KVC's @sum?

2009-07-03 Thread marc hoffman

Hi,

i'm wondering if i am missing something, but is KVC's @sum operator  
supposed to handle negative values? i'm using it to calculate the sum  
(duh) of NSDecimalNumber in a custom class. all is going fine, but as  
soon as i have a negative value, i get a huge negative number as result.


for example, the following two lines on sample data illustrate the odd  
result. note how the array shows a range of numbers in a "reasonable"  
range, but the sum is completely out of whack. in all my test cases  
without negative numbers, the sum is fine.



NSLog(@"%f", [[rows valueForKeyPath:@"@sum.FooField"] floatValue]);
NSLog(@"%@", [rows valueForKeyPath:@"@sum.FooField"]);
NSLog(@"%@", [rows valueForKeyPath:@"FooField"]);

2009-07-03 23:48:21.881 FooApp[16072:a0f]  
-7922816051279260559605760.00
2009-07-03 23:48:21.881 FooApp[16072:a0f]  
-7922816251426433759342309.0336

2009-07-03 23:48:21.881 FooApp[16072:a0f] (
899.,
899.,
2598.,
799.,
-899.,
899.,
599.,
599.,
699.,
1798.,
699.,
599.,
999.,
899.
)

what could i possibly be missing? any thoughts would be appreciated.

yours,
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


Re: Securely limit the running an application by serial number

2009-07-03 Thread Kyle Sluder
On Fri, Jul 3, 2009 at 1:33 PM, Michael Ash wrote:
> In addition to what the others have said, you should think seriously
> about how useful obfuscation will be.

There might be an argument here about protecting trade secrets.  If
you don't defend them, they lose their protected status.

The biggest threat to Ammar's product seems to be an insider attack.
"What You Know" security is not going to be useful here, since
everyone will have shared access to roughly equivalent knowledge.
"Who You Are" level security is going to be tough to implement in this
situation.  That leaves us with "What You Have."

The best solution might be to have a server process running on a box
outside of the user's control, and have the client machines depend on
certain functionality provided by the server.  You can generate a key
for each client, stick it on the client's keychain, and use that to
authenticate any messages transferred between the client and server.
This gives you the opportunity to revoke a rogue client's key, which
will cripple the client since it depends on the server for
functionality.

I only recommend this approach if you are providing this software on a
licensed, contractual basis.  From my ethical perspective, customers
of buyout software should not be subject to such treatment.

--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: Design for custom tableviewcell button action

2009-07-03 Thread Brian Slick


On Jul 3, 2009, at 4:39 PM, mmalc Crawford wrote:


On Jul 3, 2009, at 11:54 AM, Brian Slick wrote:

I did make a slight adjustment to the technique - most  
significantly the omitting of the identifier in the XIB file,


This is actually a very significant factor.
If you haven't set an identifier, it's not clear how you're  
retrieving cached cells in tableView:cellForRowAtIndexPath:?


I assume you have a test along the lines of:

   UITableViewCell *cell = [tableView  
dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell == nil) {
   cell = ...

Could you check whether you're creating a new cell each time?


That's impressive; good call.  It was indeed creating a new cell each  
time.  And now that I take a second look at the code, I'm pretty sure  
I see why.  The XIB-loading command itself doesn't actually have the  
identifier as a parameter, and is thus totally dependent on that info  
being in the XIB.  Therefore, the cell never gets queued.  My initial  
thought was that omitting it would make it generic, but I now see the  
flaw in that thinking.  Simply declaring the identifier doesn't make  
it get used anywhere.  :p


Incidentally, that's what is wrong with TaggedLocations... it also  
does not have the identifier in the XIB.  I manually added it, then  
retested, and saw dramatically better performance (for my own program,  
too).


So now I either need to figure out how to make my scenarios all work  
with a single identifier, or I may just go ahead with the code-only  
cell I just built in response to the performance issue.  If would be  
nice if there was some kind of queueWithReuseIdentifier: method for  
these XIB cases.  (This is what I'm trying to do:  http://bit.ly/l55eH )


All this aside, please file a performance bug against the  
TaggedLocations sample.


Done, although I'm not sure if I did so correctly.  Thank you for your  
help.


Brian

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread I. Savant

On Jul 3, 2009, at 5:15 PM, colo wrote:


I am seeking a bare bones beginner source or tutorial for building
painting apps on the iphone.


  A "bare bones beginner" source or tutorial is simply not possible  
for an application of this nature. I'm unfamiliar with the iPhone  
example code offerings but I know that the Sketch example for the Mac  
environment will give you what you need to create a drawing  
application, but it is by no means "bare bones" or "beginner", nor can  
it possibly be. Even the TextEdit example is too complex a problem  
(encodings, doc types, pagination, and many other things).


  What you need, if you're a complete Cocoa beginner, is to spend the  
time with the introductory material from Apple, a good book, and time.


  If you're already familiar with Cocoa apps and you're actually only  
asking for painting-related stuff, then the Sketch example code is  
where it's at.



So, I must make my own. :D


  ... or you could try picking your favorite one and submitting a  
feature request to the developer. Few complete applications are so  
easy it's worth writing your own just to add one feature.


--
I.S.





___

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

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

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

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


Re: in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread WT

On Jul 3, 2009, at 11:15 PM, colo wrote:


I am seeking a bare bones beginner source or tutorial for building
painting apps on the iphone.
Of all the apps I tested. None have a paint bucket tool that only
fills in a section of color. They all fill the screen.
So, I must make my own. :D



Having the right algorithm is half the work.
As always, google is your friend...


"Paint bucket" algorithm?
http://discuss.joelonsoftware.com/default.asp?joel.3.18248.3


How does the fill operation work in paint applications?
http://stackoverflow.com/questions/274213/how-does-the-fill-operation-work-in-paint-applications


Flood fill
http://en.wikipedia.org/wiki/Flood_fill


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


in search of a starter iphone painting tutorial or sample code

2009-07-03 Thread colo
I am seeking a bare bones beginner source or tutorial for building
painting apps on the iphone.
Of all the apps I tested. None have a paint bucket tool that only
fills in a section of color. They all fill the screen.
So, I must make my own. :D
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Optimizing writes of big files for specific hardware?

2009-07-03 Thread Jay Reynolds Freeman

On Jul 3, 2009, at 1:20 PM, Greg Guerin wrote:

> [useful comments excised, thank you very much]

I will try lseek and write at the end.

> Exactly what problem is solved by initially writing multiple
> gigabytes of zeros to disk?

As for what I am doing, I have a parallel Scheme system (Wraith
Scheme, see the "Software" page of my web site, URL in the .sig),
and I use mmap to obtain a shared Scheme main memory.  By
"parallel", I mean separate Unix processes, not threads.  I am
setting things up so that a user who wishes to do so can choose
a memory size large enough to drag the application to a screeching
halt from swapping, and the way to do that seems to be for one
process to create a file of the desired size, then have that
process and all the others mmap it.  I am not saying that it is
wise to choose such a large Scheme main memory, but some users
may want to do it.

If there is a better way, I would love to hear about it; I am
by no means an mmap wizard.

--  Jay Reynolds Freeman
-
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread Todd Heberlein

This is for limited use, and isn't a product for the masses.


There has already been some pretty good stuff posted, but just keep in  
mind that once you've released your code, if someone is really  
interested in modifying your code, they probably will. I doubt there  
will ever be a 100% guaranteed solution.


The military has been investigating elements of this for a few years  
with respect to unmanned combat vehicles (they know they are going to  
be captured by their enemy, so for a variety of reasons they want to  
protect the code), so you may want to look around at DARPA and DARPA  
contractors to see what unclassified papers have been published.


Todd

___

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

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

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

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


Re: Design for custom tableviewcell button action

2009-07-03 Thread mmalc Crawford


On Jul 3, 2009, at 11:54 AM, Brian Slick wrote:

So, if TaggedLocations was flying while mine was sucking, I'd  
probably concede that what I was doing was wrong (and would probably  
need more custom cells).  But since neither one is performing very  
well, and I can't find any significant differences between them, I'm  
thinking there is either a flaw with this approach, or my trusty 1st- 
gen just isn't bringing enough horsepower to handle it.


The only time you should see a performance hit with this approach is  
when the cells are first loaded; once they're loaded (and cached),  
performance should be identical whether you code the cell  
programmatically or use a nib file.  *Without looking at any  
performance metrics* (I don't have a device to hand), I'd *guess* the  
issue is likely to be with transparency.  Try switching off  
transparency wherever you can find it and see if that helps.
If you can exactly recreate your hand-coded cell in IB, it would be  
interesting to see what the performance comparison is like.


I did make a slight adjustment to the technique - most significantly  
the omitting of the identifier in the XIB file,




This is actually a very significant factor.
If you haven't set an identifier, it's not clear how you're retrieving  
cached cells in tableView:cellForRowAtIndexPath:?


I assume you have a test along the lines of:

UITableViewCell *cell = [tableView  
dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
cell = ...

Could you check whether you're creating a new cell each time?


All this aside, please file a performance bug against the  
TaggedLocations sample.


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: Securely limit the running an application by serial number

2009-07-03 Thread Michael Ash
On Fri, Jul 3, 2009 at 4:11 PM, Ammar Ibrahim wrote:
> I'm writing a 64-bit only app. Any pointers on where I can find info on
> obfuscation?

In addition to what the others have said, you should think seriously
about how useful obfuscation will be.

First, realize that you have a virtually insurmountable gulf in
expertise between you and the guy cracking your app. He's probably
been doing it since before puberty, and by now has utterly destroyed
systems of greater sophistication than you or I could ever think of.

Then, think of the value of your time. Your time is probably pretty
expensive. His time is probably free. Indeed, he probably thinks
cracking apps is fun, so in a sense his time has a negative cost.

Furthermore, than huge gulf in expertise means that each additional
hour you spend securing your app will cause this cracker (who thinks
this is all fun anyway) to spend much less than one additional hour
breaking it.

There can be some benefits to doing quick, moderate obfuscations, but
it's probably not worth putting significant effort into it.

Mike
___

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

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

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

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


Re: Securely limit the running an application by serial number

2009-07-03 Thread Jim Thomason
>> I'm writing a 64-bit only app. Any pointers on where I can find info on
>> obfuscation?
>
>
> 

In addition to that, don't even think about doing your checks in
objective-C. It's just too easy to hack around, and if somebody's
dedicated to cracking you, it's an easy entry point.

So do it all in C. It's much tougher to crack into.

Once you've written it all in C, then convert it all to a C macro
instead. That makes it excruciatingly difficult to find it. And, at
that point, there is no if statement to crack - the macro duplicates
the code all over the app, so even if somebody hacked into the
assembly and switched it in one place, you've still got unaltered
checks all over the rest of the place.

Raw C executes pretty fast, so you can pepper your app with it. In
completely unrelated methods, even, just to spread out the checks
everywhere.

Wanna get really hardcore? Write 3 different versions of your
validation macro and vary which one you use. That's now 3 different
blocks of assembly that the black hat is going to have to decipher,
disassemble, and hack to get inside.

Sound like too much trouble to you? Well, then security really isn't
that important anyway. :-)

Just remember - it's always an arms race, and the more time you spend
writing security functionality for your application, the less time
you're spending actually developing the stuff that the user cares
about. No end user is going to be impressed at all with your app that
so securely locks them down to a single machine and if that gives your
competition time to catch up with a better feature set, you're in big
trouble.

Oh, I also wrote up an article with my experience in doing some of
this stuff a few years ago. Doesn't specifically address tying to the
hardware, but may be useful for general pointers, too:

http://www.jimandkoka.com/m.cgi/Journal.mchn?state=display_entry&journal_entry_id=283

-Jim
___

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

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

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

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


Re: Securely limit the running an application by serial number

2009-07-03 Thread Quincey Morris

On Jul 3, 2009, at 12:49, Ammar Ibrahim wrote:

I want my application to run on specific computers that are licensed  
to use
the software. This is for limited use, and isn't a product for the  
masses.
I've realized that you can limit the software to run on specific  
computers
by limiting using the serial number of the machine. how secure is  
it? can
someone crack the software by avoiding the "if statement" that does  
the

check? How can I secure my checks.


Also see this tech note:

http://developer.apple.com/technotes/tn/tn1103.html

about trying to rely on the serial number. It talks a bit about some  
of the other issues, too.



___

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

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

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

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


Re: Optimizing writes of big files for specific hardware?

2009-07-03 Thread Greg Guerin

Jay Reynolds Freeman wrote:


I have an app whose initialization includes writing a huge file
to disk -- think GigaBytes, or even tens of GigaBytes.  I am
doing this in the context of setting up a large area of shared
memory with mmap, so the big write has to happen at
initialization, and it is agonizingly slow.



Simply seeking to a large position in a new or truncated file and  
writing will fill all intervening locations with zeros.  Unix-type  
OSes generally guarantee that intervening space is zeros.


The most optimal thing possible is to never write zeros at all, i.e.  
the fastest thing possible is the thing you don't do.  The next most  
optimal thing is to only write the exact number of zeros needed, and  
only when you need them.


I think you're doing this backwards.  You should be looking at ways  
to eliminate writing zeros, especially tens of gigabytes of them, not  
ways of making them faster.  That's because no matter what else you  
do, you will still be limited by the slowest link in the chain of OS,  
HD controller, HD, SATA, memory controller, etc.  That could be in  
the range of 20-30 MB/sec, or even worse on older machines or USB- 
connected HDs.  Do the math.


Exactly what problem is solved by initially writing multiple  
gigabytes of zeros to disk?  Yes, you've zeroed multiple gigabytes of  
a shared file on disk, but exactly why is that necessary?  What does  
it accomplish, specifically, and why is it gigabytes in size?


  -- GG

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread Nick Zitzmann


On Jul 3, 2009, at 2:11 PM, Ammar Ibrahim wrote:

I'm writing a 64-bit only app. Any pointers on where I can find info  
on obfuscation?





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


Re: Securely limit the running an application by serial number

2009-07-03 Thread Ammar Ibrahim
On Fri, Jul 3, 2009 at 11:09 PM, Nick Zitzmann  wrote:

>
> On Jul 3, 2009, at 1:49 PM, Ammar Ibrahim wrote:
>
>  can
>> someone crack the software by avoiding the "if statement" that does the
>> check?
>>
>
> Yes.
>
>  How can I secure my checks.
>>
>
>
> Obfuscate them and hope nobody finds out. It's the only way. 32-bit apps
> can be easily hacked through input managers, CM plugins, and APE. 64-bit
> apps can't be hacked by any of the above - yet.


I'm writing a 64-bit only app. Any pointers on where I can find info on
obfuscation?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread Nick Zitzmann


On Jul 3, 2009, at 1:49 PM, Ammar Ibrahim wrote:


can
someone crack the software by avoiding the "if statement" that does  
the

check?


Yes.


How can I secure my checks.



Obfuscate them and hope nobody finds out. It's the only way. 32-bit  
apps can be easily hacked through input managers, CM plugins, and APE.  
64-bit apps can't be hacked by any of the above - yet.


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


Re: Optimizing writes of big files for specific hardware?

2009-07-03 Thread Igor Mozolevsky
2009/7/3 Jay Reynolds Freeman :

> At the moment I am actually just using the C++ library "write"
> to do the writes, in a tight loop with a large buffer (50 MByte)
> full of zeros.
>
> Is there a way to optimize?

I'd memory-map the file and bzero() the space.


--
Igor
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Securely limit the running an application by serial number

2009-07-03 Thread Ammar Ibrahim
I meant "Securely limit the running *of* an application by serial number"

On Fri, Jul 3, 2009 at 10:49 PM, Ammar Ibrahim wrote:

> I want my application to run on specific computers that are licensed to use
> the software. This is for limited use, and isn't a product for the masses.
> I've realized that you can limit the software to run on specific computers
> by limiting using the serial number of the machine. how secure is it? can
> someone crack the software by avoiding the "if statement" that does the
> check? How can I secure my checks.
>
> Thanks,
> Ammar
>
___

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

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


Securely limit the running an application by serial number

2009-07-03 Thread Ammar Ibrahim
I want my application to run on specific computers that are licensed to use
the software. This is for limited use, and isn't a product for the masses.
I've realized that you can limit the software to run on specific computers
by limiting using the serial number of the machine. how secure is it? can
someone crack the software by avoiding the "if statement" that does the
check? How can I secure my checks.

Thanks,
Ammar
___

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

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


Optimizing writes of big files for specific hardware?

2009-07-03 Thread Jay Reynolds Freeman

I am not sure whether this is a Cocoa question or a Darwin one.
I will take the discussion elsewhere if need be.  Please advise.

I have an app whose initialization includes writing a huge file
to disk -- think GigaBytes, or even tens of GigaBytes.  I am
doing this in the context of setting up a large area of shared
memory with mmap, so the big write has to happen at
initialization, and it is agonizingly slow.

At the moment I am actually just using the C++ library "write"
to do the writes, in a tight loop with a large buffer (50 MByte)
full of zeros.

Is there a way to optimize?  I have enough scar tissue to know
that attempts to optimize without knowing exactly what you are
doing are often counterproductive, but in a perfect world,
appropriate techniques might involve sizing buffers correctly
in terms of disk track size, and using enough threads to make
sure the disk controller was kept busy with actual writes to
the hardware instead of waiting for the drive to spin.

The parameters for adjusting that kind of algorithm would of
course vary from computer to computer, so my app would have to
determine them at run-time.

I am loath to go down this rathole without a reasonable suspicion
that there is cheese at the bottom.  Any advice or experience
out there?  I did check the web, to no avail.

In a still more perfect world, Apple would already have provided
functionality to optimize large file writes ... but NSFileHandle's
"writeData:" offers no hint that any such thing has been done.

And FWIW, I am building using Xcode 3.1.3, and using the LLVM
GCC 4.2 compiler, to run on MacOS 10.5.

--  Jay Reynolds Freeman
-
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)

___

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

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

2009-07-03 Thread Quincey Morris

On Jul 3, 2009, at 11:23, Development wrote:

What is the suggested user interface when creating modal dialogs for  
documents that have be movable? For our application (think of it as  
a drawing program), the user sometimes NEEDS to be able to view the  
document under the modal dialog.  We can not use sheets, because  
they cover up the document window itself.  We can not do Inspectors,  
since the operations are intensely modal.  We could make the dialog  
box application modal (ie. one at any given time), but our client  
has really requested document modal, since they are often working  
with more then one document at the same time. I know how to write  
and invoke the code to make any given window modal to another, but I  
am more concerned about the user interface of this. Is there any  
suggested way to do this? Something to clue the user to what is  
going on?


Seems to me you want to do two things: lock out a document and display  
another window, and the ideal way to lock out a document is to use a  
sheet. So do these two things.


First, put up a sheet on your document window that's small (say one  
text line high, with a brief message explaining why the document is  
locked out) and has no buttons. Then display a second (non-modal)  
window as your dialog.


Closing the dialog would also end the sheet of the document window.

You might have to slightly redesign your document window if the little  
sheet would cover up something important at the top of the window.



___

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

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

2009-07-03 Thread WT

On Jul 3, 2009, at 9:01 PM, Development wrote:

You know, that is not a half bad idea. It won't work for all the  
situations (some of the dialog boxes are to big to fit in a drawer),  
but it would for several of the smaller ones.  Also, if the document  
is full screen, drawers would be an issue. I will still look for a  
better solution for larger dialogs.


Thanks

Steve


Heh, for once, one of my off-the-wall ideas actually makes sense. :)

But, you know, why not combine the drawer idea with the collapsible  
view idea? You then could fit a large dialog in a drawer, by allowing  
parts of the dialog to be collapsible/expandable in turns, almost like  
a radio button kind of behavior: when the user expands a section of  
the dialog, another collapses to keep the dialog inside the drawer.


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: Movable Document Modal Dialogs

2009-07-03 Thread Benjamin Dobson


On 3 Jul 2009, at 19:23:04, Development wrote:

This is more for the user interface experts, than the cocoa  
programming experts...


What is the suggested user interface when creating modal dialogs for  
documents that have be movable? For our application (think of it as  
a drawing program), the user sometimes NEEDS to be able to view the  
document under the modal dialog.  We can not use sheets, because  
they cover up the document window itself.  We can not do Inspectors,  
since the operations are intensely modal.  We could make the dialog  
box application modal (ie. one at any given time), but our client  
has really requested document modal, since they are often working  
with more then one document at the same time. I know how to write  
and invoke the code to make any given window modal to another, but I  
am more concerned about the user interface of this. Is there any  
suggested way to do this? Something to clue the user to what is  
going on?


Thanks,


How about a collapsible sheet? That is, a normal sheet, but at the top  
there is a disclosure triangle that hides the whole contents of the  
sheet, making it about the size of a toolbar. It might not be what you  
want, but it's an idea.

___

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

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

2009-07-03 Thread Development
You know, that is not a half bad idea. It won't work for all the  
situations (some of the dialog boxes are to big to fit in a drawer),  
but it would for several of the smaller ones.  Also, if the document  
is full screen, drawers would be an issue. I will still look for a  
better solution for larger dialogs.


Thanks

Steve

On Jul 3, 2009, at 2:43 PM, WT wrote:


On Jul 3, 2009, at 8:23 PM, Development wrote:

This is more for the user interface experts, than the cocoa  
programming experts...


What is the suggested user interface when creating modal dialogs  
for documents that have be movable? For our application (think of  
it as a drawing program), the user sometimes NEEDS to be able to  
view the document under the modal dialog.  We can not use sheets,  
because they cover up the document window itself.  We can not do  
Inspectors, since the operations are intensely modal.  We could  
make the dialog box application modal (ie. one at any given time),  
but our client has really requested document modal, since they are  
often working with more then one document at the same time. I know  
how to write and invoke the code to make any given window modal to  
another, but I am more concerned about the user interface of this.  
Is there any suggested way to do this? Something to clue the user  
to what is going on?


Thanks,

Steve


This may be a really dumb idea, since I'm not a very experienced  
Cocoa developer, but can a drawer be document-modal?


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: Design for custom tableviewcell button action

2009-07-03 Thread Brian Slick
Well, at first I really liked this technique, and it seems simple  
enough.  I restructured my program to use it, and in the simulator all  
went well.  Then I uploaded to the phone (1st-gen) and saw absolutely  
horrid scrolling performance.  I fired up the CA tool, and saw numbers  
that were well under 10 FPS, usually around 4.


I did make a slight adjustment to the technique - most significantly  
the omitting of the identifier in the XIB file, because I have a few  
different display options that hide various aspects of my cell -  
because I wasn't getting the flexibility I wanted.  In order to  
determine if my changes were causing a problem, I built the  
TaggedLocations example, and also ran it on the phone with the CA  
tool.  Similar numbers, similarly horrid scrolling performance.   
Rebooting the phone didn't seem to make a difference for either program.


I flipped on the "Color Blended Layers" toggle for both programs, to  
see if there were any key differences.  My UIButton image has a  
transparent background, so that lit up, but that has been the case all  
along, and I had decent scrolling performance before.  The primary  
event name label in the TaggedLocations example lit up.  1 field in  
each case, although in terms of number of pixels the TaggedLocations  
program is even worse than mine.


So, if TaggedLocations was flying while mine was sucking, I'd probably  
concede that what I was doing was wrong (and would probably need more  
custom cells).  But since neither one is performing very well, and I  
can't find any significant differences between them, I'm thinking  
there is either a flaw with this approach, or my trusty 1st-gen just  
isn't bringing enough horsepower to handle it.


For now, I think I'll just go back to code-only cells, although if  
there are any thoughts about what the problem is and/or what I can do  
about it, I'd be interested in hearing them.


Brian


On Jun 26, 2009, at 9:08 PM, mmalc Crawford wrote:


Replicated content
--
If you replicate a cell within a table view, then (assuming you want  
to use a nib file) the cell must go in a separate nib file so that  
you can load it an arbitrary number of times, as discussed here: 


To summarise the general approach, though, with a particular  
implementation:


In your table view controller class, declare an outlet for the  
custom cell and an action method for the button:

@property (nonatomic, assign) IBOutlet <#Your table view cell class#>
*<#cell outlet property#>;
- (IBAction)<#button action#>:(UIButton *)sender;

In your table view cell class, declare an outlet for the button (and  
any other UI elements as appropriate):

@property (nonatomic, retain) IBOutlet UIButton *<#button property#>;

In the cell's nib file:
	The class of the File's Owner should be your table view controller  
class.

Set an identifier for the cell.
Connect the appropriate outlet from File's Owner to the cell
Connect the button's action to the File's Owner
Connect the cell's button outlet to the button


In your table view controller subclass, then implement the  
tableView:cellForRowAtIndexPath: method along the following lines:


// Simplified code example
- (UITableViewCell *)tableView:(UITableView *)tableView  
cellForRowAtIndexPath:(NSIndexPath *)indexPath {


 static NSString *CellIdentifier = @"<#your cell's idenitifier#>";

	 <#Your table view cell class#> *cell = (<#Your table view cell  
class#> *)
  [tableView  
dequeueReusableCellWithIdentifier:CellIdentifier];


 if (cell == nil) { 
		[[NSBundle mainBundle] loadNibNamed:@"<#Your nib file name#>"  
owner:self options:nil];

 cell = <#cell outlet property#>;
 self.<#cell outlet property#> = nil;
}

cell.<#button property#>.tag = indexPath.row;

// implementation continues...


In your implementation of the action method, you can ask the button  
for its tag (which will indicate the row with which it's associated).


- (IBAction)<#button action#>:(UIButton *)sender {

NSInteger row = sender.tag;


For an example that illustrates several aspects of this approach, see:
	


___

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

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

2009-07-03 Thread WT

On Jul 3, 2009, at 8:23 PM, Development wrote:

This is more for the user interface experts, than the cocoa  
programming experts...


What is the suggested user interface when creating modal dialogs for  
documents that have be movable? For our application (think of it as  
a drawing program), the user sometimes NEEDS to be able to view the  
document under the modal dialog.  We can not use sheets, because  
they cover up the document window itself.  We can not do Inspectors,  
since the operations are intensely modal.  We could make the dialog  
box application modal (ie. one at any given time), but our client  
has really requested document modal, since they are often working  
with more then one document at the same time. I know how to write  
and invoke the code to make any given window modal to another, but I  
am more concerned about the user interface of this. Is there any  
suggested way to do this? Something to clue the user to what is  
going on?


Thanks,

Steve


This may be a really dumb idea, since I'm not a very experienced Cocoa  
developer, but can a drawer be document-modal?


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: Movable Document Modal Dialogs

2009-07-03 Thread Fritz Anderson

On 3 Jul 2009, at 1:23 PM, Development wrote:

What is the suggested user interface when creating modal dialogs for  
documents that have be movable? For our application (think of it as  
a drawing program), the user sometimes NEEDS to be able to view the  
document under the modal dialog.  We can not use sheets, because  
they cover up the document window itself.  We can not do Inspectors,  
since the operations are intensely modal.  We could make the dialog  
box application modal (ie. one at any given time), but our client  
has really requested document modal, since they are often working  
with more then one document at the same time. I know how to write  
and invoke the code to make any given window modal to another, but I  
am more concerned about the user interface of this. Is there any  
suggested way to do this? Something to clue the user to what is  
going on?


I don't think you can do it with off-the-shelf components.

An idea, I don't know how difficult: In the document window, under the  
title bar, animate in an additional NSView containing the modal  
information. It would push the document content down. Institute a  
runloop mode (or possibly just a document flag for your UI validation  
to inspect) that enables viewing the document, but not changing its  
state.


— F


--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- 


___

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

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

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

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


Movable Document Modal Dialogs

2009-07-03 Thread Development
This is more for the user interface experts, than the cocoa  
programming experts...


What is the suggested user interface when creating modal dialogs for  
documents that have be movable? For our application (think of it as a  
drawing program), the user sometimes NEEDS to be able to view the  
document under the modal dialog.  We can not use sheets, because they  
cover up the document window itself.  We can not do Inspectors, since  
the operations are intensely modal.  We could make the dialog box  
application modal (ie. one at any given time), but our client has  
really requested document modal, since they are often working with  
more then one document at the same time. I know how to write and  
invoke the code to make any given window modal to another, but I am  
more concerned about the user interface of this. Is there any  
suggested way to do this? Something to clue the user to what is going  
on?


Thanks,

Steve 
___


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

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

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

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


Re: Determining OS at Runtime

2009-07-03 Thread Jim Correia

On Jul 3, 2009, at 1:06 PM, Steve Christensen wrote:

For the case of a function, if you're deploying on 10.4 but using a  
10.5 function, that function will be weak-linked so doing a runtime  
check is both faster and more accurate in determining whether a  
function exists or not.


Beware that there have been edge cases in the past where a non-NULL  
function test will give you a false positive with disastrous results.


It goes like this:

if (FunctionName != NULL) {
FunctionName(x, y, z);
}

FunctionName was SPI on 10.x but (inadvertently) exported, but API on  
10.y.


When running on 10.x, your NULL function pointer test will pass, but  
this is SPI and isn't supported for use. The signature may have  
changed, or the range of valid input values may be a subset of the  
supported ones on 10.y.


This is not a theoretical problem, but one which has happened in the  
past.


What is the take home lesson here? Test all branches of the code you  
write.


Jim
___

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

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

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

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


Re: Determining OS at Runtime

2009-07-03 Thread Adam R. Maxwell


On Jul 3, 2009, at 10:06 AM, Steve Christensen wrote:

For the case of a function, if you're deploying on 10.4 but using a  
10.5 function, that function will be weak-linked so doing a runtime  
check is both faster and more accurate in determining whether a  
function exists or not. For a Cocoa class method, you could replace  
the test with a call to -respondsToSelector: to determine if it  
exists or not. In both cases you're taking a feature-based approach  
rather than a "I know this feature showed up in this OS version"  
approach.


Just as a caution, you may run across functions that don't have the  
appropriate weak attribute in the header, so you'll crash at launch  
time on 10.4 (this bit me recently with CFStringTokenizer, rdar://problem/6781636 
)  So if you're checking function pointers against NULL, check the  
header to make sure they have the correct accessibility macro.


--
Adam



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Determining OS at Runtime

2009-07-03 Thread Steve Christensen
For the case of a function, if you're deploying on 10.4 but using a  
10.5 function, that function will be weak-linked so doing a runtime  
check is both faster and more accurate in determining whether a  
function exists or not. For a Cocoa class method, you could replace  
the test with a call to -respondsToSelector: to determine if it  
exists or not. In both cases you're taking a feature-based approach  
rather than a "I know this feature showed up in this OS version"  
approach.


And if you did actually need a IsLeopardOrLater function, it would be  
better to cache the Gestalt result once since it won't change while  
your app is running. Otherwise you're making a selector value lookup  
each time.


BOOL IsLeopardOrLater(void)
{
static SInt32 sVersion = 0;

if (sVersion == 0)
Gestalt(gestaltSystemVersion, &sVersion);

return (sVersion >= 0x1050);
}


On Jul 3, 2009, at 9:00 AM, Mark Munz wrote:


You might also just use Gestalt:

BOOL IsLeopardOrLater(void)
{
SInt32 vers;
Gestalt(gestaltSystemVersion,&vers);
return (vers >= 0x1050);
}


On Fri, Jul 3, 2009 at 6:59 AM, Steve Christensen  
wrote:

On Jul 2, 2009, at 9:56 PM, Andrew Farmer wrote:


On 2 Jul 2009, at 16:29, Steve Christensen wrote:


If you want to make sure that you don't include any "old" code  
in your
executable when you decide to make 10.5 (for example) your base  
OS version,

you could arrange your code like this:

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
  if (SomeLeopardFunction == NULL)
  TigerFunction();
  else
#endif
  SomeLeopardFunction();


Preprocessor directives take effect at compile time, not at runtime.


Yes, I'm aware of that. My point was that by writing the code in this
fashion, when you start building your software to -require- a  
minimum of

10.5, any pre-10.5 code will be compiled out because then
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 so all  
you're left

with is the call to SomeLeopardFunction().


___

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

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

2009-07-03 Thread Mark Munz
You might also just use Gestalt:

BOOL IsLeopardOrLater(void)
{
SInt32 vers;
Gestalt(gestaltSystemVersion,&vers);
return (vers >= 0x1050);
}


On Fri, Jul 3, 2009 at 6:59 AM, Steve Christensen wrote:
> On Jul 2, 2009, at 9:56 PM, Andrew Farmer wrote:
>
>> On 2 Jul 2009, at 16:29, Steve Christensen wrote:
>>>
>>> If you want to make sure that you don't include any "old" code in your
>>> executable when you decide to make 10.5 (for example) your base OS version,
>>> you could arrange your code like this:
>>>
>>> #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
>>>   if (SomeLeopardFunction == NULL)
>>>       TigerFunction();
>>>   else
>>> #endif
>>>       SomeLeopardFunction();
>>
>> Preprocessor directives take effect at compile time, not at runtime.
>
> Yes, I'm aware of that. My point was that by writing the code in this
> fashion, when you start building your software to -require- a minimum of
> 10.5, any pre-10.5 code will be compiled out because then
> MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 so all you're left
> with is the call to SomeLeopardFunction().
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/unmarked%40gmail.com
>
> This email sent to unmar...@gmail.com
>



-- 
Mark Munz
unmarked software
http://www.unmarked.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: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-03 Thread Jerry Krinock


On 2009 Jul 03, at 05:50, Michael Ash wrote:


It is entirely possible that Apple's code relies
on this method throwing an exception on error.


Ah, you're correct.  So I've changed it to be a regular category  
method, +unarchiveObjectSafelyWithData:, instead of replacing the  
method.


___

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

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

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

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


Re: Private copy not working correctly

2009-07-03 Thread Joe Turner

Thanks, this seems to work perfectly!

I recently read about shallow and deep copies, but didn't see the  
initWithDictionary:copyItems: method.


Thanks,

Joe
On Jul 2, 2009, at 6:51 PM, Adam R. Maxwell wrote:



On Jul 2, 2009, at 12:05 PM, Joe Turner wrote:

I'm trying to create a private copy of an object, but yet when the  
original changes, my copy changes too.
I have an array of dictionaries called spacesData. Then, when I do:  
NSDictionary *backup = [[spacesData objectAtIndex:index] copy];  
everything is fine, and this one looks as it should. Then, when I  
change something in spacesData objectAtIndex:index], this private  
copy changes too. Doesn't "copy" create a private copy, or am I  
doing something wrong?


Copying a collection makes a shallow copy, so only the collection  
itself is copied, not the values that it contains.  If you want to  
copy values, check out -[NSDictionary  
initWithDictionary:copyItems:], or CFPropertyListCreateDeepCopy().


--
Adam



___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-03 Thread John C. Randolph


On Jul 2, 2009, at 10:52 AM, Bill Cheeseman wrote:

Apple will probably say I should move on to Cocoa Bindings and get  
over it.



I certainly would.

-jcr
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: User interface validation doesn't work, right?

2009-07-03 Thread Keary Suska

On Jul 2, 2009, at 11:52 AM, Bill Cheeseman wrote:


On Jul 2, 2009, at 12:24 PM, Keary Suska wrote:

Because the two protocols in question are formal protocols, the  
@interface declaration must specify conformance. If it doesn't,  
then no assumption of conformance should be made. Pure and simple.  
Also, protocol conformance is not inheritable in Objective-C.


1. Taking that last point first, the Objective-C 2.0 Programming  
Language document says this: "A class is said to conform to a formal  
protocol if it adopts the protocol or inherits from another class  
that adopts it." I believe, without checking, that this was true in  
1.0, also. I take that to mean that protocol conformance is in fact  
inherited. That makes sense, because a protocol is simply a promise  
that certain methods are implemented, and implemented methods are  
inherited by subclasses.


Yeah, I misspoke there. You are absolutely correct.


2. The key question for me is your first point.

The way I work around the lack of automatic validation for buttons  
is this: In my window controller, I implement - 
validateUserInterfaceItem: and declare that my controller conforms  
to the NSUserInterfaceValidations protocol. That's exactly what  
NSDocument does, as I understand it. Since user interface items are  
not automatically validated, I force validation by implementing  
NSWindow's -windowDidUpdate: delegate method so that it loops  
through all subviews of the window calling my controller's - 
validateUserInterfaceItem: protocol method. (I could use something  
other than -windowDidUpdate: to trigger the protocol method if  
efficiency becomes an issue, but at this point doing it every time  
the window updates works just fine. I am aware that Apple is  
struggling with efficiency concerns in automatic validation of  
toolbar items.)


Why not use bindings or KVO? They will likely be much more efficient,  
easier to implement, and provide more control.


Now here's my question for you: In my controller's implementation of  
-validateUserInterfaceItem:, I can either limit the items that I  
enable/disable by checking whether their class is NSButton (which I  
know responds to -action and -setEnabled:, and I can confirm that  
programmatically). Or, instead, I can limit the items by checking  
whether they conform to the NSValidatedUserInterfaceItem protocol.  
If I do the latter, I have to declare a subclass of NSButton and  
declare that it conforms to the protocol because NSButton does not  
itself declare conformance, and of course I have to set the type of  
my buttons to my subclass type in Interface Builder. Either  
technique works (I know because I've already done it), but testing  
for compliance with the NSValidatedUserInterfaceItem protocol  
somehow seems purer to me.


The whole approach seems problematic to me. I would say that you  
should use the API when you can, and work around it only when you  
can't (I am full of ambiguous maxims these days!) I.e., allow menus  
(includes popups) and toolbars and any other object that conforms to  
NSValidatedUserInterfaceItem proper ("proper" in the Objective-C view,  
as opposed to your view--this has been hashed out enough I won't  
elaborate) to use their automatic validation, and use a "home grown"  
solution for everything else. The latter solution also preferably  
working with the API rather than around it (e.g. KVO), because you can.


Where would you come out on this question? From your comments, I  
assume you would say I should not subclass NSButton and declare it  
as conforming. Then I would have to simply check whether the class  
of an item is the NSButton class. You might also insist that I  
should not name my validation method -validateUserInterfaceItem:,  
but something else such as -updateWindow, because I risk confusing  
people about what my controller really does. In that case, I'm back  
where most Cocoa applications were before Cocoa bindings were  
invented, declaring a custom -updateWindow method and calling it  
from -windowDidUpdate or whatever.


Yes, because as others point out, we don't actually know how (more  
importantly, when) validation is called, so we don't know how to  
duplicate it. I doubt that declaring conformance is sufficient.


I would prefer to do things the NSUserInterfaceValidations way, so  
that I'm ready when Apple gets around to making user interface item  
validation automatic, which I really think it ought to do (with an  
on/off switch). (Apple will probably say I should move on to Cocoa  
Bindings and get over it.)



I would agree with Apple, or as a concession, say use KVO.

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

___

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

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

Help/Unsubscribe/Update your S

Re: Determining OS at Runtime

2009-07-03 Thread Steve Christensen

On Jul 2, 2009, at 9:56 PM, Andrew Farmer wrote:


On 2 Jul 2009, at 16:29, Steve Christensen wrote:
If you want to make sure that you don't include any "old" code in  
your executable when you decide to make 10.5 (for example) your  
base OS version, you could arrange your code like this:


#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
   if (SomeLeopardFunction == NULL)
   TigerFunction();
   else
#endif
   SomeLeopardFunction();


Preprocessor directives take effect at compile time, not at runtime.


Yes, I'm aware of that. My point was that by writing the code in this  
fashion, when you start building your software to -require- a minimum  
of 10.5, any pre-10.5 code will be compiled out because then  
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 so all you're  
left with is the call to SomeLeopardFunction().


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-03 Thread Michael Ash
On Fri, Jul 3, 2009 at 1:42 AM, Jerry Krinock wrote:
>
> On 2009 Jul 02, at 21:11, Michael Ash wrote:
>
>> Is there a reason you can't just implement a new method in a category
>> and not replace the existing one? It will be just as safe in your
>> code, just as easy to use,
>
> I'd considered doing that and yes it could be done.  But then it would have
> a different method name that I'd have to remember to use instead of
> -unarchiveObjectWithData:.
>
> Replacing a Cocoa method seems like it should only be done if the original
> method shipped by Apple is buggy.  I believe that's the case here.  The only
> behavior I'm losing is a potential crash.

Well, that's wrong. The behavior you're losing is that of throwing an
exception on error. It is entirely possible that Apple's code relies
on this method throwing an exception on error. As your own code
demonstrates, you can catch the exception in question without
crashing.

You're not fixing a bug, unless you consider throwing an exception to
always be a bug AND you consider any code which relies on catching an
exception to likewise be a bug. You're changing existing non-buggy
behavior. That's a bad thing to do unless you have a VERY good reason,
and IMHO "a different method name that I'd have to remember to use" is
a pretty crappy reason for this.

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: User interface validation doesn't work, right?

2009-07-03 Thread Quincey Morris

On Jul 3, 2009, at 01:20, Bill Cheeseman wrote:

In the case of buttons, you likewise have to implement - 
validateUserInterfaceItem: yourself. But that isn't enough, because  
Cocoa does not call it automatically just because you implemented  
it. A generic solution is to implement the -windowDidUpdate:  
delegate method in your window controller, and in it loop through  
all the subviews in your window's contentView. In each iteration of  
the loop, call your -validateUserInterfaceItem: method, testing  
first to make sure the item implements -action and -tag and - 
setEnabled: (or just test whether it's a button, since all buttons  
do). If efficiency becomes a problem, take steps to reduce the  
frequency with which -validatedUserInterfaceItem: is called (every  
time the window updates -- that is, once every time through the run  
loop -- may be overkill for many validation scenarios).


You should test for the specific view classes you want to have  
validated (just NSButton, I think, but I may have missed something  
from earlier in the thread). Don't try to initiate validation on every  
item (even if it implements action, tag and setEnabled), because you  
don't know for sure what other classes may already have validation  
systems in place (like menus and toolbars do, though they of course  
won't be found among the subviews).


I would also check that the button *doesn't* conform to  
NSValidatedUserInterfaceItem, because if it does that certainly means  
it is already participating in a validation system being initiated  
elsewhere. There don't appear to be any such systems (apart from menus  
and toolbars) in the Cocoa frameworks under Leopard, but who knows  
what may change in the future?


Then the only danger is that if someone else (e.g. a 3rd-party  
framework) implements a validation system for NSButtons in the same ad- 
hoc way you're proposing, then your two systems will conflict.  
However, if that's the case, you probably won't know of it (except  
that validation will occur twice as many times), and there's not much  
you can do about it, so it's not worth worrying about.


When you invoke validateUserInterfaceItem:, your window controller  
also needs to make sure to send the message to the button's effective  
target, not to self, similar to what's described in:


	http://developer.apple.com/documentation/Cocoa/Conceptual/UIValidation/Articles/ValidatingObjects.html#/ 
/apple_ref/doc/uid/2745


so the code will look a bit like this:

id validator = [NSApp targetForAction:[button action] to:[button  
target] from: button];
if ((validator == nil) || ![validator respondsToSelector:[button  
action]])

[button setEnabled:NO];
else if ([validator  
respondsToSelector:@selector(validateUserInterfaceItem:)])
	[button setEnabled:[validator validateUserInterfaceItem: (id<  
NSValidatedUserInterfaceItem>) button]];

else
[button setEnabled:YES];


I agree that the frequency of the validation is a side issue, to be  
dealt with if there is a problem. In general, there may also be a  
problem with validation *not* getting called unless there is a window  
update, if the validation result might change when there is no visible  
change to the window. (I believe there's a flaw like that in the  
toolbar automatic validation, but I've never been able to pin it down.)



___

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

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

2009-07-03 Thread Carl Harris
Are there events that I can observe that indicate when the screen  
lock has activated/deactivated?  I have a background agent that  
should really be disabled when the screen is locked...



Responding to my own post, in hopes that it may help others who find  
themselves hunting for how to do detect the activation/deactivation of  
the screen lock and/or screensaver...


The following notifications are posted to the default distributed  
notification center for events related to the screen lock and screen  
saver:


com.apple.screenIsLocked
com.apple.screenIsUnlocked

com.apple.screensaver.didstart
com.apple.screensaver.willstop
com.apple.screensaver.didstop

Getting these events is then a simple matter of registering to observe  
them via NSDistributedNotificationCenter.  I found them by adding an  
observer for *all* distributed events, and then sorting through the  
received notification names after activating/deactivating the screen  
lock.


I haven't found declarations for these events in a header anywhere,  
and I'm not certain that they're part of any published API, but the  
events are observable, at least in Leopard.


--
Carl Harris
Virginia Tech



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: User interface validation doesn't work, right?

2009-07-03 Thread Bill Cheeseman

On Jul 2, 2009, at 8:38 PM, Quincey Morris wrote:

It remains totally mysterious what's going to cause individual  
validatable interface items to trigger their own validation. Perhaps  
there's no automatic general mechanism at all, and each interface  
item class has to solve the problem for itself


I would summarize it like this:

In the case of menu items and toolbar items, you have to implement - 
validateMenuItem: or -validateToolbarItem:, or their fallback - 
validateUserInterfaceItem:, yourself. In your implementation, you  
decide which items require validation by testing which action the  
current item sends (or, rarely, what tag it has). If you implement one  
of these -validate...  methods, it is called automatically by the - 
update or -validateVisibleItems mechanisms you described.


In the case of buttons, you likewise have to implement - 
validateUserInterfaceItem: yourself. But that isn't enough, because  
Cocoa does not call it automatically just because you implemented it.  
A generic solution is to implement the -windowDidUpdate: delegate  
method in your window controller, and in it loop through all the  
subviews in your window's contentView. In each iteration of the loop,  
call your -validateUserInterfaceItem: method, testing first to make  
sure the item implements -action and -tag and -setEnabled: (or just  
test whether it's a button, since all buttons do). If efficiency  
becomes a problem, take steps to reduce the frequency with which - 
validatedUserInterfaceItem: is called (every time the window updates  
-- that is, once every time through the run loop -- may be overkill  
for many validation scenarios).


--

Bill Cheeseman
b...@cheeseman.name

___

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

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

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

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