How font size managed without affecting the font? Please help

2009-01-13 Thread rethish
Hi all,


problem:

I have some text(in textview) with different combination of fonts. If i
select some range of text (combination of different fonts) to change its
size , the size changes with a change in font (which was last selected from
the popupbutton pop1).


I want to change the fontsize without affecting the font . (AS IN
TEXTEDIT AND WORD)


I use all the fonts and fontsize through a popupbutton:
pop1 : font
pop2 : fontsize



NSArray *path=[[NSFontManager alloc]  availableFonts];
 
[pop1 addItemsWithTitles:path];


I use this code to change the fontsize:

NSFont *font1 = [NSFont fontWithName:[pop1 titleOfSelectedItem] size:[[pop2
titleOfSelectedItem] doubleValue]];

  
if([[txt string] isEqualToString:@""])
{
[txt setFont:font1];
}

else 
{
NSRange range= [txt rangeForUserCharacterAttributeChange];
NSDictionary *attrs=[NSDictionary
dictionaryWithObjectsAndKeys:font1, NSFontAttributeName ,txt ,
NSTextViewDidChangeTypingAttributesNotification, nil];
[txt setTypingAttributes:attrs];
[txt setFont:font1 range: range];


}
  




Thank you
regards





___

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

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

2009-01-13 Thread Mohan Parthasarathy
On Tue, Jan 13, 2009 at 8:06 PM, Ken Thomases  wrote:

> On Jan 13, 2009, at 3:33 PM, Jean-Daniel Dupas wrote:
>
>  he is just talking about class name, not class.
>>
>> NSClassFromString() is probably what you're looking for.
>>
>> NSMutableString *clsName = derive class name from the entry.
>>
>> Class cls = NSClassFromString(clsName);
>>
>> id instance = [[cls alloc] init];
>>
>
> I'll just add the following:
>
> If you don't need such complete flexibility -- for example, if you're
> selecting from a fixed set of classes by some tag -- then you don't need to
> compute a class name and look up the class that way.
>
> Classes are objects and so they can be stored in collections.  For example,
> you could have a lookup dictionary that mapped from keys to class objects.
>  You would construct the dictionary like this:
>
>[NSDictionary dictionaryWithObjectsAndKeys:
>[SomeClass class], "key1",
>[OtherClass class], "key2",
>[ThirdClass class], "key3",
>// ... etc.
>nil];
>
> This adds a small amount of safety in the same way that
> statically-specified stuff generally does.  For example, the compiler will
> catch typos in class names.
>

Thanks for this suggestion. This looks fairly clean except that the space is
allocated at the beginning. This may not be a big deal in some cases. In the
other way, you allocate space and insert in the dictionary only when needed.
Also, eventually i need the real object instances inserted in the
dictionary.

-mohan


-mohan


>
> Cheers,
> Ken
>
>
___

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

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

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

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


Re: Constructing class names dynamically

2009-01-13 Thread Ken Thomases

On Jan 13, 2009, at 3:33 PM, Jean-Daniel Dupas wrote:


he is just talking about class name, not class.

NSClassFromString() is probably what you're looking for.

NSMutableString *clsName = derive class name from the entry.

Class cls = NSClassFromString(clsName);

id instance = [[cls alloc] init];


I'll just add the following:

If you don't need such complete flexibility -- for example, if you're  
selecting from a fixed set of classes by some tag -- then you don't  
need to compute a class name and look up the class that way.


Classes are objects and so they can be stored in collections.  For  
example, you could have a lookup dictionary that mapped from keys to  
class objects.  You would construct the dictionary like this:


[NSDictionary dictionaryWithObjectsAndKeys:
[SomeClass class], "key1",
[OtherClass class], "key2",
[ThirdClass class], "key3",
// ... etc.
nil];

This adds a small amount of safety in the same way that statically- 
specified stuff generally does.  For example, the compiler will catch  
typos in class names.


Cheers,
Ken

___

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

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

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

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


Re: runModalForWindow, best solution to modal session

2009-01-13 Thread Ken Thomases

On Jan 13, 2009, at 1:21 PM, Alexander Reichstadt wrote:


On 13.01.2009, at 19:44, Keary Suska wrote:

If so, do you override -initWithWindowNibName:? The implementation  
may matter.


No, I only override initWithWindow. Should I override it, and if so  
should I call on NSBundle to load my nib there then?


Your symptoms sound like you're not overriding the initializer  
properly.  Show us the code.


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: Seamlessly converting any type of document to PDF?

2009-01-13 Thread Andrew Farmer

On 13 Jan 09, at 15:24, Laurent Daudelin wrote:
I'm looking for suggestions on how to convert any type of document  
to PDF. Ideally without the user input but I'm mostly interested in  
getting it to work. I did think about a few possible solutions but  
I'm not sure. 'textutil' could be used for some conversions to maybe  
html and then I could probably convert html to pdf, but that would  
not work for any type of document. I know that when you print from  
any application, you can save the printed document to pdf but that  
requires too much interaction from the user.


Any idea or suggestion?


There is no general way to do this without the cooperation of the  
program that created the files.

___

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

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

2009-01-13 Thread JB
Great suggestion!  However, the post method itself sits inside a
try-catch-finally statement:

@implementation Controller
- (void)sync{
  @try {
NSLog(@"sync has begun");
... lots of setup, with potential to throw custom errors ...
[batch post]; // can throw custom errors too
  }
  @catch (NSException* exception) {
NSString* reason = [NSString stringWithFormat:@"%@", [exception
reason]];
[self setSyncStatus:[NSString stringWithFormat:@"Sync failed: %@",
reason]];
[self setSyncing:FALSE];
  }
  @finally {
if ([self isSyncing] == TRUE) {
  // if still syncing, sync wasn't interrupted by error; set sync status
to success
  [self setSyncStatus:[NSString stringWithFormat:@"Last sync: %@", [self
timestamp]]];
  [self setSyncing:FALSE];
}
[self postSyncFinishedNotification];
  }
}
@end

@implementation Batch
...
- (void)post{
  NSMutableURLRequest* request = [self requestWithMethod:POST];

  // this method wraps NSURLConnection initWithRequest:request delegate:self
  [self sendAsynchronousRequest:request];

  // should not be evaluated until sendAsynchronousRequest is complete
  NSLog(@"post finished");
}

- (NSData*)sendAsynchronousRequest:(NSMutableURLRequest*)request{
  NSURLConnection* connection = [[NSURLConnection alloc]
initWithRequest:request delegate:self];
  if (connection) {
// do nothing, handled by delegate methods
  } else {
 @throw [self connectionException];
  }
  return receivedData;
}
@end

I did this to have one place to catch and process errors for the entire sync
process, which includes errors that I throw upon receipt of responses
containing non-2xx status codes (not shown here, but appears in the delegate
method connection:didReceiveResponse:)

This works with the synchronous approach, but not with the async approach
because the rest of the try-catch-finally statement evaluates before the
request completes.  Hence the request for suggestions on forcing the
sendAsynchronousRequest method to finish before moving on.

I've looked into locking the thread with NSConditionLock, but that feels
like overkill here.  Might there be a more direct solution that I'm not
seeing?

Many thanks!
JB



On Tue, Jan 13, 2009 at 2:24 PM, Kevin Gessner wrote:

> On Jan 13, 2009, at 4:27 PM, JB wrote:
>
>  Hi all,
>>
>> I'm building a client for a server with (apparently) weird redirect
>> issues,
>> I cannot get a proper HTTP response using NSURLConnection
>> sendSynchronousRequest
>>
>> However, I can print out the response code using the asynchronous method:
>> [[NSURLConnection alloc] initWithRequest:request delegate:self];
>>
>> When I swap this method in, I can print out the status code just fine.
>> However, because this approach is asynchronous my code calls this method
>> and
>> moves on without waiting for a return value.  I need the request to
>> complete
>> before moving on.
>>
>> How can I force my code to wait for the asynchronous request to finish,
>> without using sendSynchronousRequest?
>>
>
> You can split your post-connection stuff into another method, and call it
> from the delegate's implementation of connectionDidFinishLoading:. Then it
> will be called only when the connection is complete.
>
> HTH
> -- Kevin
>
> Kevin Gessner
> http://kevingessner.com
> ke...@kevingessner.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: Seamlessly converting any type of document to PDF?

2009-01-13 Thread Martin Wierschin
I'm looking for suggestions on how to convert any type of document  
to PDF.


I've never used it, but the QuickLook API seems to indicate this  
functionality may be available if the document QuickLook generator  
cooperates:


"If your application has documents that (potentially) have more than  
one page of vector graphics, you should consider using the  
QLPreviewRequestCreatePDFContext function to create the graphics  
context for drawing the preview in. This function returns a graphics  
context suited for PDF content."


Unfortunately it would be up to the QuickLook generator to decide the  
difference between a "preview" and a full print. Although, looking at  
the API I don't even see a way for clients to specifically request  
multi-page previews, so you may be completely out of luck there.


Ideally without the user input but I'm mostly interested in getting  
it to work.


You might be able to put together some AppleScript or Accessibility  
API code that opens the file in the default application and  
manipulates the Print dialogue to save off a PDF. It would likely be  
ugly work to support applications that have custom print options/ 
dialogs.


~Martin

___

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

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

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

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


Re: UTIs and type codes and extensions

2009-01-13 Thread Julien Jalon
On Wed, Jan 14, 2009 at 2:14 AM, Randall Meadows wrote:

> I'm just making sure I'm not missing something...
>
> There's no system-defined way to go from a UTI to an old-style file type
> code (which the UTI docs seem to refer to as a "tag") and back again, am I
> correct?
>

extern CFStringRef
UTTypeCopyPreferredTagWithClass(
  CFStringRef   inUTI,
  CFStringRef   inTagClass)
AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;

extern CFStringRef
UTTypeCreatePreferredIdentifierForTag(
  CFStringRef   inTagClass,
  CFStringRef   inTag,
  CFStringRef   inConformingToUTI)   /* can be NULL */
 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;

extern CFArrayRef
UTTypeCreateAllIdentifiersForTag(
  CFStringRef   inTagClass,
  CFStringRef   inTag,
  CFStringRef   inConformingToUTI)   /* can be NULL */
 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;



>
> For instance, my app can export files as TIFF, JPEG, or PNG.  When the user
> makes the selection, I convert the selection popup menu to the appropriate
> UTI using the defined constants in UTCoreTypes.h (kUTTypeTIFF, et al).  I'd
> like to generalize the subsequent code to take that UTI ("public.tiff" for
> example) and convert it to the appropriate type code ('TIFF').  The next
> logical step would be producing a file name extension based on that as well
> ("public.tiff" -> "tif").
>
> *All* this information is contained in the table at <
> http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/utilist/chapter_4_section_1.html#//apple_ref/doc/uid/TP40001319-CH205-CHDIJFGJ>,
> but I could discern no way to actually do these types of conversions in a
> general manner.
>
> History: The reason I need to do this is, Photoshop is brain-dead when it
> comes to opening image files that happen to have no extension in the
> filename (and no file type code).  Preview, QuickTime Player and
> GraphicConverter (and sometimes Safari) have NO problem identifying and
> opening the exact same files, sans extension, but PS simply says "Could not
> complete your request because Photoshop does not recognize this type of
> file."  I am working around this by attaching type and creator codes to all
> the image files I export.  (Yes, my client could avoid all this by simply
> including an extension to the image name, but old dogs, new tricks, and all
> that...)
>

You always can teach new tricks to old dogs... it's significantly more
difficult for human beings.

-- 
Julien
___

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

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


UTIs and type codes and extensions

2009-01-13 Thread Randall Meadows

I'm just making sure I'm not missing something...

There's no system-defined way to go from a UTI to an old-style file  
type code (which the UTI docs seem to refer to as a "tag") and back  
again, am I correct?


For instance, my app can export files as TIFF, JPEG, or PNG.  When the  
user makes the selection, I convert the selection popup menu to the  
appropriate UTI using the defined constants in UTCoreTypes.h  
(kUTTypeTIFF, et al).  I'd like to generalize the subsequent code to  
take that UTI ("public.tiff" for example) and convert it to the  
appropriate type code ('TIFF').  The next logical step would be  
producing a file name extension based on that as well ("public.tiff" - 
> "tif").


*All* this information is contained in the table at , but I could discern no way to actually do these types of  
conversions in a general manner.


History: The reason I need to do this is, Photoshop is brain-dead when  
it comes to opening image files that happen to have no extension in  
the filename (and no file type code).  Preview, QuickTime Player and  
GraphicConverter (and sometimes Safari) have NO problem identifying  
and opening the exact same files, sans extension, but PS simply says  
"Could not complete your request because Photoshop does not recognize  
this type of file."  I am working around this by attaching type and  
creator codes to all the image files I export.  (Yes, my client could  
avoid all this by simply including an extension to the image name, but  
old dogs, new tricks, and all that...)


Thanks!
randy
___

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

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

2009-01-13 Thread Shawn Erickson
On Tue, Jan 13, 2009 at 4:13 PM, Jerry Krinock  wrote:
>
> On 2009 Jan, 13, at 14:24, Kevin Gessner wrote:
>
>> On Jan 13, 2009, at 4:27 PM, JB wrote:
>>
>>> How can I force my code to wait for the asynchronous request to finish,
>>> without using sendSynchronousRequest?
>>
>> You can split your post-connection stuff into another method, and call it
>> from the delegate's implementation of connectionDidFinishLoading:. Then it
>> will be called only when the connection is complete.
>
> How will that cause the main thread to block, as JB desires?

It doesn't. The point is he really shouldn't have the main thread
block. He should have it be event driven. Start the request, go back
to the normal run loop, handle the notification when the request
finishes (or fails), and carry on with the next steps.

> My code for doing this starts the connection in a different thread, then
> enters an infinite loop which checks for either a response or a user
> cancellation every 50 milliseconds, breaking when either is received.

*cringe*

Polling like this is almost always a bad idea... Several better ways
exist to deal with this but which to use depends on what you are
attempting to do.

-Shawn
___

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

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

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

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


Re: alternative to NSURLConnection sendSynchronousRequest

2009-01-13 Thread Jerry Krinock


On 2009 Jan, 13, at 14:24, Kevin Gessner wrote:


On Jan 13, 2009, at 4:27 PM, JB wrote:

How can I force my code to wait for the asynchronous request to  
finish,

without using sendSynchronousRequest?


You can split your post-connection stuff into another method, and  
call it from the delegate's implementation of  
connectionDidFinishLoading:. Then it will be called only when the  
connection is complete.


How will that cause the main thread to block, as JB desires?

My code for doing this starts the connection in a different thread,  
then enters an infinite loop which checks for either a response or a  
user cancellation every 50 milliseconds, breaking when either is  
received.


___

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

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

2009-01-13 Thread Jerry Krinock


On 2009 Jan, 13, at 11:48, Ronnie B wrote:


I have a modal dialog that I want to resize dynamically in case if a
validation on an input field fails and I display a validation text  
bellow

the field.  I would like to 'push' the rest of the dialog down,



leaving the rest if the elements proportionally as they were.


I don't know what you mean by "proportionally", but other than that I  
think I get it.  You want to add a subview, move the other subviews,  
and resize the window bigger as needed.



Anyone can suggest a right way of doing it.


Well, I don't know if it is "right", but it works for me.  Iterate  
through all the subviews, do alot of calculations, and send alot of  
setFrame: messages.


The following project is a work in progress, but if you dig into the - 
[SSYAlert doLayout], you'll see how it's done for a very general case:


http://sheepsystems.com/files/SSYAlert.zip

I tried to symlink all the dependencies and set zip to follow them.   
Let me know if there are any missing any dependencies.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Chunk 1978
humm well, my app is 10.5 only, so only G4s+ can run it (i
think)... i just realized that if the finder is busy (copying, etc.)
it will not quit and the system will show the attached message.  my
procedure was this:

- execute action
- quit finder
- relaunch finder

but i've realized that if the finder is busy and can not quit, the
action will still execute wether the finder quits or not.  so, now my
procedure is this:

- quit finder
- execute action
- relaunch finder

i'm assuming that based on newer computers (G4+) and this new
procedure that i don't have to worry about the finder's quit delay?  i
realize this is still crude, but less likely to fail, no?

On Tue, Jan 13, 2009 at 6:30 PM, has  wrote:
> Chunk 1978 wrote:
>
>> ok... so i've decided to use a simple apple script for this:
>>
>> tell application "Finder"
>>quit
>>delay 0.25
>>launch
>> end tell
>>
>> or this (which i believe is the same thing)
>>
>> tell application "Finder"
>>quit
>>delay 0.25
>>activate application "Finder"
>> end tell
>>
>> but i'd like to know about the delay.  without the delay... in this
>> script the delay works to save the finder's window state and then to
>> relaunch the finder.  should i be concerned about this delay on older,
>> slower computers?  should it be longer?
>
>
> Quitting an application and relaunching it immediately afterwards is a bit
> problematic as the 'quit' event will return before the application has
> finished terminating, with the result that you're trying to start up an
> application that's in the process of shutting down. Sticking in a delay is
> crude at best, and potentially unreliable as the time a process takes to
> terminate might vary. You might try getting the process's PID then
> repeatedly polling the system to see if that PID still exists, and only
> proceed with the relaunch once it ceases to be. (If you're in 10.5+,
> AppleScript's application objects have an 'is running' property, although I
> don't know if they do this or something else). To be honest, I'm not really
> sure what's best.
>
> HTH
>
> has
> --
> Control AppleScriptable applications from Python, Ruby and ObjC:
> http://appscript.sourceforge.net
>
>
<>___

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

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

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

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

Re: Strange Webview Problem

2009-01-13 Thread Diez B. Roggisch

Jean-Daniel Dupas schrieb:


Le 14 janv. 09 à 00:11, Diez B. Roggisch a écrit :


Nick Zitzmann schrieb:

On Jan 13, 2009, at 3:45 PM, Diez B. Roggisch wrote:
Just for the record - the timoutInterval of 0 is the culprit. I 
don't have the slightest idea why it stopped working, but I don't 
care either. It might be worth mentioning in the docs though that 
passing 0 actually terminates the request immediatly, instead of 
setting the timeout to unlimited.
That makes sense, actually. If you want the timeout interval to be 
unlimited, then you should pass in DBL_MAX, which will cause it to 
time out ~300 million years from now, by which point I assume your 
computer will no longer be around (or at least you won't be using 
it)... 0 usually means "do it now" when it comes to time intervals.


But it doesn't mean "do it now", it means "don't do it at all"...

And I disagree that it makes sense - if I didn't want something to 
happen, I simply wouldn't make the call.


It obviously meant "I don't care" until a few months ago, and I've 
seen lots of interfaces that behaved that way. Timeouts, resource 
limits, all those kind of things accept 0 for "turn this option off."


However, it was never documented to work that way, so I don't blame 
anybody - it's obviously an implementation artifact. And of course I 
can (and did) set the timout to a ridiculous long interval. Not just 
as long as you proposed though :)


Diez


Just an example of why 0 does not always mean "no timeout":


I never said it always does.


man poll
If timeout is greater than zero, it specifies a maximum interval (in 
milliseconds) to wait for any file descriptor to become ready.
If timeout is zero, then poll() will return without blocking. If the 
value of timeout is -1, the poll blocks indefinitely.


Else how would you handle this case ?



I wouldn't. Because there are three different semantics of poll that 
need to be catered to.


See here for an example that shaped my expectations:

https://twiki.cern.ch/twiki/bin/view/LCG/FtsChangesFrom20To21

"""
Note on timeout arguments: values for timeout arguments in the database 
follow this convention:


* unset (null) or negative value: do not specify the timeout and 
let the underlying transfer service choose a default.
* 0: no timeout (if the underlying transfer service allows it; e.g. 
in case of http timeout, a timeout is always set).

* positive value: use value for timeout
"""

I don't say passing 0 as timeout *has* to behave the way I expected it 
to be. All I say is


 - the behavior changed without notice, so it is some kind of regression
 - it is not documented
 - there are known cases where 0 means "ignore value", so it is worth 
documenting

 - I fail to see where the sense lies in making a call effectively a NOP

However, I don't want to blow this out of proportion. My problem is solved.

The fun part would have been if I had received these insights into the 
meaning of timeout *before* I struggled to find make things work. Which 
is not to imply you guys aren't helpful.


Diez
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread has

Chunk 1978 wrote:


ok... so i've decided to use a simple apple script for this:

tell application "Finder"
quit
delay 0.25
launch
end tell

or this (which i believe is the same thing)

tell application "Finder"
quit
delay 0.25
activate application "Finder"
end tell

but i'd like to know about the delay.  without the delay... in this
script the delay works to save the finder's window state and then to
relaunch the finder.  should i be concerned about this delay on older,
slower computers?  should it be longer?



Quitting an application and relaunching it immediately afterwards is a  
bit problematic as the 'quit' event will return before the application  
has finished terminating, with the result that you're trying to start  
up an application that's in the process of shutting down. Sticking in  
a delay is crude at best, and potentially unreliable as the time a  
process takes to terminate might vary. You might try getting the  
process's PID then repeatedly polling the system to see if that PID  
still exists, and only proceed with the relaunch once it ceases to be.  
(If you're in 10.5+, AppleScript's application objects have an 'is  
running' property, although I don't know if they do this or something  
else). To be honest, I'm not really sure what's best.


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

___

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

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

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

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


Re: supress calling objectValueForTableColumn

2009-01-13 Thread David Blanton

I just added

	if([aTableView inLiveResize]) return nil; in the  
objectValueForTableColumn call table blank but the resize is quick  
and the table refreshes quick


I guess I should oride preservescontentduringresize




On Jan 13, 2009, at 4:00 PM, David Blanton wrote:

I programatically add the enclosing scroll view of a table view to  
a scroll view that is the upper portion of a vertical split view.


I would like to supress the calling of objectValueForTableColumn  
whne resizing the split view so it functions smoothly.


Is this possible?

David Blanton





___

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

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

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


This email sent to aired...@tularosa.net




David Blanton





___

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

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


Seamlessly converting any type of document to PDF?

2009-01-13 Thread Laurent Daudelin

Hello.

I'm looking for suggestions on how to convert any type of document to  
PDF. Ideally without the user input but I'm mostly interested in  
getting it to work. I did think about a few possible solutions but I'm  
not sure. 'textutil' could be used for some conversions to maybe html  
and then I could probably convert html to pdf, but that would not work  
for any type of document. I know that when you print from any  
application, you can save the printed document to pdf but that  
requires too much interaction from the user.


Any idea or suggestion?

Thanks in advance!
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@verizon.net
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries



___

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

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

2009-01-13 Thread Jean-Daniel Dupas


Le 14 janv. 09 à 00:11, Diez B. Roggisch a écrit :


Nick Zitzmann schrieb:

On Jan 13, 2009, at 3:45 PM, Diez B. Roggisch wrote:
Just for the record - the timoutInterval of 0 is the culprit. I  
don't have the slightest idea why it stopped working, but I don't  
care either. It might be worth mentioning in the docs though that  
passing 0 actually terminates the request immediatly, instead of  
setting the timeout to unlimited.
That makes sense, actually. If you want the timeout interval to be  
unlimited, then you should pass in DBL_MAX, which will cause it to  
time out ~300 million years from now, by which point I assume your  
computer will no longer be around (or at least you won't be using  
it)... 0 usually means "do it now" when it comes to time intervals.


But it doesn't mean "do it now", it means "don't do it at all"...

And I disagree that it makes sense - if I didn't want something to  
happen, I simply wouldn't make the call.


It obviously meant "I don't care" until a few months ago, and I've  
seen lots of interfaces that behaved that way. Timeouts, resource  
limits, all those kind of things accept 0 for "turn this option off."


However, it was never documented to work that way, so I don't blame  
anybody - it's obviously an implementation artifact. And of course I  
can (and did) set the timout to a ridiculous long interval. Not just  
as long as you proposed though :)


Diez


Just an example of why 0 does not always mean "no timeout":

man poll
	If timeout is greater than zero, it specifies a maximum interval (in  
milliseconds) to wait for any file descriptor to become ready.
	If timeout is zero, then poll() will return without blocking. If the  
value of timeout is -1, the poll blocks indefinitely.


Else how would you handle this case ?

___

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

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

2009-01-13 Thread Diez B. Roggisch

Nick Zitzmann schrieb:


On Jan 13, 2009, at 3:45 PM, Diez B. Roggisch wrote:

Just for the record - the timoutInterval of 0 is the culprit. I don't 
have the slightest idea why it stopped working, but I don't care 
either. It might be worth mentioning in the docs though that passing 0 
actually terminates the request immediatly, instead of setting the 
timeout to unlimited.



That makes sense, actually. If you want the timeout interval to be 
unlimited, then you should pass in DBL_MAX, which will cause it to time 
out ~300 million years from now, by which point I assume your computer 
will no longer be around (or at least you won't be using it)... 0 
usually means "do it now" when it comes to time intervals.


But it doesn't mean "do it now", it means "don't do it at all"...

And I disagree that it makes sense - if I didn't want something to 
happen, I simply wouldn't make the call.


It obviously meant "I don't care" until a few months ago, and I've seen 
lots of interfaces that behaved that way. Timeouts, resource limits, all 
those kind of things accept 0 for "turn this option off."


However, it was never documented to work that way, so I don't blame 
anybody - it's obviously an implementation artifact. And of course I can 
(and did) set the timout to a ridiculous long interval. Not just as long 
as you proposed though :)


Diez


___

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

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


supress calling objectValueForTableColumn

2009-01-13 Thread David Blanton
I programatically add the enclosing scroll view of a table view to a  
scroll view that is the upper portion of a vertical split view.


I would like to supress the calling of objectValueForTableColumn whne  
resizing the split view so it functions smoothly.


Is this possible?

David Blanton





___

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

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

2009-01-13 Thread Nick Zitzmann


On Jan 13, 2009, at 3:45 PM, Diez B. Roggisch wrote:

Just for the record - the timoutInterval of 0 is the culprit. I  
don't have the slightest idea why it stopped working, but I don't  
care either. It might be worth mentioning in the docs though that  
passing 0 actually terminates the request immediatly, instead of  
setting the timeout to unlimited.



That makes sense, actually. If you want the timeout interval to be  
unlimited, then you should pass in DBL_MAX, which will cause it to  
time out ~300 million years from now, by which point I assume your  
computer will no longer be around (or at least you won't be using  
it)... 0 usually means "do it now" when it comes to time intervals.


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: Strange Webview Problem

2009-01-13 Thread Diez B. Roggisch

req = [NSURLRequest requestWithURL: url
cachePolicy: NSURLRequestReloadIgnoringCacheData
timeoutInterval: 0
   ];


Just for the record - the timoutInterval of 0 is the culprit. I don't 
have the slightest idea why it stopped working, but I don't care either. 
It might be worth mentioning in the docs though that passing 0 actually 
terminates the request immediatly, instead of setting the timeout to 
unlimited.


Diez
___

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

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

2009-01-13 Thread Kevin Gessner

On Jan 13, 2009, at 4:27 PM, JB wrote:


Hi all,

I'm building a client for a server with (apparently) weird redirect  
issues,

I cannot get a proper HTTP response using NSURLConnection
sendSynchronousRequest

However, I can print out the response code using the asynchronous  
method:

[[NSURLConnection alloc] initWithRequest:request delegate:self];

When I swap this method in, I can print out the status code just fine.
However, because this approach is asynchronous my code calls this  
method and
moves on without waiting for a return value.  I need the request to  
complete

before moving on.

How can I force my code to wait for the asynchronous request to  
finish,

without using sendSynchronousRequest?


You can split your post-connection stuff into another method, and call  
it from the delegate's implementation of connectionDidFinishLoading:.  
Then it will be called only when the connection is complete.


HTH
-- Kevin

Kevin Gessner
http://kevingessner.com
ke...@kevingessner.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


How can I change the time format for NSDatePicker?

2009-01-13 Thread peter ljunglöf

Hi,

here's a question about the time format for NSDatePicker. There are  
only two possibilities for time format: hr+min and hr+min+sec. I  
recently noticed that the actual time format used is the Short resp.  
Normal time format as defined in the International System Preferences.


This means that if I set the system date/time format to Swedish, I get  
[21.12] in the DatePicker, but if I change the region to English  
(USA), I get [9:12 PM] in the DatePicker.


So far, so good. But now I want use my own DatePicker time format in  
my app - how can I do that? I tried to bind a NSDateFormatter to the  
DatePicker (in Interface Builder), and IB doesn't complain, but it  
doesn't work. Is there any way to, e.g., change the International  
Region locally, only for one application or for one single DatePicker?


thanks,
/Peter

- - --- -- -- - - -  -  -- ---
peter ljunglöf (http://www.ling.gu.se/~peb)



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CoreData with OutlineView collapses items on fetch

2009-01-13 Thread peter ljunglöf

Hi Ron,

thanks for the information. Your explanation sounds reasonable and it  
also explains why the selection is removed (since the old TreeNode is  
removed), and why the delegate method outlineViewItemDidCollapse (and  
similar) is not triggered (since there is no "collapse", just a new  
fresh TreeNode).


So, there was a change in the behaviour of NSTreeController between  
10.5.5 and 10.5.6. Before it always returned the old TreeNode, but now  
it (sometimes) creates a new TreeNode - e.g., if it is deeply nested.  
Do you know if this new behaviour is intentional?


The only solution I can see is to go through all items in the  
OutlineView and record which of them are expanded or not, and record  
the curent selection. Then call [TreeController fetch], and then go  
through the items again, reexpanding and reselecting if necessary.


This means that using CoreData suddenly requires much more coding than  
before.


/Peter Ljunglöf


13 jan 2009 kl. 20.45 skrev Ron Lue-Sang:


Hi Peter,
I only skimmed through your description/question, but I'm reasonable  
sure I know what you're asking and what the answer is.


The outlineView identifies its items by pointer comparison. So two  
objects that are logically the same can show up in the tree  
together, but they can have different expansion state associated  
with them. For an outlineView bound to a treeController, the  
outlineView's items are NSTreeNodes vended by the treeController.


If you start out with A containing B and its descendants C and D,  
and then refresh managedObject A, the treeController sees this


1) A no longer has child objects
2) A has a new set of child objects

The treeController will see step one and nuke the treeNodes  
associated with B, C and D, since they're gone now. Then when A has  
its childObjects relationship filled in again, the outlineView knows  
that the outlineView item for A needs to be reloaded, so it'll ask  
the treeController for item A's child items. These will be a new set  
of treeNodes, including B.


What's happening is the treeController doesn't know that old B will  
become new B later. So it returns a different NSTreeNode instance to  
the outlineView for its item. The outlineView sees the new instance  
and shows it collapsed by default.


If you know you're going to do an operation like this, you can hang  
on to the indexPath of the nodes you want to expand, and just re- 
expand them when the operation is over.


Hope that helps.

On Jan 13, 2009, at 2:33 AM, peter ljunglöf wrote:


Hi,

After upgrading to 10.5.6, I got a problem with NSOutlineView and  
NSTreeController in my CoreData application. When executing fetch:  
on the NSTreeController, deeply nested items (nesting level>=2)  
collapses in the NSOutlineView.


I created a minimal XCode project with the same problem, it can be  
downloaded from


http://heatherleaf.se/temp/OutlineBug.zip

Open in XCode (I've tried 3.1.1 and 3.1.2), compile and run. Create  
some nested items (double-click to rename the item), select the  
topmost item and then click the "Fetch" button. E.g., if I create  
the following items (where "v" is the expanded triangle and ">" is  
the collapsed triangle):


   +---+
   | v A   |
   |   v B |
   | v C   |
   | D |
   +---+

Select the A item, and the click "Fetch", I get the following result:

   +---+
   | v A   |
   |   > B |
   |   |
   |   |
   +---+

Depending on the nestings and which item is selected, the selection  
sometimes changes, and sometimes everything is deselected.


Also, none of the following delegate methods get called:
outlineView:shouldCollapseItem:
outlineViewItemWillCollapse:
outlineViewItemDidCollapse:

Does anyone know what the problem is and how I can avoid collapsing  
my outline views? I did not have this problem in 10.5.5.



The example project is really simple. I created a new CoreData  
Application project. Added one attribute "name" and two  
relationships "children" and "parent" (inverses) to the data model.  
I did not touch the code at all.


In IB, I added a NSTreeController, with I set to Entity mode,  
children key path "children" and fetch predicate "parent==nil".  
Bound the Managed Object Context to  
OutlineBug_AppDelegate.managedObjectContext.


Then I added a NSOutlineView with one column, and bound that  
column's Value to TreeController.arrangedObjects.name.
Finally I added three buttons: Fetch, Remove and Add Child, and  
bound their sent actions to the TreeController's fetch:, remove:,  
and addChild: methods.


That's all.

regards,
Peter Ljunglöf


PS. My original project is of course larger, and can be found at http://code.google.com/p/kronox/ 
, if someone's interested...


- - --- -- -- - - -  -  

Re: Using UIImageView for animations

2009-01-13 Thread David Duncan

On Jan 13, 2009, at 1:03 PM, Sebastian Morsch wrote:

I am having the same problem with UIImageView, just in my case, it's  
not FPS performance but running out of memory. Using +  
imageWithContentsOfFile didn't seem to solve the problem. I had 20  
full screen PNGs loaded at the same time to hand them over to the  
view via the animationImages property, which almost always results  
in a memory warning.


Understandably, because that's 20*(320*480*4) = almost 12MB, which  
is way too much.


Pretty much. Using the animatedImages property requires all the images  
be accessible by the graphics hardware. As you may be aware, the  
graphics hardware can only view 24MB at a time (which includes the  
screen buffer and the back buffers of all of your views). If you go  
over 24MB then you fall off a performance cliff, as the driver has to  
juggle which memory is visible to the graphics hardware. This memory  
usage also competes with all other allocations that your application  
does, and any large allocation has a good chance to trigger a memory  
warning.


So my question is, how such an animation can be implemented? My next  
idea would be to do the animation myself by loading the next image,  
swapping it for the old one and dispose of the old one, so there's  
always just two images in memory at the same time. But I'm not sure,  
if this path is a good one because the timing of that process might  
be difficult to handle.


As you mention the timing is difficult to deal with. This would work  
fine for a slide show type animation where each image is onscreen for  
a fairly long length of time.


From my understanding, UIImageView can't be used for full frame  
animations with more than 10 images, or am I missing something? Is  
there another recommended strategy (besides using  
MPMoviePlayerController)?



This depends entirely on what you are attempting to implement. If you  
can do your animation programatically in some manner, then that would  
be the recommended course. Often people use OpenGL so that they can  
animate models with textures instead of pre-rendered content.  
Sometimes you can just use a set of static (or animated) but smaller  
images and move the hosting views around the screen. But exactly how  
you do it will depend on what you are trying to accomplish.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


Re: Constructing class names dynamically

2009-01-13 Thread Mohan Parthasarathy
thanks, this is exactly what i was looking for..

thanks
mohan


On Tue, Jan 13, 2009 at 1:41 PM, Bill Bumgarner  wrote:

> On Jan 13, 2009, at 1:33 PM, Jean-Daniel Dupas wrote:
>
>> he is just talking about class name, not class.
>>
>> NSClassFromString() is probably what you're looking for.
>>
>> NSMutableString *clsName = derive class name from the entry.
>>
>> Class cls = NSClassFromString(clsName);
>>
>> id instance = [[cls alloc] init];
>>
>
> Hah!  Yah -- OK -- my bad...
>
> Yes -- that is generally an OK idea.   A little odd for a design pattern,
> but not so odd as to raise any warning flags.
>
> b.bum
>
>
___

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

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

2009-01-13 Thread Bill Bumgarner

On Jan 13, 2009, at 1:33 PM, Jean-Daniel Dupas wrote:

he is just talking about class name, not class.

NSClassFromString() is probably what you're looking for.

NSMutableString *clsName = derive class name from the entry.

Class cls = NSClassFromString(clsName);

id instance = [[cls alloc] init];


Hah!  Yah -- OK -- my bad...

Yes -- that is generally an OK idea.   A little odd for a design  
pattern, but not so odd as to raise any warning flags.


b.bum

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Aquatic Prime + PayPal With Multiple Apps?

2009-01-13 Thread Devon Ferns
With Paypal IPN you can put in custom variables or different URLs for 
different products like /ipn.php?product=1, /ipn.php?product=2 etc.
In your php script you could just load the correct key pair depending on 
the URL parameters or custom variables passed.


Devon


Chunk 1978 wrote:

i've been researching aquatic prime and it doesn't seem easy to have
multiple apps if licenses are purchased thru PayPal.

Aquatic Prime + PayPal requires Auto Return to be turned on, and a
Return URL to be supplied.  the return URL leads to the .PHP file that
produces the license and and automatically sends it thru email.   the
supplied .PHP scripts are set up for one set of keys (Public Key and
Private Key)... different apps should have a different set of keys so
that purchasing one license for one app will not work on all apps the
developer offers...

the only thing i can think of is to have PayPal's Return URL be
directed to some sort of If/Else .PHP script that would load the
appropriate .PHP scripts for the appropriate purchased license, but
what would the variables be with paypal?

does anyone have experience with multiple apps and Aquatic Prime?
___

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

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

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

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


[SOLVED]: Enable Scripting Failing - Missing something? Based on SimpleScripingVerbs sample

2009-01-13 Thread Adam Venturella
I dunno what I was doing wrong, but I want back and made 2 new
projects from scratch, following the steps I laid out, and they both
woked.  One was a Striaght up Cocoa app, he the other was a Core Data
App.

:: shrugs ::
___

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

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


Aquatic Prime + PayPal With Multiple Apps?

2009-01-13 Thread Chunk 1978
i've been researching aquatic prime and it doesn't seem easy to have
multiple apps if licenses are purchased thru PayPal.

Aquatic Prime + PayPal requires Auto Return to be turned on, and a
Return URL to be supplied.  the return URL leads to the .PHP file that
produces the license and and automatically sends it thru email.   the
supplied .PHP scripts are set up for one set of keys (Public Key and
Private Key)... different apps should have a different set of keys so
that purchasing one license for one app will not work on all apps the
developer offers...

the only thing i can think of is to have PayPal's Return URL be
directed to some sort of If/Else .PHP script that would load the
appropriate .PHP scripts for the appropriate purchased license, but
what would the variables be with paypal?

does anyone have experience with multiple apps and Aquatic Prime?
___

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

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

2009-01-13 Thread Jean-Daniel Dupas


Le 13 janv. 09 à 22:29, Bill Bumgarner a écrit :


On Jan 13, 2009, at 1:18 PM, Mohan Parthasarathy wrote:

Does this make sense ?


Yes.


Or this is a bad idea ?


Yes.

Generally, anyway, it is indicative of bad design when your code  
seems to require dynamic generation of classes.




he is just talking about class name, not class.

NSClassFromString() is probably what you're looking for.

NSMutableString *clsName = derive class name from the entry.

Class cls = NSClassFromString(clsName);

id instance = [[cls alloc] init];


___

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

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

2009-01-13 Thread Bill Bumgarner

On Jan 13, 2009, at 1:18 PM, Mohan Parthasarathy wrote:

Does this make sense ?


Yes.


Or this is a bad idea ?


Yes.

Generally, anyway, it is indicative of bad design when your code seems  
to require dynamic generation of classes.


Not to say that there aren't specific cases where it is warranted --  
bridging comes to mind -- but that they are few and far between.


In this case, it sounds like are effectively looking for something  
that can do key/value storage, possibly with the ability to monitor  
the changes and/or support KVC and the like?



Obviously, i can have a dictionary which can be
keyed in using the "entry" selected which in turn has the relevant  
object to

handle the selection.


That'll work fine, no need for a custom class.   You could have a  
subclass of NSObject that has a name and stores an arbitrary set of  
key/value pairs in an NSMutableDictionary backing store (or  
NSMapTable, which can handle non-object values).   Instances of this  
would then be shoved into your dictionary as needed.


b.bum
___

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

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


alternative to NSURLConnection sendSynchronousRequest

2009-01-13 Thread JB
Hi all,

I'm building a client for a server with (apparently) weird redirect issues,
I cannot get a proper HTTP response using NSURLConnection
sendSynchronousRequest

However, I can print out the response code using the asynchronous method:
[[NSURLConnection alloc] initWithRequest:request delegate:self];

When I swap this method in, I can print out the status code just fine.
However, because this approach is asynchronous my code calls this method and
moves on without waiting for a return value.  I need the request to complete
before moving on.

How can I force my code to wait for the asynchronous request to finish,
without using sendSynchronousRequest?

example:

- (void)post{

  NSLog(@"building batch request");
  NSMutableURLRequest* request = [self requestWithMethod:POST];

  NSLog(@"posting batch request");
  // this method wraps NSURLConnection initWithRequest:request delegate:self
  [self sendAsynchronousRequest:request];

  // should not be evaluated until sendAsynchronousRequest is complete
  NSLog(@"post finished");
}

Many thanks!
JB
___

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

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


Constructing class names dynamically

2009-01-13 Thread Mohan Parthasarathy
Hi,

Sorry for the bad subject name. I found no other way to explain this. What i
need is a way to generate a class name dynamically. For example, the user
selects an entry in the Table (assume just one column) and each entry is
handled by a separate class. Obviously, i can have a dictionary which can be
keyed in using the "entry" selected which in turn has the relevant object to
handle the selection.

The other way is to dynamically construct the name from the selected "entry"
assuming the classes are named properly. The main section of the code does
not have to know what each class is (hence avoid including each of the
header files) as each of them is expected to implement a few methods
(protocol). Does this make sense ? Or this is a bad idea ?

Thanks for any suggestions,
mohan
___

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

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


Enable Scripting Failing - Missing something? Based on SimpleScripingVerbs sample

2009-01-13 Thread Adam Venturella
I have been reading over the docs re: Implementing Scripting for the
last couple of hours:
http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_implement/chapter_4_section_1.html#//apple_ref/doc/uid/2037-BBCJEEEC

Looked Over this sample from the docs:
Implementing a Verb-First Command-Align
http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_script_cmds/chapter_8_section_4.html#//apple_ref/doc/uid/20001242-SW7


I took a look at the sample application:
http://developer.apple.com/samplecode/SimpleScriptingVerbs/index.html
SimpleScriptingVerbs

Seems simple enough, so I wanted to start a new application, to make
sure I had my understanding correct.  I am literally copying the
SimpeCommand.h/m from the SimpleScriptingVerbs sample and trying to
implement that.
My process has been:

1) create new Cocoa application
2) Edit Info.plist to enable scripting and point to the script definition file:

NSAppleScriptEnabled


OSAScriptingDefinition
MyScriptingDef.def


3) create MyScriptingDef.def:


http://www.w3.org/2003/XInclude";>

   









4) check my targets to make sure MyScriptingDef.def is included in the
Copy Bundle Resources ( it is)

5) created SimpleCommand.h/m (which I copy from the
SimpleScriptingVerbs minus the scriptLog.h related files):
SimpleCommand.h:
#import 
@interface SimpleCommand : NSScriptCommand {
}
- (id)performDefaultImplementation;
@end

SimpleCommand.m:
#import "SimpleCommand.h"
@implementation SimpleCommand
- (id)performDefaultImplementation {
/* return 7 to show how to return a number from a command */
return [NSNumber numberWithInt:7];
}
@end





5) Run the application

6) open the script editor:
tell application "COCOA_Scriptable"
   do simple command
end tell

7) compile it and I get this error:
Syntax Error
Expected end of line but found identifier

8) click OK and I see in the script editor that "simple" is
highlighted in "do simple command"

9) look at SimpleScriptingVerbs(SimpleScriptingVerbsTest.applescript):
tell application "SimpleScriptingVerbs"
do simple command
end tell

10) test that app, everything works.


Am I missing something fundamental in my application?  It looks
exactly the same as the SimpleScriptingVerbs, but since it doesn't
function the same I must have missed a step somewhere?
___

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

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

2009-01-13 Thread Sebastian Morsch
I am having the same problem with UIImageView, just in my case, it's  
not FPS performance but running out of memory. Using +  
imageWithContentsOfFile didn't seem to solve the problem. I had 20  
full screen PNGs loaded at the same time to hand them over to the view  
via the animationImages property, which almost always results in a  
memory warning.


Understandably, because that's 20*(320*480*4) = almost 12MB, which is  
way too much.


So my question is, how such an animation can be implemented? My next  
idea would be to do the animation myself by loading the next image,  
swapping it for the old one and dispose of the old one, so there's  
always just two images in memory at the same time. But I'm not sure,  
if this path is a good one because the timing of that process might be  
difficult to handle.


From my understanding, UIImageView can't be used for full frame  
animations with more than 10 images, or am I missing something? Is  
there another recommended strategy (besides using  
MPMoviePlayerController)?


Thanks,
Sebastian



Am 13.01.2009 um 19:24 schrieb David Duncan:


On Jan 12, 2009, at 8:10 PM, Glenn Bloom wrote:


- When I animate a set of PNG's rather than JPEG's (again using
UIImageView's animationImages property),  I am thinking I don't  
need to
think about compression (or Apple optimization)? Is it then  
appropriate to
think of the total memory to be consumed simply as an aggregate of  
the total

bytes for all the images?


Basically yes. The rule of thumb is Width * Height * 4 for each  
image. Images must be decompressed before display. The PNG  
optimization that Xcode applies converts the image to a format that  
is optimal for display, it doesn't reduce the amount of storage  
needed to display it.


- Am I correct in thinking that for loading a short-running  
animation, I
should generally use the initWithContentsOfFile method of UIImage  
instead of

imageNamed because imageNamed caches the data into memory?


Unless you can prove that you get better performance with  
+imageNamed: you should always prefer +imageWithContentsOfFile: or - 
initWithContentsOfFile:. This is especially true with large images  
(primarily because they consume lots of memory and are not reused  
often enough to gain a benefit).



- I had thought there was a way to use Instruments to assess if a
UIImageView animation was skipping frames.  Now, I'm not so sure.   
Any
particular way to test if such an animation is skipping or not  
displaying

frames?



You can get an FPS meter from the Core Animation instrument. This  
may or may not be what you are thinking of.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


___

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

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

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

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


Re: IKImageBrowserView drag and drop/reordering when using core data [SOLVED]

2009-01-13 Thread jonat...@mugginsoft.com

IKImageBrowserDataSource Protocol has the answer.
For non file path represented images we need to implement -  
imageBrowser:writeItemsAtIndexes:toPasteboard:

/*

 write images to paste board

 need for dragging of non path represented images

 */
- (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser  
writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard: 
(NSPasteboard *)pasteboard

{
NSInteger   index;

	for (index = [itemIndexes lastIndex]; index != NSNotFound; index =  
[itemIndexes indexLessThanIndex:index])

{
		GoodThing *goodThing = [[imageBrowserViewArrayController content]  
objectAtIndex:index];
		[pasteboard setData:goodThing.imageRepresentation  
forType:NSTIFFPboardType];

}

return [itemIndexes count];
}


On 13 Jan 2009, at 14:43, jonat...@mugginsoft.com wrote:

I have been utilising the IKImageBrowserViewWithCoreData Apple  
sample code and wished to add drag and drop and reordering  
functionality.
Another Apple sample project, image-browser, covers most of the  
detail.


My problem is the following:

Drag and drop from say the finder works okay (if one can figure out  
that setting IKImageBrowserView -draggingDestinationDelegate seems  
broken in IB).

Reordering within the view itself, however, fails.

By experimentation I have determined that this is because our image  
representation (as per the IKImageBrowserItem informal protocol) is  
IKImageBrowserNSDataRepresentationType.
In other words, we are storing an NSData rep of our image in the  
Core Data store.


Modifying the code to use a IKImageBrowserPathRepresentationType  
gives working reordering but only an image path in the store.


It would seem that the browser view itself will not initiate a drag  
for a data representation.


Has anyone successfully overridden the IKImageBrowserView's dragging  
behaviour?


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.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: ***Junkmail*** How do I programaticly create a va_list

2009-01-13 Thread Jeff LaMarche
I can reinforce Bill's advice here. I tried to do this same thing  
once, fairly recently actually, so that I could subclass a Foundation  
class that had a variadic init method. I lost several hours of my time  
and a lot of my sanity trying to find a way to make it work before  
giving up.



On Jan 13, 2009, at 11:48 AM, Bill Bumgarner wrote:


On Jan 13, 2009, at 8:32 AM, Horst Jäger wrote:
I have a problem concerning the va_list. I don't know how to  
programaticly create one.


I need to do this because I want to use the initWithFormat method  
of NSString. But I neither know how many args there will be nor are  
the args Strings - they are selectors the associated methods of  
which return Strings.


... rest of excellent problem description deleted ...

In short, you don't want to do this.  Specifically, creating a  
vaargs list to be passed as a parameter to another method  
effectively requires encoding the arguments in whatever fashion the  
compiler would encode them.  It is highly architecture specific and  
is rife with really awesomely tedious details that are easy to screw  
up.


___

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

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

2009-01-13 Thread Kyle Sluder
On Tue, Jan 13, 2009 at 7:47 AM, Georg Seifert  wrote:
> But how I get hold of the open panel in a NSDocument app?

Again, *please* read the documentation.  The "The Roles of Key Objects
in Document-Based Applications" section of the Document-Based
Applications Overview guide describes who is responsible for the Open
panel--it's NSDocumentController:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Documents/Concepts/RolesOfDocObjects.html#//apple_ref/doc/uid/2025

--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: Getting the network Machine Icon

2009-01-13 Thread Sandro Noel

Well it's not that bad of a place to put it...
there is not way to know beforehand if the servers are going to be  
present
So it makes sense to ask the server what it is. when Bonjour declares  
it's presence.

or when the SMB server broadcasts.

The icons for every possible mac model are local to the computer, if  
you have a Mac.

/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/

I suspect that the icon in the reply from the FPGetSrvrInfo is useful  
for other platforms.
because with the model number, there is pretty much no more  
information needed to

associate an icon from the local resource.

The only problem I find it VERY complicated for such a simple feature.
to have to implement sockets UDP or TCP "have not gotten a reply yet".
Just to get an image to show up on screen :) is quite an overhead :)

Perhaps it would of been nice to add the model number of the machine  
to a NSNetService(Bonjour) TXT record.

Instead of having to uery the host directly. IMHO

I might be wrong, what do I know :)

Sandro Noel.

On 13-Jan-09, at 12:09 PM, I. Savant wrote:

On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel   
wrote:


The AFP client sends the FPGetSrvrInfo command to obtain server  
information.
The FPGetSrvrInfo command returns server information including the  
following
server parameters: server name, machine type, AFP version strings,  
UAM
strings, volume icon and mask, a bitmap of flags, and optionally, a  
list of
available Open Directory names. For descriptions of server  
parameters, see

FPGetSrvrInfo in the Reference section.



 Neat! That seems an odd place to put that functionality, but
hopefully it'll be better-placed when all that stuff is eventually
cocoa-ized. Thanks for the follow-up. Very informative.

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


dynamic resizing of a window

2009-01-13 Thread Ronnie B
Hi All.

I have a modal dialog that I want to resize dynamically in case if a
validation on an input field fails and I display a validation text bellow
the field.  I would like to 'push' the rest of the dialog down, leaving the
rest if the elements proportionally as they were.

Anyone can suggest a right way of doing it.

Thanks,
Ron.
___

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

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

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

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


Re: CoreData with OutlineView collapses items on fetch

2009-01-13 Thread Ron Lue-Sang

Hi Peter,
I only skimmed through your description/question, but I'm reasonable  
sure I know what you're asking and what the answer is.


The outlineView identifies its items by pointer comparison. So two  
objects that are logically the same can show up in the tree together,  
but they can have different expansion state associated with them. For  
an outlineView bound to a treeController, the outlineView's items are  
NSTreeNodes vended by the treeController.


If you start out with A containing B and its descendants C and D, and  
then refresh managedObject A, the treeController sees this


1) A no longer has child objects
2) A has a new set of child objects

The treeController will see step one and nuke the treeNodes associated  
with B, C and D, since they're gone now. Then when A has its  
childObjects relationship filled in again, the outlineView knows that  
the outlineView item for A needs to be reloaded, so it'll ask the  
treeController for item A's child items. These will be a new set of  
treeNodes, including B.


What's happening is the treeController doesn't know that old B will  
become new B later. So it returns a different NSTreeNode instance to  
the outlineView for its item. The outlineView sees the new instance  
and shows it collapsed by default.


If you know you're going to do an operation like this, you can hang on  
to the indexPath of the nodes you want to expand, and just re-expand  
them when the operation is over.


Hope that helps.

On Jan 13, 2009, at 2:33 AM, peter ljunglöf wrote:


Hi,

After upgrading to 10.5.6, I got a problem with NSOutlineView and  
NSTreeController in my CoreData application. When executing fetch:  
on the NSTreeController, deeply nested items (nesting level>=2)  
collapses in the NSOutlineView.


I created a minimal XCode project with the same problem, it can be  
downloaded from


http://heatherleaf.se/temp/OutlineBug.zip

Open in XCode (I've tried 3.1.1 and 3.1.2), compile and run. Create  
some nested items (double-click to rename the item), select the  
topmost item and then click the "Fetch" button. E.g., if I create  
the following items (where "v" is the expanded triangle and ">" is  
the collapsed triangle):


   +---+
   | v A   |
   |   v B |
   | v C   |
   | D |
   +---+

Select the A item, and the click "Fetch", I get the following result:

   +---+
   | v A   |
   |   > B |
   |   |
   |   |
   +---+

Depending on the nestings and which item is selected, the selection  
sometimes changes, and sometimes everything is deselected.


Also, none of the following delegate methods get called:
outlineView:shouldCollapseItem:
outlineViewItemWillCollapse:
outlineViewItemDidCollapse:

Does anyone know what the problem is and how I can avoid collapsing  
my outline views? I did not have this problem in 10.5.5.



The example project is really simple. I created a new CoreData  
Application project. Added one attribute "name" and two  
relationships "children" and "parent" (inverses) to the data model.  
I did not touch the code at all.


In IB, I added a NSTreeController, with I set to Entity mode,  
children key path "children" and fetch predicate "parent==nil".  
Bound the Managed Object Context to  
OutlineBug_AppDelegate.managedObjectContext.


Then I added a NSOutlineView with one column, and bound that  
column's Value to TreeController.arrangedObjects.name.
Finally I added three buttons: Fetch, Remove and Add Child, and  
bound their sent actions to the TreeController's fetch:, remove:,  
and addChild: methods.


That's all.

regards,
Peter Ljunglöf


PS. My original project is of course larger, and can be found at http://code.google.com/p/kronox/, 
 if someone's interested...


- - --- -- -- - - -  -  -- ---
peter ljunglöf (http://www.ling.gu.se/~peb)



___

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

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

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

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



--
RONZILLA



___

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

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

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

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


Re: runModalForWindow, best solution to modal session

2009-01-13 Thread Alexander Reichstadt

Hi Keary,

On 13.01.2009, at 19:44, Keary Suska wrote:



On Jan 13, 2009, at 10:44 AM, Alexander Reichstadt wrote:


Hi,

in my app I call runModalForWindow: in a class method initializer -- 
the class is a NSWindowController subclass-- from a controller of a  
sheet. Please, disregard UI Guidelines, it's a highly customized  
app and this approach used as per specific request.


+ (id)selectItem
{
	KSingleItemSelectorController *newSelector =  
[[KSingleItemSelectorController alloc]  
initWithWindowNibName:@"SingleItemSelector"];

(void)[newSelector window];
NSLog(@"The window is nil, see: %@",[newSelector window]);

[NSApp runModalForWindow:[newSelector window]];
id keepThis = newSelector.returnValue;
[newSelector release];
return keepThis;
}



Is the class of the File's Owner of the nib set to  
KSingleItemSelectorController


Yes.


and its window outlet set?


Yes

If so, do you override -initWithWindowNibName:? The implementation  
may matter.


No, I only override initWithWindow. Should I override it, and if so  
should I call on NSBundle to load my nib there then?


Alex

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

CoreData with OutlineView collapses items on fetch

2009-01-13 Thread peter ljunglöf

Hi,

After upgrading to 10.5.6, I got a problem with NSOutlineView and  
NSTreeController in my CoreData application. When executing fetch: on  
the NSTreeController, deeply nested items (nesting level>=2) collapses  
in the NSOutlineView.


I created a minimal XCode project with the same problem, it can be  
downloaded from


http://heatherleaf.se/temp/OutlineBug.zip

Open in XCode (I've tried 3.1.1 and 3.1.2), compile and run. Create  
some nested items (double-click to rename the item), select the  
topmost item and then click the "Fetch" button. E.g., if I create the  
following items (where "v" is the expanded triangle and ">" is the  
collapsed triangle):


+---+
| v A   |
|   v B |
| v C   |
| D |
+---+

Select the A item, and the click "Fetch", I get the following result:

+---+
| v A   |
|   > B |
|   |
|   |
+---+

Depending on the nestings and which item is selected, the selection  
sometimes changes, and sometimes everything is deselected.


Also, none of the following delegate methods get called:
outlineView:shouldCollapseItem:
outlineViewItemWillCollapse:
outlineViewItemDidCollapse:

Does anyone know what the problem is and how I can avoid collapsing my  
outline views? I did not have this problem in 10.5.5.



The example project is really simple. I created a new CoreData  
Application project. Added one attribute "name" and two relationships  
"children" and "parent" (inverses) to the data model. I did not touch  
the code at all.


In IB, I added a NSTreeController, with I set to Entity mode, children  
key path "children" and fetch predicate "parent==nil". Bound the  
Managed Object Context to OutlineBug_AppDelegate.managedObjectContext.


Then I added a NSOutlineView with one column, and bound that column's  
Value to TreeController.arrangedObjects.name.
Finally I added three buttons: Fetch, Remove and Add Child, and bound  
their sent actions to the TreeController's fetch:, remove:, and  
addChild: methods.


That's all.

regards,
Peter Ljunglöf


PS. My original project is of course larger, and can be found at http://code.google.com/p/kronox/ 
, if someone's interested...


- - --- -- -- - - -  -  -- ---
peter ljunglöf (http://www.ling.gu.se/~peb)



___

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

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

2009-01-13 Thread Keary Suska


On Jan 13, 2009, at 10:44 AM, Alexander Reichstadt wrote:


Hi,

in my app I call runModalForWindow: in a class method initializer -- 
the class is a NSWindowController subclass-- from a controller of a  
sheet. Please, disregard UI Guidelines, it's a highly customized app  
and this approach used as per specific request.


+ (id)selectItem
{
	KSingleItemSelectorController *newSelector =  
[[KSingleItemSelectorController alloc]  
initWithWindowNibName:@"SingleItemSelector"];

(void)[newSelector window];
NSLog(@"The window is nil, see: %@",[newSelector window]);

[NSApp runModalForWindow:[newSelector window]];
id keepThis = newSelector.returnValue;
[newSelector release];
return keepThis;
}



Is the class of the File's Owner of the nib set to  
KSingleItemSelectorController, and its window outlet set? If so, do  
you override -initWithWindowNibName:? The implementation may matter.


HTH,

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

___

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

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

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

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


Re: NSTextField input validation

2009-01-13 Thread Keary Suska


On Jan 13, 2009, at 10:32 AM, Adam Venturella wrote:

It is my understanding that, NSTextFieldCell gets the windows field  
editor
when the user goes to edit the cell's contents.  How I understood  
the docs
was that I need to override the cell's: setUpFieldEditorAttributes:  
as that
is the point at which the cell is getting the windows field editor.   
Once I
have that I can adjust it accordingly.  Or I can override the  
NSWindows's

windowWillReturnFieldEditor:toObject: to customize it there.
Is there a location, in IB or otherwise that lets me configure the  
Field

Editor outside of the above methods?


Well, the cell is asked to customize or replace the field editor, but  
the cell itself never "gets" the editor. The only purpose of the cell  
is to draw the UI on behalf of the NSTextField. Even the NSTextField  
doesn't know its editor--only the window does. The important thing is  
that the text editing system assigns the NSTextField (not the cell) as  
the delegate automatically. Changing this could have unintended  
consequences--especially difficult to track bugs. So, I wouldn't  
interfere with that.


It is probably better to subclass NSTextField instead, and implement  
the desired delegate method. I don't think the method you want is  
implemented, but you should check anyway, and if it is, you may want  
to call super's implementation.


On a different note, there may be a number of pitfalls. For instance,  
if you wish to allow any truly numeric value, vs. just digits. There  
may be also be some localization issues. Just FYI.


HTH,

On Tue, Jan 13, 2009 at 8:23 AM, Keary Suska >wrote:




On Jan 12, 2009, at 5:22 PM, Adam Venturella wrote:

So there we have it.  Again this does do exactly what I want it to  
do, if

the user tries to enter a letter or anything not a number, I get an
NSBeep(); It works if the operation is a paste operation or  
initiated by a

keystroke.

My main question, am I doing the right thing by casting the  
NSText  into a
NSTextView, and is the NumberFormatter the best way to go in order  
to test

for a valid number or should I go the NSScanner route?



Subclassing NSTextFieldCell seems a bit unnecessary--why not just  
set the

NSTextField delegate to one of your controllers? The whole
-setUpFieldEditorAttributes seems a bit kludgey to me (and possibly  
prone to

errors).

Also, I would use an NSCharacterSet (-characterIsMember:) instead of
NSFormatter or NSSCanner. Much more lightweight.



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

___

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

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

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

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


Re: Using UIImageView for animations

2009-01-13 Thread David Duncan

On Jan 12, 2009, at 8:10 PM, Glenn Bloom wrote:


- When I animate a set of PNG's rather than JPEG's (again using
UIImageView's animationImages property),  I am thinking I don't need  
to
think about compression (or Apple optimization)? Is it then  
appropriate to
think of the total memory to be consumed simply as an aggregate of  
the total

bytes for all the images?


Basically yes. The rule of thumb is Width * Height * 4 for each image.  
Images must be decompressed before display. The PNG optimization that  
Xcode applies converts the image to a format that is optimal for  
display, it doesn't reduce the amount of storage needed to display it.


- Am I correct in thinking that for loading a short-running  
animation, I
should generally use the initWithContentsOfFile method of UIImage  
instead of

imageNamed because imageNamed caches the data into memory?


Unless you can prove that you get better performance with +imageNamed:  
you should always prefer +imageWithContentsOfFile: or - 
initWithContentsOfFile:. This is especially true with large images  
(primarily because they consume lots of memory and are not reused  
often enough to gain a benefit).



- I had thought there was a way to use Instruments to assess if a
UIImageView animation was skipping frames.  Now, I'm not so sure.  Any
particular way to test if such an animation is skipping or not  
displaying

frames?



You can get an FPS meter from the Core Animation instrument. This may  
or may not be what you are thinking of.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


runModalForWindow, best solution to modal session

2009-01-13 Thread Alexander Reichstadt

Hi,

in my app I call runModalForWindow: in a class method initializer -- 
the class is a NSWindowController subclass-- from a controller of a  
sheet. Please, disregard UI Guidelines, it's a highly customized app  
and this approach used as per specific request.


+ (id)selectItem
{
	KSingleItemSelectorController *newSelector =  
[[KSingleItemSelectorController alloc]  
initWithWindowNibName:@"SingleItemSelector"];

(void)[newSelector window];
NSLog(@"The window is nil, see: %@",[newSelector window]);

[NSApp runModalForWindow:[newSelector window]];
id keepThis = newSelector.returnValue;
[newSelector release];
return keepThis;
}

As a result I am getting the following message:

2009-01-13 14:10:49.424 Secret[76477:10b] loading
2009-01-13 14:10:49.425 Secret[76477:10b] The window is nil, see: (null)
2009-01-13 14:10:49.438 Secret[76477:10b] *** Assertion failure in - 
[KApplication  
_commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo 
:], /SourceCache/AppKit/AppKit-949.35/AppKit.subproj/NSApplication.m: 
3031
2009-01-13 14:10:49.439 Secret[76477:10b] Modal session requires modal  
window


I read up on the different threads across the forums on this message  
to no avail, so I tried something different because I found no way so  
that my subclass would actually ever get its window, regardless how I  
initialized it.


In turn now, when I do the following everything works:

+ (id)selectItem
{
	KSingleItemSelectorController *newSelector =  
[[KSingleItemSelectorController alloc]  
initWithWindowNibName:@"SingleItemSelector"];
	NSWindowController *ersatz = [[NSWindowController alloc]  
initWithWindowNibName:@"SingleItemSelector"];

[ersatz loadWindow];

[newSelector setWindow:[ersatz window]];
[ersatz release];

[NSApp runModalForWindow:[newSelector window]];

id keepThis = newSelector.returnValue;
[newSelector release];  

return keepThis;
}


This second option is unacceptable but just for experimenting to  
understand where the source of the problem is. It suggests to me that  
there is no reason for the first approach not to work, given I  
excluded all other possible faults, like wrong subclass, no delegate  
or subclass assignment of File's owner and so forth.


Finally I found a third way:

+ (id)selectItem
{
	KSingleItemSelectorController *newSelector = [[self alloc]  
initWithWindowNibName:@"SingleItemSelector"];

[NSBundle loadNibNamed:[newSelector windowNibName] owner:newSelector];  
[NSApp runModalForWindow:[newSelector window]];

id keepThis = newSelector.returnValue;
[newSelector release];  

return keepThis;
}

This works, too. The question is why the initial way doesn't work and  
the second one does, where either both or none of both should work. I  
read through the documentation on Resource Programming Guide, but in  
the end found so many answers,I wonder which of all three is the  
correct one, or is there a fourth and they are all wrong?


Alex

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: NSTextField input validation

2009-01-13 Thread Adam Venturella
It is my understanding that, NSTextFieldCell gets the windows field editor
when the user goes to edit the cell's contents.  How I understood the docs
was that I need to override the cell's: setUpFieldEditorAttributes: as that
is the point at which the cell is getting the windows field editor.  Once I
have that I can adjust it accordingly.  Or I can override the NSWindows's
windowWillReturnFieldEditor:toObject: to customize it there.
Is there a location, in IB or otherwise that lets me configure the Field
Editor outside of the above methods?


On Tue, Jan 13, 2009 at 8:23 AM, Keary Suska wrote:

>
> On Jan 12, 2009, at 5:22 PM, Adam Venturella wrote:
>
>  So there we have it.  Again this does do exactly what I want it to do, if
>> the user tries to enter a letter or anything not a number, I get an
>> NSBeep(); It works if the operation is a paste operation or initiated by a
>> keystroke.
>>
>> My main question, am I doing the right thing by casting the NSText  into a
>> NSTextView, and is the NumberFormatter the best way to go in order to test
>> for a valid number or should I go the NSScanner route?
>>
>
> Subclassing NSTextFieldCell seems a bit unnecessary--why not just set the
> NSTextField delegate to one of your controllers? The whole
> -setUpFieldEditorAttributes seems a bit kludgey to me (and possibly prone to
> errors).
>
> Also, I would use an NSCharacterSet (-characterIsMember:) instead of
> NSFormatter or NSSCanner. Much more lightweight.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>
___

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

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

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

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


Re: CALayer removeFromSupeLayer crashes

2009-01-13 Thread Corbin Dunn


On Jan 9, 2009, at 12:19 PM, Dennis Christopher wrote:



I attach a base layer to a custom view as follows:

[view setWantsLayer:YES];

then I add several layers with:

CALayer *layer = [CALayer layer];
layer.name = @"test";
[view.layer addSublayer:layer];

the view draws and each layer draws thru the designated drawRect   
and drawLayer methods, and all this looks fine.


However, I have an action that removes all layers but this crashes on
removeFromSuperlayer:

NSArray *theLayers = [[self layer] sublayers];
 for(CALayer *layer in sublayers) {
   [layer removeFromSuperlayer];

I'm new to CALayer and at a loss as to what could be wrong with this.
Any suggestions would be appreciated.
(I've read  through most of Dudney's Core Animation book but nothing
jumps out at me.)


I highly recommend *always* adding a symbolic breakpoint on  
objc_exception_throw. It will help you debug issues like this faster.


corbin


___

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

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

2009-01-13 Thread I. Savant
On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel  wrote:

> The AFP client sends the FPGetSrvrInfo command to obtain server information.
> The FPGetSrvrInfo command returns server information including the following
> server parameters: server name, machine type, AFP version strings, UAM
> strings, volume icon and mask, a bitmap of flags, and optionally, a list of
> available Open Directory names. For descriptions of server parameters, see
> FPGetSrvrInfo in the Reference section.


  Neat! That seems an odd place to put that functionality, but
hopefully it'll be better-placed when all that stuff is eventually
cocoa-ized. Thanks for the follow-up. Very informative.

--
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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Chunk 1978
ok thank you all for your help... i'm now convinced this is a better
option than force quitting the finder

On Tue, Jan 13, 2009 at 11:54 AM, Mark Butler  wrote:
> Hi Chuck,
> hmm.. no this has no logic to deal with the finder being busy
> This is only making sure the the Finder exists before relaunching...
> I dont believe that tell app "Finder" to quit will return until it
> successfully does.
> If you expect there may be some finder things going on this will likely
> timeout.
> You could wrap the tell app finder to quit in something to deal with that.
>
> tell application "Finder"
> with timeout of 99 seconds
> quit
> end timeout
> end tell
>
> or
> repeat
> try
> tell application "Finder" to quit
> exit repeat
> end try
> delay 0.25
> end repeat
> Mark
>
> On Jan 13, 2009, at 8:43 AM, Chunk 1978 wrote:
>
> ok... so in this script it's basically assuring that if anything is
> using the finder or being copied, it will end so the finder will
> relaunch?  or is this script allowing finder processes to finish
> before the finder relaunch?
>
> On Tue, Jan 13, 2009 at 11:39 AM, Mark Butler  wrote:
>
> Sorry not quite that simple how about...
>
> tell application "Finder" to quit
>
> set theProcess to {}
>
> repeat
>
>   try
>
>   tell application "System Events" to tell application "Finder"
>
> to activate
>
>   end try
>
>   delay 0.25
>
>   tell application "System Events" to set theProcesses to name of every
>
> process
>
>   if theProcesses contains "Finder" then exit repeat
>
> end repeat
>
> Mark
>
> On Jan 13, 2009, at 4:56 AM, Chunk 1978 wrote:
>
> i found this on apple's website, but i'm not sure if this is what you
>
> are talking about when you say using an apple event to quit the
>
> finder.  also, based on the description of the code, it doesn't seem
>
> like this will automatically relaunch finder after it has been quit.
>
> OSErr QuitFinder()
>
> {
>
>  int kFinderProcessSignature = 'MACS';
>
>  OSErranErr = paramErr;
>
>  AppleEventtAppleEvent = {typeNull,nil};
>
>  AppleEvent  tReply;
>
>  AEBuildErrortAEBuildError;
>
>  anErr = AEBuildAppleEvent(
>
>  kCoreEventClass, kAEQuitApplication,
>
>  typeApplSignature, &kFinderProcessSignature,
>
>  sizeof(OSType), kAutoGenerateReturnID,
>
>  kAnyTransactionID, &tAppleEvent,
>
>  &tAEBuildError,"");
>
>  if (noErr == anErr)
>
>  {
>
>  anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
>
>kAENeverInteract, kAENormalPriority,
>
>kNoTimeOut, nil, nil );
>
>  (void) AEDisposeDesc(&tAppleEvent);
>
>  }
>
>  return anErr;
>
> }
>
>
> On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder 
>
> wrote:
>
> On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978  wrote:
>
> i have this code to relaunch the finder:
>
> Can't answer your question directly, but you should be sending Finder
>
> a Quit Apple Event, not killing it.  And even if you want to kill it,
>
> you should not be launching a task to do so.  And if you are going to
>
> launch a task to do it, you shouldn't be using "killall Finder" to do
>
> it.
>
> --Kyle Sluder
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
>
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> http://lists.apple.com/mailman/options/cocoa-dev/markusca%40mac.com
>
> This email sent to marku...@mac.com
>
>
>
>
___

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

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

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

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


Re: ***Junkmail*** How do I programaticly create a va_list

2009-01-13 Thread Bill Bumgarner

On Jan 13, 2009, at 8:32 AM, Horst Jäger wrote:
I have a problem concerning the va_list. I don't know how to  
programaticly create one.


I need to do this because I want to use the initWithFormat method of  
NSString. But I neither know how many args there will be nor are the  
args Strings - they are selectors the associated methods of which  
return Strings.


... rest of excellent problem description deleted ...

In short, you don't want to do this.  Specifically, creating a vaargs  
list to be passed as a parameter to another method effectively  
requires encoding the arguments in whatever fashion the compiler would  
encode them.  It is highly architecture specific and is rife with  
really awesomely tedious details that are easy to screw up.


On the system, the libffi API is available to assist with this.  It  
provides a bit of insulation from the ABI, but not much.


---

Unless you are going to do this particular operation a bazillion  
times, it would be far easier to collect the strings via normal  
methods and then concatenate them together however you need.


b.bum___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Mark Butler

Sorry not quite that simple how about...

tell application "Finder" to quit
set theProcess to {}
repeat
try
		tell application "System Events" to tell application "Finder" to  
activate

end try
delay 0.25
	tell application "System Events" to set theProcesses to name of every  
process

if theProcesses contains "Finder" then exit repeat
end repeat

Mark

On Jan 13, 2009, at 4:56 AM, Chunk 1978 wrote:


i found this on apple's website, but i'm not sure if this is what you
are talking about when you say using an apple event to quit the
finder.  also, based on the description of the code, it doesn't seem
like this will automatically relaunch finder after it has been quit.

OSErr QuitFinder()
{
   int kFinderProcessSignature = 'MACS';
   OSErranErr = paramErr;
   AppleEventtAppleEvent = {typeNull,nil};
   AppleEvent  tReply;
   AEBuildErrortAEBuildError;

   anErr = AEBuildAppleEvent(
   kCoreEventClass, kAEQuitApplication,
   typeApplSignature, &kFinderProcessSignature,
   sizeof(OSType), kAutoGenerateReturnID,
   kAnyTransactionID, &tAppleEvent,
   &tAEBuildError,"");

   if (noErr == anErr)
   {
   anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
 kAENeverInteract, kAENormalPriority,
 kNoTimeOut, nil, nil );

   (void) AEDisposeDesc(&tAppleEvent);
   }
   return anErr;
}


On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder   
wrote:
On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978   
wrote:

i have this code to relaunch the finder:


Can't answer your question directly, but you should be sending Finder
a Quit Apple Event, not killing it.  And even if you want to kill it,
you should not be launching a task to do so.  And if you are going to
launch a task to do it, you shouldn't be using "killall Finder" to do
it.

--Kyle Sluder


___

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

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

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

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


___

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

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

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

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


Re: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Chunk 1978
Repeat until exists process "Finder" is false?

i keep getting errors in applescript... can't get this right...

> You could use a repeat...
>
> Tell app "Finder" to quit
> Repeat until process "Finder" exists
>Tell app "finder" to activate
>Delay .25
> End
>
> I wrote this on an iphone so it's only close.
>
> Mark
>
>
>
> On Jan 13, 2009, at 8:11 AM, Chunk 1978  wrote:
>
>> ok... so i've decided to use a simple apple script for this:
>>
>> tell application "Finder"
>>   quit
>>   delay 0.25
>>   launch
>> end tell
>>
>> or this (which i believe is the same thing)
>>
>> tell application "Finder"
>>   quit
>>   delay 0.25
>>   activate application "Finder"
>> end tell
>>
>> but i'd like to know about the delay.  without the delay... in this
>> script the delay works to save the finder's window state and then to
>> relaunch the finder.  should i be concerned about this delay on older,
>> slower computers?  should it be longer?
>>
>> if i write it like this:
>>
>> tell application "Finder"
>>   quit
>>   activate application "Finder"
>> end tell
>>
>> i will receive "Finder got an error:  connection is invalid" the
>> second time i load the script.  is this because there was no delay for
>> the finder to save stuff before it was quit?
>>
>> On Tue, Jan 13, 2009 at 7:56 AM, Chunk 1978  wrote:
>>>
>>> i found this on apple's website, but i'm not sure if this is what you
>>> are talking about when you say using an apple event to quit the
>>> finder.  also, based on the description of the code, it doesn't seem
>>> like this will automatically relaunch finder after it has been quit.
>>>
>>> OSErr QuitFinder()
>>> {
>>>  int kFinderProcessSignature = 'MACS';
>>>  OSErranErr = paramErr;
>>>  AppleEventtAppleEvent = {typeNull,nil};
>>>  AppleEvent  tReply;
>>>  AEBuildErrortAEBuildError;
>>>
>>>  anErr = AEBuildAppleEvent(
>>>  kCoreEventClass, kAEQuitApplication,
>>>  typeApplSignature, &kFinderProcessSignature,
>>>  sizeof(OSType), kAutoGenerateReturnID,
>>>  kAnyTransactionID, &tAppleEvent,
>>>  &tAEBuildError,"");
>>>
>>>  if (noErr == anErr)
>>>  {
>>>  anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
>>>kAENeverInteract, kAENormalPriority,
>>>kNoTimeOut, nil, nil );
>>>
>>>  (void) AEDisposeDesc(&tAppleEvent);
>>>  }
>>>  return anErr;
>>> }
>>>
>>>
>>> On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder 
>>> wrote:

 On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978  wrote:
>
> i have this code to relaunch the finder:

 Can't answer your question directly, but you should be sending Finder
 a Quit Apple Event, not killing it.  And even if you want to kill it,
 you should not be launching a task to do so.  And if you are going to
 launch a task to do it, you shouldn't be using "killall Finder" to do
 it.

 --Kyle Sluder

>>>
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/markusca%40mac.com
>>
>> This email sent to marku...@mac.com
>
___

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

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

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

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


Re: Getting the network Machine Icon

2009-01-13 Thread Sandro Noel

Follow UP.

Here is what i got from the Carbon-dev list


I'd guess it just uses AFP to ask the server:

From :


The AFP client sends the FPGetSrvrInfo command to obtain server  
information. The FPGetSrvrInfo command returns server information  
including the following server parameters: server name, machine type,  
AFP version strings, UAM strings, volume icon and mask, a bitmap of  
flags, and optionally, a list of available Open Directory names. For  
descriptions of server parameters, see FPGetSrvrInfo in the Reference  
section.


I will post my code here as soon as i'm done, if this is the proper  
solution, it does makes sense.


regards

Sandro Noel.

On 12-Jan-09, at 2:01 PM, I. Savant wrote:

On Mon, Jan 12, 2009 at 1:52 PM, Sandro Noel   
wrote:



Thanks guy's i'll ask in the Carbon-dev list.


 Sorry - I didn't see the "remote" part of the requirement at first.
After spending some time searching the docs, tech notes, and even some
headers for this myself (because it's an intriguing question), I
couldn't find any good leads either. I'll second the suspicion that
Carbon will likely be needed, but there doesn't appear to be a
well-documented way to do so.

 If you wouldn't mind following up on this thread with any references
you might get on carbon-dev (for those who aren't subscribed), it
would be greatly appreciated.

--
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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Mark Butler

You could use a repeat...

Tell app "Finder" to quit
Repeat until process "Finder" exists
Tell app "finder" to activate
Delay .25
End

I wrote this on an iphone so it's only close.

Mark



On Jan 13, 2009, at 8:11 AM, Chunk 1978  wrote:


ok... so i've decided to use a simple apple script for this:

tell application "Finder"
   quit
   delay 0.25
   launch
end tell

or this (which i believe is the same thing)

tell application "Finder"
   quit
   delay 0.25
   activate application "Finder"
end tell

but i'd like to know about the delay.  without the delay... in this
script the delay works to save the finder's window state and then to
relaunch the finder.  should i be concerned about this delay on older,
slower computers?  should it be longer?

if i write it like this:

tell application "Finder"
   quit
   activate application "Finder"
end tell

i will receive "Finder got an error:  connection is invalid" the
second time i load the script.  is this because there was no delay for
the finder to save stuff before it was quit?

On Tue, Jan 13, 2009 at 7:56 AM, Chunk 1978   
wrote:

i found this on apple's website, but i'm not sure if this is what you
are talking about when you say using an apple event to quit the
finder.  also, based on the description of the code, it doesn't seem
like this will automatically relaunch finder after it has been quit.

OSErr QuitFinder()
{
  int kFinderProcessSignature = 'MACS';
  OSErranErr = paramErr;
  AppleEventtAppleEvent = {typeNull,nil};
  AppleEvent  tReply;
  AEBuildErrortAEBuildError;

  anErr = AEBuildAppleEvent(
  kCoreEventClass, kAEQuitApplication,
  typeApplSignature, &kFinderProcessSignature,
  sizeof(OSType), kAutoGenerateReturnID,
  kAnyTransactionID, &tAppleEvent,
  &tAEBuildError,"");

  if (noErr == anErr)
  {
  anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
kAENeverInteract, kAENormalPriority,
kNoTimeOut, nil, nil );

  (void) AEDisposeDesc(&tAppleEvent);
  }
  return anErr;
}


On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder  
 wrote:
On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978   
wrote:

i have this code to relaunch the finder:


Can't answer your question directly, but you should be sending  
Finder
a Quit Apple Event, not killing it.  And even if you want to kill  
it,
you should not be launching a task to do so.  And if you are going  
to
launch a task to do it, you shouldn't be using "killall Finder" to  
do

it.

--Kyle Sluder




___

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

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

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

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

___

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

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

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

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


***Junkmail*** How do I programaticly create a va_list

2009-01-13 Thread Horst Jäger



Hi,

I have a problem concerning the va_list. I don't know how to  
programaticly create one.


I need to do this because I want to use the initWithFormat method of  
NSString. But I neither know how many args there will be nor are the  
args Strings - they are selectors the associated methods of which  
return Strings.




Suppose the initWithFormat method of NSString worked with an array  
instead of a va_list (Syntax: - (id)initWithFormat:(NSString *)format  
arguments: (NSArray *)args)


Then I could convert the array of selectors into an array of NSStrings  
and my function would look like this:


(NSString *)formattedTextForClass: (Class)targetClass:  
withFormat(NSString *)format withArguments: (NSArray *)selectors{


// do the conversion

NSMutableArray results = [[NSMutableArray alloc] init];
for(int iter = 0; iter < [selectors count]; ++iter){
SEL selector = [selectors objectAtIndex: iter];
NSString *result = [targetClass performSelector: selector];
[results addObject: result];
}

// use the converted list
// unfortunately it doesn't work like this

	NSString *retval = [[NSString alloc] initWithFormat: format	 
withArguments: results];


[results release];  
return retval;

}

But the initWithFormat method of NSString works with a va_list instead  
of an array. So - if I knew how to do the converison in the va_list -  
my function would look (at least a little) like this:


(NSString *)formattedTextForClass: (Class)targetClass:  
withFormat(NSString *)format withArguments: (va_list)selectors{


// do the conversion
// unfortunately I don't know how to do that

va_list results = [self somehow_get_the_converted_va_list: selectors];

// use the converted list

	NSString *retval = [[NSString alloc] initWithFormat: format	 
withArguments: results];


[results release];  
return retval;

}

And I would call it like this:

NSString *myFormattedText = [MyFormatter formattedTextForClass:  
[SomeClass class], @selector(firstSelector),  
@selector(secondSelector), @selector(thirdSelector), nil];



Any help would be very much appreciated. Thanks in advance!

Horst

___

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

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

2009-01-13 Thread Keary Suska


On Jan 12, 2009, at 5:22 PM, Adam Venturella wrote:

So there we have it.  Again this does do exactly what I want it to  
do, if

the user tries to enter a letter or anything not a number, I get an
NSBeep(); It works if the operation is a paste operation or  
initiated by a

keystroke.

My main question, am I doing the right thing by casting the NSText   
into a
NSTextView, and is the NumberFormatter the best way to go in order  
to test

for a valid number or should I go the NSScanner route?


Subclassing NSTextFieldCell seems a bit unnecessary--why not just set  
the NSTextField delegate to one of your controllers? The whole - 
setUpFieldEditorAttributes seems a bit kludgey to me (and possibly  
prone to errors).


Also, I would use an NSCharacterSet (-characterIsMember:) instead of  
NSFormatter or NSSCanner. Much more lightweight.


HTH,

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

___

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

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

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

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


Re: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Chunk 1978
ok... so i've decided to use a simple apple script for this:

tell application "Finder"
quit
delay 0.25
launch
end tell

or this (which i believe is the same thing)

tell application "Finder"
quit
delay 0.25
activate application "Finder"
end tell

but i'd like to know about the delay.  without the delay... in this
script the delay works to save the finder's window state and then to
relaunch the finder.  should i be concerned about this delay on older,
slower computers?  should it be longer?

if i write it like this:

tell application "Finder"
quit
activate application "Finder"
end tell

i will receive "Finder got an error:  connection is invalid" the
second time i load the script.  is this because there was no delay for
the finder to save stuff before it was quit?

On Tue, Jan 13, 2009 at 7:56 AM, Chunk 1978  wrote:
> i found this on apple's website, but i'm not sure if this is what you
> are talking about when you say using an apple event to quit the
> finder.  also, based on the description of the code, it doesn't seem
> like this will automatically relaunch finder after it has been quit.
>
> OSErr QuitFinder()
> {
>int kFinderProcessSignature = 'MACS';
>OSErranErr = paramErr;
>AppleEventtAppleEvent = {typeNull,nil};
>AppleEvent  tReply;
>AEBuildErrortAEBuildError;
>
>anErr = AEBuildAppleEvent(
>kCoreEventClass, kAEQuitApplication,
>typeApplSignature, &kFinderProcessSignature,
>sizeof(OSType), kAutoGenerateReturnID,
>kAnyTransactionID, &tAppleEvent,
>&tAEBuildError,"");
>
>if (noErr == anErr)
>{
>anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
>  kAENeverInteract, kAENormalPriority,
>  kNoTimeOut, nil, nil );
>
>(void) AEDisposeDesc(&tAppleEvent);
>}
>return anErr;
> }
>
>
> On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder  wrote:
>> On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978  wrote:
>>> i have this code to relaunch the finder:
>>
>> Can't answer your question directly, but you should be sending Finder
>> a Quit Apple Event, not killing it.  And even if you want to kill it,
>> you should not be launching a task to do so.  And if you are going to
>> launch a task to do it, you shouldn't be using "killall Finder" to do
>> it.
>>
>> --Kyle Sluder
>>
>
___

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

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

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

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


Re: White background when NSButton is pressed

2009-01-13 Thread glenn andreas


On Jan 13, 2009, at 8:03 AM, Jonathan Selander wrote:


Hi,

Im using alpha-transparent PNGs on NSButtons to build a part of my  
interface. It looks good, but when a button is pressed, a square  
white background fills the button. Is there a way to get rid of this  
in IB? I've been toying with almost every option so far with no luck.



Assuming you mean that the PNG represents everything you want to be  
displayed (i.e., no frame or background gradient from the button), try:


Style: Bevel or Square
Mode: Momentary Change
Border: Off
Selected: Off
Transparent: Off
Mixed: Off



Glenn Andreas  gandr...@gandreas.com
  wicked fun!
Dominogy | Just place all the dominos on the board...

___

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

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


IKImageBrowserView drag and drop/reordering when using core data

2009-01-13 Thread jonat...@mugginsoft.com
I have been utilising the IKImageBrowserViewWithCoreData Apple sample  
code and wished to add drag and drop and reordering functionality.

Another Apple sample project, image-browser, covers most of the detail.

My problem is the following:

Drag and drop from say the finder works okay (if one can figure out  
that setting IKImageBrowserView -draggingDestinationDelegate seems  
broken in IB).

Reordering within the view itself, however, fails.

By experimentation I have determined that this is because our image  
representation (as per the IKImageBrowserItem informal protocol) is  
IKImageBrowserNSDataRepresentationType.
In other words, we are storing an NSData rep of our image in the Core  
Data store.


Modifying the code to use a IKImageBrowserPathRepresentationType gives  
working reordering but only an image path in the store.


It would seem that the browser view itself will not initiate a drag  
for a data representation.


Has anyone successfully overridden the IKImageBrowserView's dragging  
behaviour?


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.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: Mac Pro memory sizes

2009-01-13 Thread julius

My thanks to all who replied to my query.
Let me see if I can correctly summarise your advice.

All references to Mac memory as GB or MB refer to standard 8 bit bytes.

Mac 64-bit computing relates to the size of pointers into the address  
space and a number of native data types such as NSInteger, NSUInteger  
and CGFloat.


When working in a 64-bit architecture there is no need to stop using  
standard c types such as char, int, float etc. These do not expand to  
fill 64-bit space but retain their accepted sizes. If one wants to be  
specific about the actual size of a type then use the types specified  
in the International Standard ISO/IEC9899 :

http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
For instance, quote: "The typedef name intN_t designates a signed  
integer type with width N, nopadding bits, and a two’s complement  
representation. Thus, int8_t denotes a signed integer type with a  
width of exactly 8 bits. "


One can discover the sizes of NSInteger, NSUInteger from the constants  
NSIntegerMin, NSIntegerMax, and NSUIntegerMax.


It is a good idea to use NSInteger/NSUInteger and CGFloat for  
parameters, and local variables.
It is also good normally to use NSInteger etc and not worry unless  
working with large numbers of small integers that need to be packed  
into as little memory as possible.


Also re the transition from X86 to X86-64:
The number of registers were doubled, and the calling conventions were  
changed so that 80% of the time function/method  arguments are stored  
in CPU registers instead of being placed in a  four-byte-aligned  
position on the stack. And that 20% of cases only happen when you pass  
in a structure larger than 128 bits, or pass in  an unaligned  
structure, or have a function that takes more than 6  arguments.
(Thus..) a program ported from X86 to X86-64 will run just slightly  
faster, especially if the program passes around a lot of 64- bit  
arguments.


I was glad to have my confusion about GC corrected, vis. in the  
context of GC one need only concern oneself with how the pointers are  
defined, e.g. only to use __strong as pointer to standard c types  
rather than as I was doing: scattering __strongs amongst all my chars  
and ints. Clearly I need to get out more.


I had not come accross the following bit of documentation:
http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/intro/chapter_1_section_1.html

I'd been using
http://developer.apple.com/documentation/Cocoa/Conceptual/Cocoa64BitGuide/Introduction/chapter_1_section_1.html#/ 
/apple_ref/doc/uid/TP40004247-CH1-DontLinkElementID_26

and not seen the link to the preceding at the bottom of the page.

It is also a good idea to revisit Memory Usage Performance Guidelines
http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/ManagingMemory.html

Runtime libraries use a lot of address space so "needing an address  
space of more than 4GB" translates very roughly to "need to manipulate  
more than about 2GB of data".


A useful optimisation technique is to do pointer arithmetic manually  
rather than rely on built-ins and standard structures. If one is  
working in different size architectures then use sizeof to get the  
correct sizes for pointer arithmetic.


Finally I was advised to avoid premature optimisation and bit packing.

So my thanks to you all.
I return to the fray with mind much eased.
Thanks again
Julius


http://juliuspaintings.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


Information request on QT streaming

2009-01-13 Thread Arnab Ganguly
Hi All,
My query is streaming from the playlist file that we get from
shoutcast.com.If we open the playlist file in text edit  format is going to
be the below

numberofentries=21
File1=http://scfire-mtc-aa04.stream.aol.com:80/stream/1074
Title1=(#1 - 119/900) .977 The Hitz Channel
Length1=-1
File2=http://scfire-dtc-aa03.stream.aol.com:80/stream/1074
Title2=(#2 - 123/900) .977 The Hitz Channel
Length2=-1
File3=http://scfire-ntc-aa10.stream.aol.com:80/stream/1074
Title3=(#3 - 123/900) .977 The Hitz Channel
Length3=-1


Now in the winamp/vlc player if I try to open the url
http://scfire-mtc-aa04.stream.aol.com:80/stream/1074it
works perfectly ie i am able to stream and listen to the music.Same if
we
try out with Quick Time player it gives invalid url when we try to open it
thorugh Quick Time but if I try to open the pls file it streams correctly.

Is there any syntactical mistake I am doing while giving the url or what
would be the conventional method need to be followed ? Thanks in advance.
-A
___

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

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

2009-01-13 Thread Jean-Daniel Dupas


http://www.cocoabuilder.com/archive/message/cocoa/2008/5/14/206531


Le 13 janv. 09 à 15:01, Jonathan Selander a écrit :


Cool, seems like I'm on the right track with these functions :)

Now I just need to figure out how to resize the main contentView to  
the desktop resolution and to make the background image i put scale  
up to the resolution. For the window size i tried this:


screenRect = [[NSScreen mainScreen] frame];
NSLog(@"w: %f, h: %f", screenRect.size.width, screenRect.size.height);

[contentWindow setContentSize:screenRect.size];

Which indeed scales the window to the correct resolution, but the  
window bar is still present, and the window isn't positioned  
correctly. To position it, i tried:


[contentWindow setFrameTopLeftPoint:screenRect.origin];

I logged the origin values first and noticed they where both 0.0,  
which seems as it should be?


Thanks



12 jan 2009 kl. 21.07 skrev Chunk 1978:


personally i've used Carbon for this, but i'm not sure if it's the
most standardized way of attaining full screen.  check out:
SetSystemUIMode(kUIModeAllHidden, 0); and
SetSystemUIMode(kUIModeAllSuppressed, 0);


On Mon, Jan 12, 2009 at 12:21 PM, Jean-Daniel Dupas
 wrote:

Le 12 janv. 09 à 18:08, Jonathan Selander a écrit :


Hi,

Is there way to make the whole main windows with all its contents
(including a quartz composition) go full screen, and perhaps even  
scale? If

so, how?

Thanks


See the archives for a bunch of solutions, and pro and cons for  
each one.


http://www.cocoabuilder.com/search/archive/cocoa?words=fullscreen



___

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

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

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

This email sent to chunk1...@gmail.com


___

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

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

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

This email sent to jonat...@trodon.se


___

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

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

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

This email sent to devli...@shadowlab.org



___

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

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

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

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


How to center a custom NSView in a NSScrollView

2009-01-13 Thread Meik Schuetz

Dear all,
I've already tried with a custom NSClipView, as explained here:

http://www.bergdesign.com/missing_cocoa_docs/nsclipview.html

I also tried setting the height/width of the custom NSView to the size  
of the NSScrollView, but somehow I do not get it to work correctly.


The question is, how can I center a custom NSView in a NSScrollView,  
if the visible width and/or height is greater than the fixed size of  
the NSScrollView?


Thanks a lot for any hint.
Best regards
Meik

___

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

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


White background when NSButton is pressed

2009-01-13 Thread Jonathan Selander

Hi,

Im using alpha-transparent PNGs on NSButtons to build a part of my  
interface. It looks good, but when a button is pressed, a square white  
background fills the button. Is there a way to get rid of this in IB?  
I've been toying with almost every option so far with no luck.


Thanks
___

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

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

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

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


Re: Make the whole view go full screen

2009-01-13 Thread Jonathan Selander

Cool, seems like I'm on the right track with these functions :)

Now I just need to figure out how to resize the main contentView to  
the desktop resolution and to make the background image i put scale up  
to the resolution. For the window size i tried this:


screenRect = [[NSScreen mainScreen] frame];
NSLog(@"w: %f, h: %f", screenRect.size.width, screenRect.size.height);

[contentWindow setContentSize:screenRect.size];

Which indeed scales the window to the correct resolution, but the  
window bar is still present, and the window isn't positioned  
correctly. To position it, i tried:


[contentWindow setFrameTopLeftPoint:screenRect.origin];

I logged the origin values first and noticed they where both 0.0,  
which seems as it should be?


Thanks



12 jan 2009 kl. 21.07 skrev Chunk 1978:


personally i've used Carbon for this, but i'm not sure if it's the
most standardized way of attaining full screen.  check out:
SetSystemUIMode(kUIModeAllHidden, 0); and
SetSystemUIMode(kUIModeAllSuppressed, 0);


On Mon, Jan 12, 2009 at 12:21 PM, Jean-Daniel Dupas
 wrote:

Le 12 janv. 09 à 18:08, Jonathan Selander a écrit :


Hi,

Is there way to make the whole main windows with all its contents
(including a quartz composition) go full screen, and perhaps even  
scale? If

so, how?

Thanks


See the archives for a bunch of solutions, and pro and cons for  
each one.


http://www.cocoabuilder.com/search/archive/cocoa?words=fullscreen



___

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

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

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


This email sent to chunk1...@gmail.com


___

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

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

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

This email sent to jonat...@trodon.se


___

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

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

2009-01-13 Thread Dennis Christopher

Matt,

Thanks for this reply. I will reply back to the list once I get this  
solved so others can benefit from it.


updateRemovedSublayer is however CALayer's not mine. I have no need to  
access individual layers, if it is ok just to call  [[self layer]  
setSublayers:nil], as Dave Duncan suggested.


Dennis
On Jan 12, 2009, at 9:25 PM, Matt Long wrote:


Dennis,

If any of your layers are autoreleased and not explicitly retained, if
you try to access them again, you will get a crash. Can you show us
what your functions such as updateRemovedSublayer look like (I'm
assuming that's yours)? If you are calling [CALayer setSublayers:nil]
and then try to access one of the layers that was in the previous
array, it will crash as they have been released. If you allocate your
layers with alloc init, you will still have a reference to the layer.
Then, when it is removed from the parent layer, you can still access
it. On the other side of that, though, you will need to explicitly
release the object when you are done.

Best regards,

-Matt



On Jan 12, 2009, at 1:57 PM, Dennis Christopher wrote:


Dave,

Thanks for the pointer. I had corrected the original array
enumeration error, and forgotten. But no matter how I try to access
a sublayer I seem to have a problem.

When I now try your suggestion I still get a crash. The call stack
shows, in order of execution:

[CALayer setSublayers:]
CALayerUpdateSublayers
updateRemovedSublayer
CALayerMarkVisible
.
.
objc_msgSend (EXC_BAD_ACCESS)

Can you suggest what might be wrong?

Dennis Christopher
On Jan 10, 2009, at 12:43 PM, David Duncan wrote:


On Jan 9, 2009, at 12:19 PM, Dennis Christopher wrote:


NSArray *theLayers = [[self layer] sublayers];
for(CALayer *layer in sublayers) {
[layer removeFromSuperlayer];

I'm new to CALayer and at a loss as to what could be wrong with
this.
Any suggestions would be appreciated.
(I've read  through most of Dudney's Core Animation book but  
nothing

jumps out at me.)



I would suspect that you'd see a message on the console to the  
effect
of "modifying an array while enumerating it". I think you can  
replace

this more simply by just doing [[self layer] setSublayers:nil].
--
David Duncan
Apple DTS Animation and Printing



___

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

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

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

This email sent to matt.l...@matthew-long.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: Mac Pro memory sizes

2009-01-13 Thread julius

Keit hi,
On 12 Jan 2009, at 22:51, Schultz Keith J. wrote:


Hi Julius,

If I understand your problem correctly you are:
1) processing a very large amount of intergers
2) using highly optimized code that is:
a) you are manipulating the data directly via pointers
b) the data in memory is expected to be in a specific
  order/structure
c) the data is stored on disk in pure binary form
  that is the same format as in memory

That's about right.
I'm creating a painting system that I want eventually to make use of  
all the available pixels on large display panels, e.g. 1600 x 1000  
pixel resolution. The shape and contents of each brushstroke change  
over time and the contents themselves are complex, e.g. random  
patterns. Effectively there is very little redundancy both in each  
frame and in any image sequence. I don't know all the problems that  
trying to pump images of this size at say 15 or 25 fps onto the screen  
will entail so I'm adopting a gradualistic approach to program  
development. If I can, I want to anticipate difficulties sufficient to  
at least maintaining a stable overall program structure.


However, pushing this data out onto the screen is not the main  
problem. The main problem is that I need to have the picture with all  
its dynamics displayed as I am painting and that I want to keep my  
options when painting reasonably open, for instance to have the  
ability to edit stroke shape variation and colour variation after it  
has been painted. Essentially colour variation can be thought of as a  
movie. A very simple (13Mb) early example may be seen here:

http://animatedpaint.co.uk/nestaMovies/pearCity4Half.mpg.
Without going into details, I need to use lots of data, there's a fair  
bit of disk I/O and processing. With every increase in manipulative  
freedom and image complexity comes a corresponding increase in the  
data and processing requirement



Several years back I had optimized the code of a C program and  
gained a
speed bump by the factor of 100 by doing the above and doing the  
pointer
arithmatic by hand for accessing the data in the structure instead  
of using

builtins and standard structures.
Yes, this can be a very good way to go however I was getting a bit  
scared off by my lack of familiarity in using GC on malloc'd data,  
which I'm over now, in fact no problem, but working by oneself with no  
one to  discuss the simplest of things can blow anxieties up from  
molehills to veritable everests.



So you do not need to worry about the size of your data just how you  
access it,
I had to have the program work on different architectures with  
different word sizes.
The inital data where in text for so the conversion to integer was  
easy. The trick was
to use the sizeof function to get the correct values for the pointer  
math.

Right I'll pay attention to these



Far as stuffing two 32-bit values into a 64-bit value to avoid  
possible context
switching is probaly a very bad trade off as the handling to such  
values and doing
any kind of math with will hurt you badly speed wise with no space  
savings.
yes, which is why earlier advice I received on using standard c types  
has been a big  relief to me.



Of course if you can do the math with bitwise operation directly you  
could process
two integers at one time. But, I do not know exactly what you are up  
to.


Hope this helps.

Keith.



Yes thanks loadsa.
Essentially everything I'm doing is very simple. It is just that  
there's an awful lot of data and it could all become very complex  
indeed if I didn't continually struggle to stop it going that way.


best wishes
Julius

http://juliuspaintings.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: Killall Finder Brings Hidden Apps To Front?

2009-01-13 Thread Chunk 1978
i found this on apple's website, but i'm not sure if this is what you
are talking about when you say using an apple event to quit the
finder.  also, based on the description of the code, it doesn't seem
like this will automatically relaunch finder after it has been quit.

OSErr QuitFinder()
{
int kFinderProcessSignature = 'MACS';
OSErranErr = paramErr;
AppleEventtAppleEvent = {typeNull,nil};
AppleEvent  tReply;
AEBuildErrortAEBuildError;

anErr = AEBuildAppleEvent(
kCoreEventClass, kAEQuitApplication,
typeApplSignature, &kFinderProcessSignature,
sizeof(OSType), kAutoGenerateReturnID,
kAnyTransactionID, &tAppleEvent,
&tAEBuildError,"");

if (noErr == anErr)
{
anErr = AESend( &tAppleEvent, &tReply, kAENoReply |
  kAENeverInteract, kAENormalPriority,
  kNoTimeOut, nil, nil );

(void) AEDisposeDesc(&tAppleEvent);
}
return anErr;
}


On Tue, Jan 13, 2009 at 1:16 AM, Kyle Sluder  wrote:
> On Tue, Jan 13, 2009 at 1:04 AM, Chunk 1978  wrote:
>> i have this code to relaunch the finder:
>
> Can't answer your question directly, but you should be sending Finder
> a Quit Apple Event, not killing it.  And even if you want to kill it,
> you should not be launching a task to do so.  And if you are going to
> launch a task to do it, you shouldn't be using "killall Finder" to do
> it.
>
> --Kyle Sluder
>
___

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

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

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

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


Re: NSImage resizing

2009-01-13 Thread Heinrich Giesen


On 09.01.2009, at 15:11, Parimal Das wrote:


in my application i need to resize a .jpg image through a command line



What does it mean: "resize" ?. Every NSBitmapImageRep has two sizes:
a (print-)size which says how long width and hight (expressed in  
inch, cm or printerpoints or ...)
of the depicted (printed) image are. This value can be set (changed)  
with -setSize:.
And it has a (storage-)size which says how many pixel the image has  
expressed as a dimensionless number.
The connection between these two "sizes" is the "resolution".  
Changing the pixelnumbers results

in a rendering process.

Next point: An icon (NSImage) is a container of several  
NSBitmapImageReps. You have to select

the one that fits best.

That lets me make a proposal which is close to your first try:

   NSImage *icon = [[NSWorkspace sharedWorkspace]  
iconForFile:filePath];		
   NSSize imageSize = { 384.0, 384.0 }; // in points (384 pts = 512  
px at 96 dpi resolution)


   [icon setSize:imageSize];
   NSBitmapImageRep *bitmapImageRep = (NSBitmapImageRep *)[icon  
bestRepresentationForDevice:nil];

   [bitmapImageRep setSize:imageSize];  // <--- do not forget !!!
   [[bitmapImageRep representationUsingType:NSJPEGFileType  
properties:nil]

   writeToFile:destPath
atomically:YES];




--
Heinrich Giesen
gies...@acm.org


___

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

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

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

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


Re: Implementing an Inspector similar to the one in IB.

2009-01-13 Thread Brian Bruinewoud
Just to clarify, I mean the exposable areas below that can be shrunk  
to a heading or expanded to full. The link that Brandon posted is  
exactly what I'm after.


So, thanks everyone for the reply.

On 12/01/2009, at 20:59 , Kyle Sluder wrote:

On Sun, Jan 11, 2009 at 3:20 AM, Brian Bruinewoud  
 wrote:
I would like to implement an inspector that has views that show/ 
hide by
clicking on their headings similar to the ones in the Interface  
Builder

inspector.


Are you talking about the row of buttons at the top that changes the
contents of the panel (like the similar Inspector in iWork apps)?  If
so, you can use a tabless NSTabView and a NSSegmentedControl, though
it won't look quite the same (NSSegmentedControl highlights its
selection in gray, not blue, rdar://5918481).  Set a different tag for
each segment of the NSSegmentedControl, and wire up the action of the
control to a method on your window controller that switches the
selected tab in the NSTabView accordingly.

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


[MEET] Amsterdam CocoaHeads, Wed Jan 14

2009-01-13 Thread Cathy Shive

Hello Cocoa developers in and near Amsterdam!

The Amsterdam chapter of CocoaHeads will be meeting again this  
Wednesday (tomorrow), January 14 from 7-9PM.


Information about the location and presentation can be found on our  
Google Groups page:


http://groups.google.com/group/cocoaheads-amsterdam

See you there!

Cathy
___

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

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


Meeting CocoaHeads Amsterdam Jan-14.

2009-01-13 Thread macdev
The CocoaHeads Amsterdam is gathering tomorrow (January 14th 2009). 

Johan Kool will give a presentation about finding (potential) bugs in your
code using LLVM/Clang.

 

For more information: www.cocoaheads.nl, and

http://groups.google.com/group/cocoaheads-amsterdam?pli=1

 

 

 

 

 

 

___

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

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

2009-01-13 Thread Kyle Sluder
On Tue, Jan 13, 2009 at 4:54 AM, Georg Seifert  wrote:
> I want to be able to select folders (with a certain extension, but no
> registered file type) in the open dialog of a NSDocument app.

Did you look at the documentation?  -[NSOpenPanel
setCanChooseDirectories] looks like it would be a very logical place
to start.  And then the -panel:shouldShowFilename: NSSavePanel
delegate method would make a whole lot of sense, since it's mentioned
in the "Filtering Out Browser Items" section of the "Application File
Management" document...

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/AppFileMgmt/Articles/FilteringOutBrowserItems.html

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


File association

2009-01-13 Thread Mahaboob
I saved the project using NSArchiver with an extension say .myExtension. And
also I opened the saved project by unachieved it from menu. Now I need to
open the saved project when double clicking on it.

How can I do this file association?
Where I need to write code for unarchiving its content ?

Thanks in advance
mahaboob


___

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

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


open folders as documents

2009-01-13 Thread Georg Seifert

hello,

I want to be able to select folders (with a certain extension, but no  
registered file type) in the open dialog of a NSDocument app.


- Is there a possibility to register a filetype without loosing the  
ability to see the content in the finder (without selecting "show  
content")?

- or can I tell the open dialog to accept folders?


Thanks
Georg
___

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

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


[SOLVED]: Sync problems with NSArrayController + NSSortDescriptor + NSTextField

2009-01-13 Thread Dado Colussi
It turned out that I had checked the Auto Rearranges Content in IB for  
my NSArrayController instance. When I turned it off, and sent - 
rearrangeObjects to the NSArrayController in - 
controlTextDidEndEditing: in the NSTextField's delegate, everything  
started working as expected.


It seems that Auto Rearranges Content is broken.

/Dado


On Jan 11, 2009, at 6:54 PM, Dado Colussi wrote:


Hello,


*** A short description of the problem ***

NSTextField that is bound to NSArrayController's  
'selection.attribute' such that the attribute is part of the  
NSArrayController's sort descriptors gets out of sync when modified.



*** A longer description of the problem ***

I have an NSTableView with a single column bound to an  
NSArrayController that manages an entity in an XML Core Data  
storage. I have programmatically added one NSSortDescriptor to the  
array controller for attribute 'name'. I have bound the table's  
'content' and 'selectionIndexes' to the array controller, and left  
the 'sortDescriptors' unbound. From mmalc's controller examples I  
understand that this prevents the user from manipulating the sort  
descriptors when interacting with the table.


In my detail view, I have an NSTextField that is has its 'value'  
bound to the array controller's 'selection.name'. I also have other  
text fields bound to other attributes in the array controller,  
essentially to attributes that are not part of the sort descriptor.


When I modify the text field for attribute 'name' and press enter,  
the value in the table view changes, and the item gets sorted  
properly. However, the text field reverts to the previous value, as  
if I had not changed it, and I lose focus on the text field.  
Changing selection in the table refreshes the text field back to  
sanity. For the sake of curiosity, I added another NSTextField and  
bound it to the same attribute 'name'. I discovered that the problem  
occurs only with the text field that is edited. The non-edited text  
field is updated correctly. I also tried removing the table  
entirely, and it did not help.


I have tried 10.5 and 10.4 SDK's on Leopard, and both show the same  
problem. Running the binary on Tiger, or building it from source  
code on Tiger, does not produce the problem, but then the array  
controller does not sort automatically. In Tiger, I can get around  
this problem by sending -rearrangeObjects to the array controller in  
the text field's delegate's -controlTextDidEndEditing: method.


Can someone explain me what is going on and how to get around this  
on Leopard?


Thanks!

/Dado



___

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

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

2009-01-13 Thread Parimal Das
hi

whenever i am running this through the command line, my app is crashing with
the error "GraphicsConetext not init"
my code crashes at the call of [lock focus]i am not creating any view till
now
So can i do it without lock/unlock focus and without view
and if not then is it possible to create a hidden view from command line so
the user wont get any wind that the view was called ..

Advanced Thanx ppl
-Parimal

On Fri, Jan 9, 2009 at 10:25 PM, Steve Christensen  wrote:

> For a bitmap image, -setSize: effectively alters the DPI of the pixels but
> doesn't actually create a new bitmap of a different size. So for a 72dpi
> image, the NSBitmapImageRep's -width and -height methods should give you the
> same values as for the image's -size method. But for a 300dpi image, for
> example, you'd expect the -width and -height values to be about 4x larger
> than the -size value.
>
> Maybe something like this would do what you want?
>
> NSImage* originalIcon = [[NSWorkspace sharedWorkspace]
> iconForFile:filePath];
> NSRect resizedBounds = NSMakeRect(0, 0, 384, 384);
> NSImage* resizedIcon = [[[NSImage alloc] resizedBounds.size] autorelease];
>
> [resizedIcon lockFocus];
> [originalIcon drawInRect:resizedBounds fromRect:NSZeroRect
> operation:NSCompositeCopy fraction:1.0];
> [resizedIcon unlockFocus];
>
> NSBitmapImageRep* bitmapImage = [[resizedIcon representations]
> objectAtIndex:0];
> [[bitmapImage representationUsingType:NSJPEGFileType properties:dict]
> writeToFile:destPath atomically:YES];
>
> Probably safer to iterate the representation(s) and actually add a check to
> see that bitmapImage really is one before actually using it, just in case
> another representation is created.
>
> steve
>
>
>
> On Jan 9, 2009, at 5:50 AM, Parimal Das wrote:
>
>  hi
>> in my application i need to resize a .jpg image through a command line
>>
>> my code is
>>
>> NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:filePath]; //
>> get
>> icon from the file at filePath destination
>>
>> NSSize imageSize;
>>
>> imageSize.width = 384.0;  // in points (384 pts = 512 px )
>>
>> imageSize.height = 384.0;
>>
>>
>> [icon setSize:imageSize]; // set image size
>>
>>
>> NSData  * tiffData = [icon TIFFRepresentation];
>>
>> bitmapImageRep = [NSBitmapImageRep imageRepWithData:tiffData];
>>
>> [[bitmapImageRep representationUsingType:NSJPEGFileType properties:dict]
>> writeToFile:destPath atomically:YES]; // write it to a file path stored in
>> destPath
>>
>>
>> this code is not altering the size at all
>>
>> i cant create a NSView as its a command line app
>>
>> any suggestions ??? how to resize it??
>>
>
>


-- 
--
Warm Regards,
Parimal Das
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Remove specific items from an Array - is this the best way?

2009-01-13 Thread Kyle Sluder
Take a look at function NSExpressions:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSExpression_Class/Reference/NSExpression.html#//apple_ref/doc/uid/TP30001190-SW11

You really can't get any more generic than NSPredicate.  When you need
to remove a set of things from an array, you should just use
-filteredArrayUsingPredicate:.

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


Remove specific items from an Array - is this the best way?

2009-01-13 Thread Steve Cronin

Folks;

I have an array of 'Suspect' objects which have 'names', 'capeSize',  
'hatSize', 'planetOfOrigin',  all the usual stuff...


Now I also have a list of 'RebelOutposts'; a set of 'planet' name  
strings,


What I want to do is remove from a usualSuspects array of Suspects any  
Suspect whose 'planetOfOrigin' is in my  rebelOutpost set.


Here's the wrinkle that makes my brow crinkle:  I really want a  
generic solution that would allow me to remove based on  
'fingerprints', or 


Here's what I'm proposing:

NSSet *workingSet = [NSSet setWithArray:usualSuspects];
NSString *searchOnKey = @"planetOfOrigin"
NSSet *removeMatchingValuesSet = [NSSet setWithSet: rebelOutpost];

offTheHook = [workingSet filteredSetUsingPredicate:[NSPredicate  
predicateWithFormat:@"NOT(%K  IN %@)", searchOnKey,  
removeMatchingValuesSet]];


(Hopefully you can see how this lends itself to wrapping in method  
with 3 parameters)


Is there a gotcha hiding in there? Nulls?
Is there a better way?

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