Re: NSString drawAtPoint and vertical font alignment

2009-09-07 Thread Stephen Blinkhorn


On 6 Sep 2009, at 21:30, Quincey Morris wrote:


On Sep 6, 2009, at 18:41, Stephen Blinkhorn wrote:

OK, do you mean the origin of [self bounds] isn't always (0, 0)?   
That could explain a few things..


The origin of the bounds coordinate system is always (0, 0) by  
definition, but what I meant to say was that the bottom left corner  
of the view (i.e. [self bounds].origin) doesn't have to be (0, 0) in  
bounds coordinates, though it usually is.


Right, here's something I don't understand and I think it is still  
relevant:


I make a custom view (really a NSControl subclass) and I use a place  
holder in IB to position it on screen.  I also set it's size to be say  
50 wide by 22 high.


If I draw the view by simply filling the rect returned by [self  
bounds] then it looks fine and in the same place as the IB  
placeholder.  However, the view responds to mouse events outside of  
its visual frame at the top edge and only registers mouse events  
inside the bottom edge once the cursor is about 3-4 pixels inside the  
frame.  Whilst only small the inaccuracy feels very wrong after a while.


I don't understand is the mouse event part.  I am filling the bounds  
rectangle via NSRectFill but mouse events visibly outside the filled  
rectangle are apparently happening inside the bounds rectangle.  I use  
this to get the event position:


NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];


I've read a lot of the Apple docs about frames, bounds and co-ordinate  
spaces but I can't figure this out.  Maye it is time for some sleep.


Thanks,
Stephen



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Joar Wingfors


On 6 sep 2009, at 22.48, Kyle Sluder wrote:

You'll need to make sure you have the unstripped release binary (not  
a debug version) of the same app version for this backtrace to be  
useful. If you don't, you will have to send the user a new binary.



For tracking down this type of issue, I would expect that having  
access to the sources for a reasonably similar version of the app  
would be sufficient - And if you're the developer, that shouldn't be  
difficult to get at.



Also the NSZombie will prevent a crash, so the user will need to set  
the appropriate breakpoint before running the program.



NSZombie doesn't prevent crashes (since Leopard). If you instruct the  
user to launch the app like this:


$ NSZombieEnabled=YES /path/to/Foo.app/Contents/MacOS/Foo

...you will see something like this in the terminal where you launched  
the app when you hit a zombie:


*** -[Bar baz]: message sent to deallocated instance 0x1004a8c30
Trace/BPT trap

...where Bar is the class of the object being messaged, and baz is  
the message being sent. If the user isn't running the app under the  
debugger, CrashReporter will pop up, and the user can copy out the  
backtrace and pass it along to the developer.



If you need information about where the object was allocated, you can  
get to that IF the user installs the developer tools (to get access to  
gdb and malloc_history). For this scenario I'd suggest launching your  
app from gdb:


$ gdb
(gdb) file /path/to/Foo.app/Contents/MacOS/Foo
(gdb) set environment NSZombieEnabled=YES
(gdb) set environment MallocStackLoggingNoCompact=1
(gdb) run

When you hit the zombie, type:

(gdb) shell malloc_history PID ADDRESS

...replacing PID with the pid of your app, and ADDRESS with the  
address of the zombie. Voila: malloc_history will spit out the  
backtrace to the allocation event for the zombie. Armed with this  
info, you should be well on your way to tracking down the problem.



j o a r


___

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

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

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

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


Re: NSString drawAtPoint and vertical font alignment

2009-09-07 Thread Quincey Morris

On Sep 6, 2009, at 23:38, Stephen Blinkhorn wrote:

I make a custom view (really a NSControl subclass) and I use a place  
holder in IB to position it on screen.  I also set it's size to be  
say 50 wide by 22 high.


If I draw the view by simply filling the rect returned by [self  
bounds] then it looks fine and in the same place as the IB  
placeholder.  However, the view responds to mouse events outside of  
its visual frame at the top edge and only registers mouse events  
inside the bottom edge once the cursor is about 3-4 pixels inside  
the frame.  Whilst only small the inaccuracy feels very wrong after  
a while.


I don't understand is the mouse event part.  I am filling the bounds  
rectangle via NSRectFill but mouse events visibly outside the filled  
rectangle are apparently happening inside the bounds rectangle.  I  
use this to get the event position:


NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];


There's not enough information here to suggest an answer. Is there a  
placeholder view that you *replace* with a NSControl subclass? Is this  
a subclass of NSControl directly, or of a specific control (e.g.  
NSButton)?


You'll probably need to post some code to get an answer, but it's not  
even clear which code.


I'd suggest you start by putting a breakpoint on the line after the  
line you showed above, and then start poking around the view hierarchy  
until you find out what numbers aren't what you expect them to be. It  
could be a coordinate system snafu, or it could be something more  
intimately related to control behavior.



___

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

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

2009-09-07 Thread James


Hi, everyone
   In my application, I have implemented to play the movie(.mov). Now, I 
want to 
control the movies looped or not when they play using menu items.
   Using the menu items, user can select to play single movie looped or all 
movie 
looped one by one. 
   I looked up the QTMovie class. But, I can not find the method for my 
purpose.
   Could anyone direct any method or function about it ?
   Any clue will help for me. Thanks a lot  for any help.
James___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Graham Cox
Great, thank-you all very much! I'm afraid this user is finding even  
point-and-click tough going, but I'll try as we have very little else  
to go on right now. Installing the dev tools is likely to be out for  
the moment.


However, in following your advice I'm not getting the app launched - I  
just get $: Command not found.. I just use the default shell in  
Terminal and I don't use it much myself so I'm not sure what the  
problem is. I'm on Snow but the user is on 10.5.7 right now.


--Graham




On 07/09/2009, at 5:04 PM, Joar Wingfors wrote:

NSZombie doesn't prevent crashes (since Leopard). If you instruct  
the user to launch the app like this:


$ NSZombieEnabled=YES /path/to/Foo.app/Contents/MacOS/Foo

...you will see something like this in the terminal where you  
launched the app when you hit a zombie:


*** -[Bar baz]: message sent to deallocated instance 0x1004a8c30
Trace/BPT trap

...where Bar is the class of the object being messaged, and baz  
is the message being sent. If the user isn't running the app under  
the debugger, CrashReporter will pop up, and the user can copy out  
the backtrace and pass it along to the developer.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Joar Wingfors


On 7 sep 2009, at 00.34, Graham Cox wrote:

However, in following your advice I'm not getting the app launched -  
I just get $: Command not found.. I just use the default shell in  
Terminal and I don't use it much myself so I'm not sure what the  
problem is. I'm on Snow but the user is on 10.5.7 right now.



You're not supposed to type either the $, or the (gdb). They're  
just there to indicate that you're supposed to type this at a prompt,  
and what type of prompt you're at.


j o a r


___

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

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

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

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


Finding nearby places

2009-09-07 Thread Mahaboob
Hi,
I get the latitude and longitude from the iPhone using coreLocation
framework. Now I need to show the nearby hotels, restaurants etc.

Which api I need to use for this?
I'm using iPhone OS 2.2

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


Re: Code Signing

2009-09-07 Thread Charles Srstka

On Sep 6, 2009, at 6:22 PM, Chris Suter wrote:


It's important to remember that code signatures are not really there
to prevent malware from running, or make it harder for hackers (since
it's trivial to remove a code signature or replace them other valid
signatures).


Well, you can always check that the signature is yours and not someone  
else's at app startup.


Charles

P.S. I know it's trivial to replace the signature with another  
signature, but to remove a signature? Are Apple's APIs really able to  
do that, or are you just talking about hacking the Mach-O file  
directly? I didn't see anything like that in the APIs.

___

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

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

2009-09-07 Thread Peter Hudson


Many thanks for this info.

I was looking for a way to observe the code having been hacked - and  
if it has been, for the app not to run.
What is the kill flag and how do I set it ?  Could it be reset by  
someone ?


Best regards

Peter



On 7 Sep 2009, at 00:22, Chris Suter wrote:


Hi Peter,

On Sun, Sep 6, 2009 at 9:00 PM, Peter Hudsonpeter.hud...@mac.com  
wrote:

I notice that when I sign code ( the whole app )  I  land up with 2
additional items in my /Contents directory in the app bundle.
These items are a folder called _CodeSignature  and an alias called
CodeResources.

If I delete these two items, the code still identifies itself as  
signed (

when I attempt to run codesign on it again ).
Also, the app still runs.

I was wondering if these files are meant to remain or if removing  
them is

not an issue ?


Within an application bundle there are signatures for all the files
within the bundle and then there's a signature for the binary itself.
The signature for the binary is stored within executable and you can
see it if you use the otool -l command (look for the
LC_CODE_SIGNATURE). The signature for all the resources is stored
within the file you've discovered.

As far as I know, except for static validation (using the codesign
tool), the signature for the resources isn't used by much (or at least
it wasn't for Leopard).

The signature for the binary is used by the system for various things.
For example you can set the kill flag to have your application
terminated if there's an invalid signature, and it's used for Keychain
access (so that if you upgrade an application, you won't be prompted
again for password access provided the signature remains valid).

It's important to remember that code signatures are not really there
to prevent malware from running, or make it harder for hackers (since
it's trivial to remove a code signature or replace them other valid
signatures).

At any rate, you shouldn't be deleting those files. If you remove
them, the signature will be invalidated.

By the way, the best list for code signing questions is the apple- 
cdsa list.


Kind regards,

Chris


___

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

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

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

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


Re: document-based application

2009-09-07 Thread René v Amerongen

Hi,

did you look at cocoadev/forum? If you want actualy the same, there is  
a disscusion about this.


HTH

Op 7 sep 2009, om 07:24 heeft Oftenwrong Soong het volgende geschreven:


Hi All,

In my doc-based app, I need to initially display a startup window  
instead of a new empty document. Its function would be somewhat akin  
to that of the Template Chooser that comes up when you launch Pages.


I've scoured the texts about the document architecture but cannot  
find pointers on how to do this.


So far this is the best idea I could come up with:

Implement NSApplication delegate applicationShouldOpenUntitledFile:,  
returning NO, and implement applicationDidFinishLaunching:, in which  
the startup window is launched. Then I manually call  
makeUntitledDocumentOfType:error.


It seems an ugly hack and I have a feeling it won't work 100% right.  
Is there a better way to implement an initial window in a doc-based  
app?


Thanks,
Soong





___

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

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

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

This email sent to apple...@xs4all.nl



___

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

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


Crash on SL in com.apple.DesktopServices after using NSOpenPanel

2009-09-07 Thread Markus Spoettl

Hello,

  I have a crash that I can't reproduce on my machines but a user  
runs into it every time he uses an open panel in the app on Snow  
Leopard.


Below is the stack trace and the code that handles the panel. Nothing  
obvious for me and it used to work and works fine under Leopard and  
Snow Leopard for me and other users. The base SDK and deployment  
target both are 10.5 compiled on Snow Leopard.


I've read the release notes and nothing relevant came up there  
(besides lots of deprecated stuff when using 10.6+ SDKs).


According to the user, he opens the panel, selects a file, OK's the  
sheet, the app does what it does and then shortly after that it crashes.


Stack and code below, I'd be grateful for hints in that matter.

Thanks!
Regards
Markus

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib 0x9696b917 objc_msgSend + 23
1   com.apple.DesktopServices   0x90f21a79 TFSInfo::~TFSInfo() + 29
2   com.apple.DesktopServices 	0x90f21f25  
TFSInfo::RemovePtrReference() + 35
3   com.apple.DesktopServices 	0x90f3a544 TNode::IsUnresolved()  
const + 48
4   com.apple.DesktopServices 	0x90f2efa0 TNode::SetAliasTarget 
(TNodePtr const, bool) + 230
5   com.apple.DesktopServices 	0x90f7538d  
TNode::RecursivelyRemoveAllChildren(bool) const + 175
6   com.apple.DesktopServices 	0x90f75986 TNode::Finalize 
(TNodePtr*) + 56

7   com.apple.DesktopServices   0x90f75bb0 TNode::Finalize() + 286
8   com.apple.DesktopServices   0x90f889fa NodeContextClose + 542
9   com.apple.AppKit  	0x971f1527 _NSSavePanelContextEnd +  
60
10  com.apple.Foundation  	0x942fbb65 __NSFireDelayedPerform +  
537

11  com.apple.CoreFoundation0x911a9eee __CFRunLoopRun + 6846
12  com.apple.CoreFoundation0x911a7d34 CFRunLoopRunSpecific + 452
13  com.apple.CoreFoundation0x911a7b61 CFRunLoopRunInMode + 97
14  com.apple.HIToolbox   	0x9622afec  
RunCurrentEventLoopInMode + 392
15  com.apple.HIToolbox   	0x9622ada3 ReceiveNextEventCommon +  
354
16  com.apple.HIToolbox   	0x9622ac28  
BlockUntilNextEventMatchingListInMode + 81

17  com.apple.AppKit0x96aaeb99 _DPSNextEvent + 847
18  com.apple.AppKit  	0x96aae40e -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] + 156

19  com.apple.AppKit0x96a705fb -[NSApplication run] + 821
20  com.apple.AppKit0x96a68695 NSApplicationMain + 574
21  com.toolsfactory.myapp  0x26ee 0x1000 + 5870

- (void)importDataPanelDidEnd:(NSOpenPanel *)panel returnCode:(int) 
returnCode  contextInfo:(void  *)contextInfo

{
[panel orderOut:self];

if (returnCode != NSOKButton) return;

if ([[panel filenames] count]  0) {
NSString *file = [[panel filenames] objectAtIndex:0];
NSString *dir = [file stringByDeletingLastPathComponent];
[[NSUserDefaults standardUserDefaults] setObject:dir  
forKey:UDEF_KEY_LAST_IMPORT_DIRECTORY];


[self importFromFiles:[panel filenames]];
}
}

- (void)importDataFromFile:(id)sender
{
NSArray *filetypes = [NSArray arrayWithObjects:@tcx, @gpx,  
@xml, @log, @fitlog, @sdf, nil];


NSOpenPanel *op = [NSOpenPanel openPanel];
[op setAllowsMultipleSelection:YES];
[op setAllowedFileTypes:filetypes];
[op setTitle:STR_IMPORT_SELECT_TITLE];
[op setMessage:STR_IMPORT_SELECT_FILES];
[op setPrompt:STR_IMPORT_IMPORT];

NSString *initialDir = [[NSUserDefaults standardUserDefaults]  
stringForKey:UDEF_KEY_LAST_IMPORT_DIRECTORY];	

if (!initialDir) {
initialDir = NSHomeDirectory();
}

[op beginSheetForDirectory:initialDir file:nil types:filetypes  
modalForWindow:[controller window] modalDelegate:self  
didEndSelector:@selector 
(importDataPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];

}

--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Problem with LSSharedFileListInsertItemURL() usage. (API in LaunchServices/LSSharedFileList.h)

2009-09-07 Thread Parimal Das
Hello all,

I am trying to do the following- when my app is used for the first
time - *'open
at login'* is selected by default. For that i am calling the code below for
the app's first run.

The code is working fine and my app is getting added in the login item list,
But on ctrl+click on my apps dock icon, its failing to show 'open at login'
as selected (tick mark)

What i am missing here??
Please guide.

*LSSharedFileListRef loginListRef = LSSharedFileListCreate(NULL,
kLSSharedFileListSessionLoginItems, NULL);
 if (loginListRef) {
 // Insert the item at the bottom of Login Items list.
LSSharedFileListItemRef loginItemRef =
LSSharedFileListInsertItemURL(loginListRef,

kLSSharedFileListItemLast,

NULL,

NULL,

(CFURLRef)url,  // url is my app location

NULL,

NULL);

if (loginItemRef) {
CFRelease(loginItemRef);
}

 CFRelease(loginListRef);
}*


Advance Thanks
-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: Crash on SL in com.apple.DesktopServices after using NSOpenPanel

2009-09-07 Thread Thomas Clement

Looks like an Apple bug.
http://kb2.adobe.com/cps/506/cpsid_50654.html

Thomas

On Sep 7, 2009, at 12:37 PM, Markus Spoettl wrote:


Hello,

 I have a crash that I can't reproduce on my machines but a user  
runs into it every time he uses an open panel in the app on Snow  
Leopard.


Below is the stack trace and the code that handles the panel.  
Nothing obvious for me and it used to work and works fine under  
Leopard and Snow Leopard for me and other users. The base SDK and  
deployment target both are 10.5 compiled on Snow Leopard.


I've read the release notes and nothing relevant came up there  
(besides lots of deprecated stuff when using 10.6+ SDKs).


According to the user, he opens the panel, selects a file, OK's the  
sheet, the app does what it does and then shortly after that it  
crashes.


Stack and code below, I'd be grateful for hints in that matter.

Thanks!
Regards
Markus

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib 0x9696b917 objc_msgSend + 23
1   com.apple.DesktopServices   0x90f21a79 TFSInfo::~TFSInfo() + 29
2   com.apple.DesktopServices 	0x90f21f25  
TFSInfo::RemovePtrReference() + 35
3   com.apple.DesktopServices 	0x90f3a544 TNode::IsUnresolved()  
const + 48
4   com.apple.DesktopServices 	0x90f2efa0  
TNode::SetAliasTarget(TNodePtr const, bool) + 230
5   com.apple.DesktopServices 	0x90f7538d  
TNode::RecursivelyRemoveAllChildren(bool) const + 175
6   com.apple.DesktopServices 	0x90f75986  
TNode::Finalize(TNodePtr*) + 56

7   com.apple.DesktopServices   0x90f75bb0 TNode::Finalize() + 286
8   com.apple.DesktopServices   0x90f889fa NodeContextClose + 542
9   com.apple.AppKit  	0x971f1527 _NSSavePanelContextEnd  
+ 60
10  com.apple.Foundation  	0x942fbb65 __NSFireDelayedPerform  
+ 537

11  com.apple.CoreFoundation0x911a9eee __CFRunLoopRun + 6846
12  com.apple.CoreFoundation  	0x911a7d34 CFRunLoopRunSpecific +  
452

13  com.apple.CoreFoundation0x911a7b61 CFRunLoopRunInMode + 97
14  com.apple.HIToolbox   	0x9622afec  
RunCurrentEventLoopInMode + 392
15  com.apple.HIToolbox   	0x9622ada3 ReceiveNextEventCommon  
+ 354
16  com.apple.HIToolbox   	0x9622ac28  
BlockUntilNextEventMatchingListInMode + 81

17  com.apple.AppKit0x96aaeb99 _DPSNextEvent + 847
18  com.apple.AppKit  	0x96aae40e -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
19  com.apple.AppKit  	0x96a705fb -[NSApplication run] +  
821

20  com.apple.AppKit0x96a68695 NSApplicationMain + 574
21  com.toolsfactory.myapp  0x26ee 0x1000 + 5870

- (void)importDataPanelDidEnd:(NSOpenPanel *)panel returnCode: 
(int)returnCode  contextInfo:(void  *)contextInfo

{
   [panel orderOut:self];

   if (returnCode != NSOKButton) return;

   if ([[panel filenames] count]  0) {
   NSString *file = [[panel filenames] objectAtIndex:0];
   NSString *dir = [file stringByDeletingLastPathComponent];
   [[NSUserDefaults standardUserDefaults] setObject:dir  
forKey:UDEF_KEY_LAST_IMPORT_DIRECTORY];


   [self importFromFiles:[panel filenames]];
   }
}

- (void)importDataFromFile:(id)sender
{
   NSArray *filetypes = [NSArray arrayWithObjects:@tcx, @gpx,  
@xml, @log, @fitlog, @sdf, nil];


   NSOpenPanel *op = [NSOpenPanel openPanel];
   [op setAllowsMultipleSelection:YES];
   [op setAllowedFileTypes:filetypes];
   [op setTitle:STR_IMPORT_SELECT_TITLE];
   [op setMessage:STR_IMPORT_SELECT_FILES];
   [op setPrompt:STR_IMPORT_IMPORT];

   NSString *initialDir = [[NSUserDefaults standardUserDefaults]  
stringForKey:UDEF_KEY_LAST_IMPORT_DIRECTORY];	

   if (!initialDir) {
   initialDir = NSHomeDirectory();
   }

   [op beginSheetForDirectory:initialDir file:nil types:filetypes  
modalForWindow:[controller window] modalDelegate:self  
didEndSelector 
:@selector(importDataPanelDidEnd:returnCode:contextInfo:)  
contextInfo:nil];

}

--
__
Markus Spoettl

___

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

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

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

This email sent to thoma...@free.fr


___

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

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


Sending the value message to an object typed id

2009-09-07 Thread Paulo F. Andrade
I was explaining the difference between typing objects with id instead  
of UISlider * (in this case) to a friend and came across this weird  
behaviour.


Consider the folowing method that is called when chaing the value of a  
UISlider:


===
- (IBAction)changeValue:(id)sender
{
[textLabel setText:[NSString stringWithFormat:@%f, [sender value]]];
}
===

[sender value] in this case returns the actual slider object...

If we cast sender to UISlider everything works as expected.

My first thought was that this behaviour may have to do with  
UISlider's -value method returning a float instead of an object.
However if I use [sender maximumValue] which also retuns a float it  
works..


So what's the deal with the method name value and ObjC runtime?


Paulo F. Andrade



___

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

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


Weird malloc error when dealing with lots of NSImage objects

2009-09-07 Thread DairyKnight
Hi all,


I keep on getting weird malloc errors with the following code, first from
ATSFontManager, and then:

FooProgram(1343,0xa01e1720) malloc: *** mmap(size=30855168) failed (error
code=12)

*** error: can't allocate region

*** set a breakpoint in malloc_error_break to debug

2009-09-07 19:37:17.606 KindPDF[1343:10b] *** NSCopyMemoryPages(0xfc18a000,
0x0, 30851072) failed


It seems to me that somewhere I have a memory leak, but I just cannot figure
out where.

What the function does is to take in a PDFPage and crop according to some
cropRect and scale down to

render the page on some surface with arbitrary geometry.

The program fails after processed for around 400 images with a device size
of 786x1144 and RENDER_SCALE_FACTOR

of 2. MAX_POINTS of 300 (This constant is to make the cropRect units
percetages)


Hope someone could help me this program has been making me mad for
around a week... Thanks.




-(NSImage *) generatePage:(PDFPage *) page withCropRect:(CropRect) cropRect
onDevice:(NSSize) deviceSize

{

NSRect originalPageMediaBox = [page boundsForBox:kPDFDisplayBoxMediaBox];

 NSRect croppedPageMediaBox = NSMakeRect((float)originalPageMediaBox.size.
width * (float)cropRect.left / MAX_POINTS,

(float)originalPageMediaBox.size.height * (float)cropRect.bottom /
MAX_POINTS,

originalPageMediaBox.size.width * (1.0 - (float)cropRect.horiCropped /
MAX_POINTS),

originalPageMediaBox.size.height * (1.0 - (float)cropRect.vertCropped /
MAX_POINTS));


 float croppedPDFAspectRatio = croppedPageMediaBox.size.height /
croppedPageMediaBox.size.width;

 float deviceAspectRatio = deviceSize.height / deviceSize.width;

float width, height;

if (croppedPDFAspectRatio  deviceAspectRatio)

{

height = deviceSize.height;

width = height / croppedPDFAspectRatio;

} else

{

width = deviceSize.width;

height = width * croppedPDFAspectRatio;

}

 width = width * RENDER_SCALE_FACTOR;

height = height * RENDER_SCALE_FACTOR;

 //

// Crop the PDF Page

//

 NSPDFImageRep *pdfImg = [NSPDFImageRep imageRepWithData:[page
dataRepresentation]];

NSSize pageSize = NSMakeSize(width / (1.0 - cropRect.horiCropped /
MAX_POINTS), height / 1.0 - cropRect.vertCropped / MAX_POINTS);

NSImage *pdfPage = [[NSImage alloc] initWithSize:pageSize];

[pdfPage lockFocus];

[pdfImg drawInRect:[pdfPage rect]];

[pdfPage unlockFocus];


 NSBitmapImageRep *pdfPageRep = [NSBitmapImageRep imageRepWithData:[pdfPage
TIFFRepresentation]];

 NSImage *rasterizedPage = [[NSImage alloc] initWithSize:NSMakeSize(width,
height)];

 [rasterizedPage lockFocus];

[[NSColor whiteColor] setFill];

NSRectFill(NSMakeRect(0, 0, width, height));

[pdfPageRep drawAtPoint:NSMakePoint(-1 * width * cropRect.left / MAX_POINTS,
-1 * height * cropRect.bottom / MAX_POINTS)];

[rasterizedPage unlockFocus];

 [pdfPage release];

 //

// Scale down to original size

//

NSImage *surface = [[[NSImage alloc] initWithSize:NSMakeSize(width /
RENDER_SCALE_FACTOR, height / RENDER_SCALE_FACTOR)] autorelease];


 [surface lockFocus];

[rasterizedPage drawInRect:[surface rect] fromRect:[rasterizedPage rect]
operation:NSCompositeCopy fraction:1];

[surface unlockFocus];

 [rasterizedPage release];

 return surface;

}
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Graham Cox


On 07/09/2009, at 5:37 PM, Joar Wingfors wrote:

You're not supposed to type either the $, or the (gdb). They're  
just there to indicate that you're supposed to type this at a  
prompt, and what type of prompt you're at.



Which was what I thought, but doing that produces much the same result:

NSZombieEnabled=YES: Command not found.

--Graham






___

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

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

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

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


Re: Sending the value message to an object typed id

2009-09-07 Thread Graham Cox


On 07/09/2009, at 9:36 PM, Paulo F. Andrade wrote:


So what's the deal with the method name value and ObjC runtime?



As an iPhone question this may be incorrect, but normally you use - 
floatValue to get a, umm, float value.


I suspect what's occurring is that -value is defined in multiple  
classes having different return types: maybe float in one case and id  
in another, say. The compiler can't disambiguate a method based on  
return type alone so compiles based solely on the first one it  
encounters, which to all intents and purposes may as well be random.  
It's a dirty little secret of Obj-C (or at least the current  
compilers) and is a very real source of bugs (and sometimes quite  
dangerous ones at that).


To avoid it, where possible do not use type id and always use explicit  
types if you can. If you know your sender is a UISlider*, then cast to  
that when messaging it with method names that can be ambiguous. Short  
and vague method names like -value are fairly likely to be ambiguous.


--Graham


___

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

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

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

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


Re: Turn on zombies in user environment?

2009-09-07 Thread Jean-Daniel Dupas


Le 7 sept. 2009 à 14:03, Graham Cox a écrit :



On 07/09/2009, at 5:37 PM, Joar Wingfors wrote:

You're not supposed to type either the $, or the (gdb). They're  
just there to indicate that you're supposed to type this at a  
prompt, and what type of prompt you're at.



Which was what I thought, but doing that produces much the same  
result:


NSZombieEnabled=YES: Command not found.

--Graham



env NSZombieEnabled=YES Your/Executable


-- Jean-Daniel




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Crash on SL in com.apple.DesktopServices after using NSOpenPanel

2009-09-07 Thread Markus Spoettl

On Sep 7, 2009, at 1:31 PM, Thomas Clement wrote:

Looks like an Apple bug.
http://kb2.adobe.com/cps/506/cpsid_50654.html



That doesn't seem to be the problem with that user's machine as the  
files are local.


Thanks for the pointer, though!

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Crash on SL in com.apple.DesktopServices after using NSOpenPanel

2009-09-07 Thread Thomas Clement

On Sep 7, 2009, at 2:25 PM, Markus Spoettl wrote:


On Sep 7, 2009, at 1:31 PM, Thomas Clement wrote:

Looks like an Apple bug.
http://kb2.adobe.com/cps/506/cpsid_50654.html


That doesn't seem to be the problem with that user's machine as the  
files are local.


The document states especially wia the SMB protocol, not only via  
the SMB protocol.


Thomas
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Weird malloc error when dealing with lots of NSImage objects

2009-09-07 Thread Roland King
where's this getting called? Is it getting called from a timer or  
button press or other event, or do you do a whole load of these in a  
loop?


It seems to me that everything you have init'ed you have released  
again, however surface is autoreleased, so it won't actually get  
dealloced until the innermost autoreleasepool is drained. If you're  
calling this function in a loop then you're not getting to that pool  
drain and you're piling up memory.


But you don't need to guess, fire up instruments, run with object  
allocations, that will very quickly show you where your memory is  
going. If you have some unbalanced release I didn't see here, you'll  
see it there, if you're piling up on an autorelease pool you'll see  
that too as the stack trace for the memory (if you enable the right  
options) will show you the last thing which happened is autorelease.




On 07-Sep-2009, at 7:45 PM, DairyKnight wrote:


Hi all,


I keep on getting weird malloc errors with the following code, first  
from

ATSFontManager, and then:

FooProgram(1343,0xa01e1720) malloc: *** mmap(size=30855168) failed  
(error

code=12)

*** error: can't allocate region

*** set a breakpoint in malloc_error_break to debug

2009-09-07 19:37:17.606 KindPDF[1343:10b] *** NSCopyMemoryPages 
(0xfc18a000,

0x0, 30851072) failed


It seems to me that somewhere I have a memory leak, but I just  
cannot figure

out where.

What the function does is to take in a PDFPage and crop according to  
some

cropRect and scale down to

render the page on some surface with arbitrary geometry.

The program fails after processed for around 400 images with a  
device size

of 786x1144 and RENDER_SCALE_FACTOR

of 2. MAX_POINTS of 300 (This constant is to make the cropRect units
percetages)


Hope someone could help me this program has been making me mad for
around a week... Thanks.




-(NSImage *) generatePage:(PDFPage *) page withCropRect:(CropRect)  
cropRect

onDevice:(NSSize) deviceSize

{

NSRect originalPageMediaBox = [page  
boundsForBox:kPDFDisplayBoxMediaBox];


NSRect croppedPageMediaBox = NSMakeRect((float) 
originalPageMediaBox.size.

width * (float)cropRect.left / MAX_POINTS,

(float)originalPageMediaBox.size.height * (float)cropRect.bottom /
MAX_POINTS,

originalPageMediaBox.size.width * (1.0 - (float)cropRect.horiCropped /
MAX_POINTS),

originalPageMediaBox.size.height * (1.0 - (float) 
cropRect.vertCropped /

MAX_POINTS));


float croppedPDFAspectRatio = croppedPageMediaBox.size.height /
croppedPageMediaBox.size.width;

float deviceAspectRatio = deviceSize.height / deviceSize.width;

float width, height;

if (croppedPDFAspectRatio  deviceAspectRatio)

{

height = deviceSize.height;

width = height / croppedPDFAspectRatio;

} else

{

width = deviceSize.width;

height = width * croppedPDFAspectRatio;

}

width = width * RENDER_SCALE_FACTOR;

height = height * RENDER_SCALE_FACTOR;

//

// Crop the PDF Page

//

NSPDFImageRep *pdfImg = [NSPDFImageRep imageRepWithData:[page
dataRepresentation]];

NSSize pageSize = NSMakeSize(width / (1.0 - cropRect.horiCropped /
MAX_POINTS), height / 1.0 - cropRect.vertCropped / MAX_POINTS);

NSImage *pdfPage = [[NSImage alloc] initWithSize:pageSize];

[pdfPage lockFocus];

[pdfImg drawInRect:[pdfPage rect]];

[pdfPage unlockFocus];


NSBitmapImageRep *pdfPageRep = [NSBitmapImageRep imageRepWithData: 
[pdfPage

TIFFRepresentation]];

NSImage *rasterizedPage = [[NSImage alloc] initWithSize:NSMakeSize 
(width,

height)];

[rasterizedPage lockFocus];

[[NSColor whiteColor] setFill];

NSRectFill(NSMakeRect(0, 0, width, height));

[pdfPageRep drawAtPoint:NSMakePoint(-1 * width * cropRect.left /  
MAX_POINTS,

-1 * height * cropRect.bottom / MAX_POINTS)];

[rasterizedPage unlockFocus];

[pdfPage release];

//

// Scale down to original size

//

NSImage *surface = [[[NSImage alloc] initWithSize:NSMakeSize(width /
RENDER_SCALE_FACTOR, height / RENDER_SCALE_FACTOR)] autorelease];


[surface lockFocus];

[rasterizedPage drawInRect:[surface rect] fromRect:[rasterizedPage  
rect]

operation:NSCompositeCopy fraction:1];

[surface unlockFocus];

[rasterizedPage release];

return surface;

}
___

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

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

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

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


___

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

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

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

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


Re: document-based application

2009-09-07 Thread Nathan Day
That is the way I do it, I don't see why it wouldn't work 100% of the  
time, it would be nice if Apple had a way to insert a template  
chooser, but I would describe the way you have done it as 'an ugly  
hack'.


On 07/09/2009, at 3:24 PM, Oftenwrong Soong wrote:


Hi All,

In my doc-based app, I need to initially display a startup window  
instead of a new empty document. Its function would be somewhat akin  
to that of the Template Chooser that comes up when you launch Pages.


I've scoured the texts about the document architecture but cannot  
find pointers on how to do this.


So far this is the best idea I could come up with:

Implement NSApplication delegate applicationShouldOpenUntitledFile:,  
returning NO, and implement applicationDidFinishLaunching:, in which  
the startup window is launched. Then I manually call  
makeUntitledDocumentOfType:error.


It seems an ugly hack and I have a feeling it won't work 100% right.  
Is there a better way to implement an initial window in a doc-based  
app?


Thanks,
Soong





___

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

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

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

This email sent to nathan_...@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: Turn on zombies in user environment?

2009-09-07 Thread Graham Cox


On 07/09/2009, at 10:22 PM, Jean-Daniel Dupas wrote:


env



Thankyou - the missing piece. It's good.

--Graham

___

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

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

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

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



Re: Code Signing

2009-09-07 Thread Carl Harris

Peter Hudson wrote:

I was looking for a way to observe the code having been hacked - and
if it has been, for the app not to run.  What is the kill flag and  
how do I set it ?

Could it be reset by someone ?


Take a look at the Code Signing Services Reference: 
http://developer.apple.com/mac/library/documentation/Security/Reference/CodeSigningRef/Reference/reference.html

Assuming that you want an application to check its own validity, the  
basic idea is that you want to get a SecCodeRef for the running app  
using SecCodeCopySelf, and then validate it against some requirement  
using SecCodeCheckValidity.  If you specify no requirement, it  
validates only the application's designated requirement.


Using SecCodeCheckValidity, you're validating the application's  
dynamic state -- i.e. confirming that it has not been modified while  
running.  You can also check the static state using  
SecStaticCodeCheckValidity.


There was a pretty good presentation on code signing at WWDC'09.  If  
you have access to the WWDC videos, you might want to check it out.




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: Change the text color in an NSTableView based on the data in the row

2009-09-07 Thread Bryan Zarnett

Thanks Graham,

I did the following and it worked fine:

NSNumber *isClosed =  [[[activityController arrangedObjects]  
objectAtIndex: row] valueForKey: @isClosed];


Cheers!


On 7-Sep-09, at 12:34 AM, Graham Cox wrote:



On 07/09/2009, at 9:40 AM, Bryan Zarnett wrote:

I would like to set the text color of the cell in an NSTableView  
based on a particular set of data in the table of in the associated  
array controller. I currently have the basic code for the coloring  
changing working right now in willDisplayCell. What I am not sure  
about is how to (1) retrieve a column for the same row to check the  
data for a cell, or (2) check the associate array controller being  
used to populate the cell data to see if a different field has  
related data.


For example, while viewing the Name column in willDisplayCell,  
I also want to see the other data that it is associated to --  
perhaps not all the data is displayed in the NSTableView.


Thoughts?


Hi Bryan,

The row index usually represents the array index of the item in the  
data model, and the column is a property for that item. Therefore  
the rowIndex is all you need to retrieve *all* of the data for an  
object, whether the table displays it or not. Both the column and  
the row index are passed to the delegate method you mention.


You ask: how to (1) retrieve a column for the same row but that  
doesn't make any sense - the column being drawn is passed to you,  
and there isn't a column for the same row. Columns and rows are,  
quite literally, orthogonal.


--Graham




___

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

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

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

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


Re: Finding nearby places

2009-09-07 Thread I. Savant

On Sep 7, 2009, at 5:48 AM, Mahaboob wrote:


I get the latitude and longitude from the iPhone using coreLocation
framework. Now I need to show the nearby hotels, restaurants etc.

Which api I need to use for this?
I'm using iPhone OS 2.2


  This has to be the fourth or fifth time you've asked this exact  
same question and it's becoming annoying.


  Posting the same question again and again is a gross violation of  
etiquette on any list and is only going to cause people to ignore all  
messages from you.


  As to your question, I believe someone (maybe me?) answered this  
the first time you asked it: You're going to have to interface with a  
web service that provides this information based on geolocation -  
there is no dedicated framework to do this (because there still has to  
be a service providing the data).


  Now, you have your answer (again). Search the documentation and the  
web for tutorials on how to use Cococa to interface with a web service  
(there are dozens). It's up to you (not this list) to find a service  
to provide the data for you. If you have *specific* questions about  
*specific* parts of the Cocoa framework, ask them, but please ...


  STOP ASKING THE SAME QUESTION AGAIN AND AGAIN.

--
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: document-based application

2009-09-07 Thread I. Savant

On Sep 7, 2009, at 1:24 AM, Oftenwrong Soong wrote:

In my doc-based app, I need to initially display a startup window  
instead of a new empty document. Its function would be somewhat akin  
to that of the Template Chooser that comes up when you launch Pages.


  This might help (it's a little hard to find via Google unless you  
know it exists):


http://www.stepwise.com/Articles/2006/eb1/index.html

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


Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Joshua Garnham
How would I do this?
The Outline View is being used with Core Data.

Cheers,
Josh.




___

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

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

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

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


Re: Sending the value message to an object typed id

2009-09-07 Thread Paulo F. Andrade




On 2009/09/07, at 13:11, Graham Cox wrote:



On 07/09/2009, at 9:36 PM, Paulo F. Andrade wrote:


So what's the deal with the method name value and ObjC runtime?



As an iPhone question this may be incorrect, but normally you use - 
floatValue to get a, umm, float value.


UISlider does not have a - floatValue method.



I suspect what's occurring is that -value is defined in multiple  
classes having different return types: maybe float in one case and  
id in another, say. The compiler can't disambiguate a method based  
on return type alone so compiles based solely on the first one it  
encounters, which to all intents and purposes may as well be random.  
It's a dirty little secret of Obj-C (or at least the current  
compilers) and is a very real source of bugs (and sometimes quite  
dangerous ones at that).


I don't get this. Won't the call

[sender value]

be dealt by objc_msgSend? Will it not traverse the isa pointer to get  
the method table and find the method named value and call that? At  
least from the UISlider class hierarchy there seems to be only one  
method named value, no ambiguity there.




To avoid it, where possible do not use type id and always use  
explicit types if you can. If you know your sender is a UISlider*,  
then cast to that when messaging it with method names that can be  
ambiguous. Short and vague method names like -value are fairly  
likely to be ambiguous.


I know this. I just want to fully understand why this is happening for  
this particular name value and not for maximumValue.




--Graham




Paulo F. Andrade

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Sending the value message to an object typed id

2009-09-07 Thread Graham Cox


On 08/09/2009, at 1:31 AM, Paulo F. Andrade wrote:


I don't get this. Won't the call

[sender value]

be dealt by objc_msgSend? Will it not traverse the isa pointer to  
get the method table and find the method named value and call  
that? At least from the UISlider class hierarchy there seems to be  
only one method named value, no ambiguity there.



Yes, but the return type will cause different compilation of  
objc_msgSend. There are several variants of that (obc_msgSend_fpret,  
objc_msgSend_stret, etc) depending on which registers are expected to  
return what sorts of values - structs vs. floats vs. integers/objects  
for example. So the right method will get called but within the wrong  
context of what will be returned. You can verify this yourself by  
disassembling some variants of calling a test method - if only the  
return type varies and the compiler can't disambiguate based on class  
of the receiver, it will compile the first version it finds.


What's probably occurring in your case is that the compiler has used a  
version (such as -(id) value) that returns its value in a certain  
register, whereas the -(float) value method returns it in a different  
register (an fp register, generally). It just so happens that the  
register that the caller pulls the result from holds the slider object.


I know this. I just want to fully understand why this is happening  
for this particular name value and not for maximumValue.


Probably because -value is ambiguous and -maximumValue is not.

Trust me - this happens. It's bitten me once or twice and I won't let  
that happen again, as it's so hard to understand what's going on and  
debug it.


--Graham


___

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

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

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

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


Re: Symbolic Links in Snow Leopard

2009-09-07 Thread Greg Guerin

Gerriet M. Denkmann wrote:


Try using a pathname that contains only Latin alphabet characters
(for reference, the original chars of the volume-name are Thai:  
\u0e40

\u0e21\u0e48\u0e19).  If necessary, create and mount a disk-image in
order to get only Latin chars.


Did try already - same issue.


Also, please show the code that assigns a value to pat1.  How that
pathname is determined may have a bearing on the problem.


Same problem if I just do: pat1 = @/Volumes/เม่น/Users/ 
gerriet/ Downloads/absAbsSymlink;



I'm convinced.

1. File a bug.
  http://developer.apple.com/bugreporter

2. Check against the latest preview release of the OS, if you have  
access to it.


  -- GG

___

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

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

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

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


Re: Symbolic Links in Snow Leopard

2009-09-07 Thread Greg Guerin

Jens Alfke wrote:

Huh? I never said the path was invalid. /Code/Murky is a  
perfectly cromulent path on my machine, although it goes through a  
symlink.



Oops.  Color me incromulent.  I somehow misunderstood your  
description, and was thinking it was a broken symlink.


  -- GG

___

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

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

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

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


Re: Sending the value message to an object typed id

2009-09-07 Thread Graham Cox


On 08/09/2009, at 1:31 AM, Paulo F. Andrade wrote:

At least from the UISlider class hierarchy there seems to be only  
one method named value, no ambiguity there.



A further point - it's not the immediate class hierarchy that is  
searched. It's the entire namespace, which as you know is everything.  
And because the compiler uses the first version it encounters, that  
could well be a method buried deep in the low-level parts of any  
framework that is visible.


To check this, disassemble the code that's calling -value. If it's not  
using objc_msgSend_fpret then it's done the wrong thing. Compare the  
disassembly with casting sender to (UISlider*), where it will use  
objc_msgSend_fpret. Finding the actual method it has based its  
compilation around is harder (and only of academic interest) - you'll  
have to search the entire namespace.


--Graham


___

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

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

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

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


Re: Weird malloc error when dealing with lots of NSImage objects

2009-09-07 Thread Bill Bumgarner

On Sep 7, 2009, at 4:45 AM, DairyKnight wrote:

FooProgram(1343,0xa01e1720) malloc: *** mmap(size=30855168) failed  
(error

code=12)

*** error: can't allocate region

*** set a breakpoint in malloc_error_break to debug

2009-09-07 19:37:17.606 KindPDF[1343:10b] *** NSCopyMemoryPages 
(0xfc18a000,

0x0, 30851072) failed


You have run out of memory and the allocator has failed.  In this  
case, it is a memory-mapped file that is failing which leads to a call  
to NSCopyMemoryPages() with an address of 0x0 as the destination.


Either your app is leaking memory -- which may be in the form of over- 
caching -- or you are simply trying to shove too much stuff into  
memory at the same time.


Use Instruments' Object Alloc instrument to see what is chewing up the  
space.


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: Sending the value message to an object typed id

2009-09-07 Thread Paulo F. Andrade

Got it.

Thank you!

Paulo F. Andrade



On 2009/09/07, at 16:51, Graham Cox wrote:

Yes, but the return type will cause different compilation of  
objc_msgSend. There are several variants of that (obc_msgSend_fpret,  
objc_msgSend_stret, etc) depending on which registers are expected  
to return what sorts of values - structs vs. floats vs. integers/ 
objects for example. So the right method will get called but within  
the wrong context of what will be returned. You can verify this  
yourself by disassembling some variants of calling a test method -  
if only the return type varies and the compiler can't disambiguate  
based on class of the receiver, it will compile the first version it  
finds.


What's probably occurring in your case is that the compiler has used  
a version (such as -(id) value) that returns its value in a certain  
register, whereas the -(float) value method returns it in a  
different register (an fp register, generally). It just so happens  
that the register that the caller pulls the result from holds the  
slider object.


___

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

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


mouseDown Event Position Accuracy (was: NSString drawAtPoint and vertical font alignment)

2009-09-07 Thread Stephen Blinkhorn


On 7 Sep 2009, at 01:09, Quincey Morris wrote:


On Sep 6, 2009, at 23:38, Stephen Blinkhorn wrote:

I make a custom view (really a NSControl subclass) and I use a  
place holder in IB to position it on screen.  I also set it's size  
to be say 50 wide by 22 high.


If I draw the view by simply filling the rect returned by [self  
bounds] then it looks fine and in the same place as the IB  
placeholder.  However, the view responds to mouse events outside of  
its visual frame at the top edge and only registers mouse events  
inside the bottom edge once the cursor is about 3-4 pixels inside  
the frame.  Whilst only small the inaccuracy feels very wrong after  
a while.


I don't understand is the mouse event part.  I am filling the  
bounds rectangle via NSRectFill but mouse events visibly outside  
the filled rectangle are apparently happening inside the bounds  
rectangle.  I use this to get the event position:


NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];


There's not enough information here to suggest an answer. Is there a  
placeholder view that you *replace* with a NSControl subclass? Is  
this a subclass of NSControl directly, or of a specific control  
(e.g. NSButton)?


I am using a direct subclass of NSControl.  I create a CustomView  
placeholder in IB and assign it to my custom control class.


You'll probably need to post some code to get an answer, but it's  
not even clear which code.


I'd suggest you start by putting a breakpoint on the line after the  
line you showed above, and then start poking around the view  
hierarchy until you find out what numbers aren't what you expect  
them to be. It could be a coordinate system snafu, or it could be  
something more intimately related to control behavior.


Everything looks OK in the debugger.  I have managed to whittle the  
code down to this tiny test case.  Presented like this it looks like  
I'm needlessly fussing over a 3 pixel area at the bottom of the view  
that doesn't respond to mouse events but with medium and small sized  
controls and switches those 3 pixels become relevant :)


Thanks again,
Stephen


#import Cocoa/Cocoa.h

@interface AS_TestControl : NSControl NSCoding
{
NSRect  viewRect;
BOOLselected;
}

@end


#import AS_TestControl.h

@implementation AS_TestControl

-(id)initWithCoder:(NSCoder*)coder
{
if (self = [super initWithCoder:coder])
{
selected = NO;
};
return self;
}

-(void)encodeWithCoder:(NSCoder*)coder
{
[super encodeWithCoder:coder];
}

-(void)dealloc
{
[super dealloc];
}

-(BOOL)isFlipped
{
return NO;
}

+(Class)cellClass
{
return [NSActionCell class];
}


#pragma mark Drawing

- (void)drawRect:(NSRect)rect
{
if(selected == YES) {
[[NSColor greenColor] set];
} else {
[[NSColor blackColor] set];
};

NSRectFill([self bounds]);
}


#pragma mark Events

-(void)mouseDown:(NSEvent*)theEvent
{
	NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];

if(NSPointInRect(p, [self bounds])) {
selected = YES;
[self setNeedsDisplay:YES];
};
}

-(void)mouseUp:(NSEvent*)theEvent
{
selected = NO;
[self setNeedsDisplay:YES];
}

@end


___

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

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

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

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


Re: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Steven Degutis
Josh,
The outline view is probably being displayed with an NSArrayController, not
just Core Data, which is an abstract term for a ton of APIs. As well,
NSArrayController falls into part of Cocoa, as well as Core Data, but that's
another story.

Assuming your row is removed via an outlet to your NSArrayController's
-remove: method, and assuming you're using NSArrayController for this in the
first place, simply subclass your NSArrayController and provide the NSAlert
behavior by overriding -remove: and then call super's -remove: once the
NSAlert has come back positive (for chlamydia).

-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/


On Mon, Sep 7, 2009 at 10:14 AM, Joshua Garnham
joshua.garn...@yahoo.co.ukwrote:

 How would I do this?
 The Outline View is being used with Core Data.

 Cheers,
 Josh.




 ___

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

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

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

 This email sent to steven.degu...@gmail.com

___

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

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

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

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


Re: mouseDown Event Position Accuracy (was: NSString drawAtPoint and vertical font alignment)

2009-09-07 Thread Steven Degutis
Stephen,

The most obvious reason that comes to mind, is that your cursor's exact
point is not located on the exact top of the default +[NSCursor
arrowCursor]. It's actually located a little lower. Try changing your cursor
to the crosshair cursor, or a custom cursor if you'd prefer, and see if it
is acting as expected at that point, by appearing to register clicks
inside the bounds and not outside.
-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/


On Mon, Sep 7, 2009 at 11:19 AM, Stephen Blinkhorn 
stephen.blinkh...@audiospillage.com wrote:


 On 7 Sep 2009, at 01:09, Quincey Morris wrote:

  On Sep 6, 2009, at 23:38, Stephen Blinkhorn wrote:

  I make a custom view (really a NSControl subclass) and I use a place
 holder in IB to position it on screen.  I also set it's size to be say 50
 wide by 22 high.

 If I draw the view by simply filling the rect returned by [self bounds]
 then it looks fine and in the same place as the IB placeholder.  However,
 the view responds to mouse events outside of its visual frame at the top
 edge and only registers mouse events inside the bottom edge once the cursor
 is about 3-4 pixels inside the frame.  Whilst only small the inaccuracy
 feels very wrong after a while.

 I don't understand is the mouse event part.  I am filling the bounds
 rectangle via NSRectFill but mouse events visibly outside the filled
 rectangle are apparently happening inside the bounds rectangle.  I use this
 to get the event position:

 NSPoint p = [self convertPoint:[theEvent locationInWindow] fromView:nil];


 There's not enough information here to suggest an answer. Is there a
 placeholder view that you *replace* with a NSControl subclass? Is this a
 subclass of NSControl directly, or of a specific control (e.g. NSButton)?


 I am using a direct subclass of NSControl.  I create a CustomView
 placeholder in IB and assign it to my custom control class.

  You'll probably need to post some code to get an answer, but it's not even
 clear which code.

 I'd suggest you start by putting a breakpoint on the line after the line
 you showed above, and then start poking around the view hierarchy until you
 find out what numbers aren't what you expect them to be. It could be a
 coordinate system snafu, or it could be something more intimately related to
 control behavior.


 Everything looks OK in the debugger.  I have managed to whittle the code
 down to this tiny test case.  Presented like this it looks like I'm
 needlessly fussing over a 3 pixel area at the bottom of the view that
 doesn't respond to mouse events but with medium and small sized controls and
 switches those 3 pixels become relevant :)

 Thanks again,
 Stephen


 #import Cocoa/Cocoa.h

 @interface AS_TestControl : NSControl NSCoding
 {
NSRect  viewRect;
BOOLselected;
 }

 @end


 #import AS_TestControl.h

 @implementation AS_TestControl

 -(id)initWithCoder:(NSCoder*)coder
 {
if (self = [super initWithCoder:coder])
{
selected = NO;
};
return self;
 }

 -(void)encodeWithCoder:(NSCoder*)coder
 {
[super encodeWithCoder:coder];
 }

 -(void)dealloc
 {
[super dealloc];
 }

 -(BOOL)isFlipped
 {
return NO;
 }

 +(Class)cellClass
 {
return [NSActionCell class];
 }


 #pragma mark Drawing

 - (void)drawRect:(NSRect)rect
 {
if(selected == YES) {
[[NSColor greenColor] set];
} else {
[[NSColor blackColor] set];
};

NSRectFill([self bounds]);
 }


 #pragma mark Events

 -(void)mouseDown:(NSEvent*)theEvent
 {
NSPoint p = [self convertPoint:[theEvent locationInWindow]
 fromView:nil];
if(NSPointInRect(p, [self bounds])) {
selected = YES;
[self setNeedsDisplay:YES];
};
 }

 -(void)mouseUp:(NSEvent*)theEvent
 {
selected = NO;
[self setNeedsDisplay:YES];
 }

 @end


 ___

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

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

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

 This email sent to steven.degu...@gmail.com

___

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

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

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

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


Re: Problem with LSSharedFileListInsertItemURL() usage. (API in LaunchServices/LSSharedFileList.h)

2009-09-07 Thread Steven Degutis
Parimal,
Your code looks complete and correct, so my only guess is that the variable url
is not actually pointing to [[NSBundle mainBundle] bundleURL] which might
explain it. (Then again, I've only ever dealt with manually adding my
application to the Login Items programmatically in apps that had no Dock
icon, and only used status bar items.)

-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/


On Mon, Sep 7, 2009 at 6:10 AM, Parimal Das parimal@webyog.com wrote:

 Hello all,

 I am trying to do the following- when my app is used for the first
 time - *'open
 at login'* is selected by default. For that i am calling the code below
 for
 the app's first run.

 The code is working fine and my app is getting added in the login item
 list,
 But on ctrl+click on my apps dock icon, its failing to show 'open at login'
 as selected (tick mark)

 What i am missing here??
 Please guide.

 *LSSharedFileListRef loginListRef = LSSharedFileListCreate(NULL,
 kLSSharedFileListSessionLoginItems, NULL);
 if (loginListRef) {
 // Insert the item at the bottom of Login Items list.
LSSharedFileListItemRef loginItemRef =
 LSSharedFileListInsertItemURL(loginListRef,

 kLSSharedFileListItemLast,

 NULL,

 NULL,

 (CFURLRef)url,  // url is my app location

 NULL,

 NULL);

if (loginItemRef) {
CFRelease(loginItemRef);
}

 CFRelease(loginListRef);
}*


 Advance Thanks
 -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/steven.degutis%40gmail.com

 This email sent to steven.degu...@gmail.com

___

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

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

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

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


Re: Copying records from to-many relationship in Core Data

2009-09-07 Thread Sean Kline
In case anyone is interested (or understood my post ;-)), Rib Rix is helping
me through this one.  The issue is that Apple states:
You are typically discouraged from performing fetches within an
implementation of awakeFromInsert. Although it is allowed, execution of the
fetch request can trigger the sending of internal Core Data notifications
which may have unwanted side-effects. For example, on Mac OS X, an instance
of NSArrayController may end up inserting a new object into its content
array twice.

One solution (from Rob) is to push the fetch request to the next iteration
of the run loop (via -performSelector:withObject:afterDelay:)

This fetches properly, does not create two records and (though I have not
tried it yet) I believe will allow me to copy the to-many
NSManagedObjects.

Regards,

- S

On Sat, Aug 29, 2009 at 4:50 PM, Sean Kline skline1...@gmail.com wrote:

 Folks,
 I have a Core Data application with two entities (relevant to this
 question) with a to-many relationship between them.  When I create a new
 record in Entity 1, I would like to copy the to-many records from Entity 2
 from that last record created into the new record.  I tried to execute a
 fetch into an array, but whenever I do this the table that is bound to
 Entity 1 displays two records.  There may be something bizarre that I have
 done causing this behavior, but does anyone have any general advice or
 examples to help me achieve what I am trying to do?

 Thanks,

 - 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: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Joshua Garnham
Steven,

The Outline View isn't being displayed with an NSArrayController rather an 
NSTreeController, but I think you can still override -remove:.
Also, how would I check to see whether the row the user wants to delete has any 
children?

Cheer,
Josh.



From: Steven Degutis steven.degu...@gmail.com
To: Joshua Garnham joshua.garn...@yahoo.co.uk
Cc: cocoa-dev@lists.apple.com
Sent: Monday, 7 September, 2009 17:20:50
Subject: Re: Making an NSAlert be displayed when the User attempts to delete a  
row from an NSOutlineView when it has children.

Josh,

The outline view is probably being displayed with an NSArrayController, not 
just Core Data, which is an abstract term for a ton of APIs. As well, 
NSArrayController falls into part of Cocoa, as well as Core Data, but that's 
another story.

Assuming your row is removed via an outlet to your NSArrayController's 
-remove: method, and assuming you're using NSArrayController for this in the 
first place, simply subclass your NSArrayController and provide the NSAlert 
behavior by overriding -remove: and then call super's -remove: once the NSAlert 
has come back positive (for chlamydia).

-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/



On Mon, Sep 7, 2009 at 10:14 AM, Joshua Garnham joshua.garn...@yahoo.co.uk 
wrote:

How would I do this?
The Outline View is being used with Core Data.

Cheers,
Josh.




___

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

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

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

This email sent to steven.degu...@gmail.com




___

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

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

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

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


Re: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Kyle Sluder
On Sep 7, 2009, at 8:14 AM, Joshua Garnham  
joshua.garn...@yahoo.co.uk wrote:



How would I do this?


http://www.whathaveyoutried.com

--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: mouseDown Event Position Accuracy (was: NSString drawAtPoint and vertical font alignment)

2009-09-07 Thread Stephen Blinkhorn
Astonishing... that is the problem.  I thought the default hot spot  
for the default cursor would be the tip of the arrow.  Obviously not.   
OK, custom cursors it is then.


Many thanks,
Stephen

On 7 Sep 2009, at 10:24, Steven Degutis wrote:


Stephen,

The most obvious reason that comes to mind, is that your cursor's  
exact point is not located on the exact top of the default + 
[NSCursor arrowCursor]. It's actually located a little lower. Try  
changing your cursor to the crosshair cursor, or a custom cursor if  
you'd prefer, and see if it is acting as expected at that point,  
by appearing to register clicks inside the bounds and not outside.


--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/


On Mon, Sep 7, 2009 at 11:19 AM, Stephen Blinkhorn stephen.blinkh...@audiospillage.com 
 wrote:


On 7 Sep 2009, at 01:09, Quincey Morris wrote:

On Sep 6, 2009, at 23:38, Stephen Blinkhorn wrote:

I make a custom view (really a NSControl subclass) and I use a place  
holder in IB to position it on screen.  I also set it's size to be  
say 50 wide by 22 high.


If I draw the view by simply filling the rect returned by [self  
bounds] then it looks fine and in the same place as the IB  
placeholder.  However, the view responds to mouse events outside of  
its visual frame at the top edge and only registers mouse events  
inside the bottom edge once the cursor is about 3-4 pixels inside  
the frame.  Whilst only small the inaccuracy feels very wrong after  
a while.


I don't understand is the mouse event part.  I am filling the bounds  
rectangle via NSRectFill but mouse events visibly outside the filled  
rectangle are apparently happening inside the bounds rectangle.  I  
use this to get the event position:


NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];


There's not enough information here to suggest an answer. Is there a  
placeholder view that you *replace* with a NSControl subclass? Is  
this a subclass of NSControl directly, or of a specific control  
(e.g. NSButton)?


I am using a direct subclass of NSControl.  I create a CustomView  
placeholder in IB and assign it to my custom control class.


You'll probably need to post some code to get an answer, but it's  
not even clear which code.


I'd suggest you start by putting a breakpoint on the line after the  
line you showed above, and then start poking around the view  
hierarchy until you find out what numbers aren't what you expect  
them to be. It could be a coordinate system snafu, or it could be  
something more intimately related to control behavior.


Everything looks OK in the debugger.  I have managed to whittle the  
code down to this tiny test case.  Presented like this it looks like  
I'm needlessly fussing over a 3 pixel area at the bottom of the view  
that doesn't respond to mouse events but with medium and small sized  
controls and switches those 3 pixels become relevant :)


Thanks again,
Stephen


#import Cocoa/Cocoa.h

@interface AS_TestControl : NSControl NSCoding
{
   NSRect  viewRect;
   BOOLselected;
}

@end


#import AS_TestControl.h

@implementation AS_TestControl

-(id)initWithCoder:(NSCoder*)coder
{
   if (self = [super initWithCoder:coder])
   {
   selected = NO;
   };
   return self;
}

-(void)encodeWithCoder:(NSCoder*)coder
{
   [super encodeWithCoder:coder];
}

-(void)dealloc
{
   [super dealloc];
}

-(BOOL)isFlipped
{
   return NO;
}

+(Class)cellClass
{
   return [NSActionCell class];
}


#pragma mark Drawing

- (void)drawRect:(NSRect)rect
{
   if(selected == YES) {
   [[NSColor greenColor] set];
   } else {
   [[NSColor blackColor] set];
   };

   NSRectFill([self bounds]);
}


#pragma mark Events

-(void)mouseDown:(NSEvent*)theEvent
{
   NSPoint p = [self convertPoint:[theEvent locationInWindow]  
fromView:nil];

   if(NSPointInRect(p, [self bounds])) {
   selected = YES;
   [self setNeedsDisplay:YES];
   };
}

-(void)mouseUp:(NSEvent*)theEvent
{
   selected = NO;
   [self setNeedsDisplay:YES];
}

@end


___

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

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

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

This email sent to steven.degu...@gmail.com





___

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

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

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

This email sent to 

Re: Sending the value message to an object typed id

2009-09-07 Thread Jens Alfke


On Sep 7, 2009, at 5:11 AM, Graham Cox wrote:

I suspect what's occurring is that -value is defined in multiple  
classes having different return types: maybe float in one case and  
id in another, say. The compiler can't disambiguate a method based  
on return type alone so compiles based solely on the first one it  
encounters, which to all intents and purposes may as well be random.  
It's a dirty little secret of Obj-C (or at least the current  
compilers) and is a very real source of bugs (and sometimes quite  
dangerous ones at that).


BTW, Paulo, this situation should have generated a compiler warning  
saying that it can't tell which version of the 'value' message it  
should use here. Whenever you get a warning like that, you should cast  
the receiver to the appropriate class.


(This is yet another reason I recommend always enabling treat  
warnings as errors when building Obj-C code.)


—Jens___

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

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

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

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


Re: How to play the movie(.mov) looped using QTMovie ?

2009-09-07 Thread Jens Alfke


On Sep 7, 2009, at 12:40 AM, James wrote:

  Using the menu items, user can select to play single movie  
looped or all movie

looped one by one.
  I looked up the QTMovie class. But, I can not find the method  
for my purpose.


Set the movie's attribute QTMovieLoopsAttribute to YES.

(All I did was open QTMovie.h and search for loop, to find this.)

—Jens___

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

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

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

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


Re: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Joshua Garnham
This.

- (IBAction)remove:(id)sender {
NSArray *selectedRow = [treeController selectedObjects];
NSInteger childrenCount = [selectedRow.children count];
if ([childrenCount != 0]) 
{
NSLog(@Display Alert);
}else{
NSLog(@Delete Imediately);
}
}





From: Kyle Sluder kyle.slu...@gmail.com
To: Joshua Garnham joshua.garn...@yahoo.co.uk
Cc: cocoa-dev@lists.apple.com cocoa-dev@lists.apple.com
Sent: Monday, 7 September, 2009 17:52:26
Subject: Re: Making an NSAlert be displayed when the User attempts to delete a 
row from an NSOutlineView when it has children.

On Sep 7, 2009, at 8:14 AM, Joshua Garnham joshua.garn...@yahoo.co.uk wrote:

 How would I do this?

http://www.whathaveyoutried.com

--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: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Volker in Lists

Hi,


   NSArray *selectedRow = [treeController selectedObjects];


you get an NSArray - so you should enumerate through the objects of  
the array



   NSInteger childrenCount = [selectedRow.children count];


Does not get the children count of anything but the NSArray, which it  
doesn't have. You should get a warning when compiling. Something along  
struct or union doesn't blah, blah blah.


Told you before: Read the warnings and try to understand them.

Cheers,
Volker


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Making an NSAlert be displayed when the User attempts to delete a row from an NSOutlineView when it has children.

2009-09-07 Thread Kyle Sluder
On Sep 7, 2009, at 10:20 AM, Joshua Garnham  
joshua.garn...@yahoo.co.uk wrote:



This.


Excellent response. In the future, it is always better if you include  
code or a description of your attempts (even if it's just looking at  
the documentation).



- (IBAction)remove:(id)sender {
NSArray *selectedRow = [treeController selectedObjects];


As you noticed, this returns an array, not a single object.


NSInteger childrenCount = [selectedRow.children count];


Which makes this line suspect. An array doesn't have children. Didn't  
the compiler issue an error/warning here? If not, you'll probably want  
to turn on all warnings and treat warnings as errors. Those options  
are so frequently used I think they should be the standard behavior.


--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: Does Mac OS X support interior pointers?

2009-09-07 Thread Quincey Morris

On Sep 7, 2009, at 02:32, John Engelhart wrote:


[...]


I'm not going to engage you on this discussion. If that means I'm  
ignoring your reasonable requests for clarification, I apologize.


However, I do feel the need to acknowledge what I might have  
previously done wrong ...


I may have misused your term 'base pointer' as you defined/intended  
it. (I did try to suggest I was using the term very loosely, by using  
quotes: base pointer.) The result demonstrates why these discussions  
are pointless -- there are multiple terms being used with different  
strict meanings by different people. A reasonable discussion has to  
have everyone speaking the same language, and that *never* happens on  
this subject.


I may have sounded sanctimonious, and if so I apologize. These  
discussions always end up in rudeness and acrimony (shortly before  
being moderated out of existence, with no resolution), so I was just  
trying to save everyone time by jumping straight to the rudeness and  
acrimony, skipping the intervening steps.


I mistakenly replied to your original post on the wrong list, so I'm  
posting this in both places. Any further discussion should go back to  
objc-language. Or maybe there won't be any further discussion.



___

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

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


KVO on Distributed Objects with exception handling.

2009-09-07 Thread Edward Chan
Hello,

I'm using KVO on a Distributed Object, and I am binding my UI controls
based on the observer.

For example:

MonkeyViewController.isEatingABanana - Binded to a UI checkbox.

MonkeyViewController.m:

@propery (readwrite, assign) BOOL isEatingABanana;

-(id)init {
...
[MonkeyBrainDOObject addObserver:self
 forKeyPath:@banana
 options:(NSKeyValueObservingOptionNew |
NSKeyValueObservingOptionOld)
context:NULL];

...
}

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
change:(NSDictionary *)change
   context:(void *)context
{
   if ([keyPath isEqualToString:@banana]) {
  [self willChangeValueForKey:@isEatingABanana];
  isEatingABanana = [change objectForKey:NSKeyValueChangeNewKey] boolValue];
  [self didChangeValueForKey:@isEatingABanana];
  }
}

- (void)setIsEatingABanana:(BOOL)flag
{
 [MonkeyBrainDOObject setBanana:flag];
 isEatingABanana = flag;
}


This indeed works, and we save some hassles of sending NSNotifications and such.

So, what I'm wondering is if the following code is sufficient enough
for the IPC exception handling?
Instead of having to manually write @try/@catch wherever I doing some
IPC, I create a wrapper object around the DO to handle the exceptions.
This wrapper class is simply an NSObject, and will call the methods
methodSignatureForSelector, and forwardInvocation when I try to use
MonkeyBrainDOObject methods (since the wrapper does not understand
them). I can then insert a @try/@catch when I forward the invokations
to the actual DO object.

MonkeyBrainWrapper.m : NSObject

- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
return [MonkeyBrainDOObject methodSignatureForSelector:selector];
// maybe I can use extra code to make sure MonkeyBrainDOObject
responds to the selector.
}

- (void)forwardInvocation:(NSInvocation *)invocation
{
   @try {
  [invocation invokeWithTarget:MonkeyBrainDOObject];
   } @catch (NSException *e) {
   // Oh no! some went wrong with the IPC. But it's ok, I caught you.. :P
   }
}

So, instead of calling directly on the MonkeyBrainDOObject in my
MonkeyViewController, I would now call my MonkeyBrainWrapper object,
which has explicit exception handling rather than the one handle by
the NSApplication.


Should that be enough for exception handling on both ends of the IPC?
Or do I need some explicit exception handling on the other end? It
seems when I tested it out, my other end never threw anything when the
connection broke.
Also, is there maybe a better approach to all of this? My old code had
a bunch of NSNotifications being sent/received whenever something
needed updating on the UI, and I found this approach to be a lot
cleaner.

Edward
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Joar Wingfors


On 7 sep 2009, at 05.03, Graham Cox wrote:

You're not supposed to type either the $, or the (gdb). They're  
just there to indicate that you're supposed to type this at a  
prompt, and what type of prompt you're at.


Which was what I thought, but doing that produces much the same  
result:


NSZombieEnabled=YES: Command not found.



The syntax I proposed works with bash, the default shell for Mac OS X.  
If you have changed to using some other shell, you will need to change  
the syntax to match.


j o a r


___

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

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

2009-09-07 Thread Gabriel Zachmann


As mentioned before, the new feature is called Blocks, and is  
available only
for Snow Leopard for the moment (probably being ported to the iPhone  
too).

I've written an introductory guide on what they are and how they work,
specifically intended for people who have experience with Objective- 
C and/or

Cocoa, but never heard of Blocks before. Here's the link:

http://www.degutis.org/dev/2009/08/30/beginners-guide-to-blocks-in-cocoa/


Thanks a lot for this write-up!

I know this question does not really belong on this list, but it's  
only a short one ;-)


It seems to me that Blocks in SL are exactly the same thing as  
Closures in Smalltalk -- is that correct?



Best regards,
Gabriel.



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

Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Chilton Webb

Hi!

I've checked the archives, but finding 'command' and '3' for anything  
relevant is somewhat impossible.


I have a situation where if I try to set the key equivalent of a menu  
to 3 or 4, it just won't happen. any other number--it works just fine.


I even made a movie...
http://www.conjurebunny.com/ConjureMenuWeirdness.mov

The thing is, I can't figure out where to even start trying to debug  
this. There are no messages on the console, no failure states, no  
NSZombies, nada. It just won't show up.


If I check the keyEquivalent later on, at any time, it will show that  
the keyEquivalent is whatever I set it to, even 3 and 4. It just won't  
show up!


What the heck could cause something like this???

Thanks!
-Chilton
___

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

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

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

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


Re: completion handlers?

2009-09-07 Thread Kyle Sluder
On Sep 7, 2009, at 1:08 PM, Gabriel Zachmann z...@tu-clausthal.de  
wrote:




It seems to me that Blocks in SL are exactly the same thing as  
Closures in Smalltalk -- is that correct?


Mostly. ObjC blocks have certain semantics you need to be aware of,  
since they can live on the stack.


Further discussion belongs on the Objective-C language list.

--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: KVO on Distributed Objects with exception handling.

2009-09-07 Thread Edward Chan
Great...

How long ago did you ask the Apple engineers? I haven't tried this
piece of code with Snow Leopard actually...


On Mon, Sep 7, 2009 at 3:29 PM, Graham Leel...@thaesofereode.info wrote:
 On Sep 7, 2009, at 20:02 , Edward Chan wrote:

 Hello,

 I'm using KVO on a Distributed Object, and I am binding my UI controls
 based on the observer.

 Hi,

 not much of constructive help from me I'm afraid, just a warning. I also did
 the same thing once, and the reaction from Apple engineers went through
 denial, shock and fear, but never got as far as acceptance. In fact I was
 told that combining KVO with DO is not supported and if it does work now,
 don't expect it to work in the future.

 Cheers,

 Graham.

___

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

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

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

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


Re: KVO on Distributed Objects with exception handling.

2009-09-07 Thread Edward Chan
Also,

Did they explain why they didn't want to support it?

Thanks,
Ed

On Mon, Sep 7, 2009 at 4:45 PM, Edward Chanedch...@gmail.com wrote:
 Great...

 How long ago did you ask the Apple engineers? I haven't tried this
 piece of code with Snow Leopard actually...


 On Mon, Sep 7, 2009 at 3:29 PM, Graham Leel...@thaesofereode.info wrote:
 On Sep 7, 2009, at 20:02 , Edward Chan wrote:

 Hello,

 I'm using KVO on a Distributed Object, and I am binding my UI controls
 based on the observer.

 Hi,

 not much of constructive help from me I'm afraid, just a warning. I also did
 the same thing once, and the reaction from Apple engineers went through
 denial, shock and fear, but never got as far as acceptance. In fact I was
 told that combining KVO with DO is not supported and if it does work now,
 don't expect it to work in the future.

 Cheers,

 Graham.


___

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

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

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

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


Need simple port scan

2009-09-07 Thread Ashley Perrien
I'm very new to networking via cocoa and need to develop a small port  
scanner application. The core of it is very simple, is address 1.2.3.4  
listening on port X. I've done a bit of looking on NSStream, pipes,  
tasks and such but hopefully what I'm trying to get is a short and  
sweet. What specifically should I be checking into or does anyone  
happen to have a snippet of code that does the above?


Ashley Perrien
Random Quote of the day:
No prizes for predicting rain. Prizes only awarded for building arks.

___

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

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

2009-09-07 Thread Jens Alfke


On Sep 7, 2009, at 1:08 PM, Gabriel Zachmann wrote:

It seems to me that Blocks in SL are exactly the same thing as  
Closures in Smalltalk -- is that correct?


Actually, Smalltalk calls them blocks too — that's where Obj-C, and  
Ruby, got the name from. (The Obj-C object model has always been very  
Smalltalk-inspired.) But yes, they're the same thing. They're also the  
same thing as function literals in JavaScript and lambdas in Python.  
It's been a very popular concept, going all the way back to 1960s' LISP.


—Jens___

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

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

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

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


Re: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Jens Alfke


On Sep 7, 2009, at 1:37 PM, Chilton Webb wrote:

I have a situation where if I try to set the key equivalent of a  
menu to 3 or 4, it just won't happen. any other number--it works  
just fine.


There are probably some other menu commands that already have those  
key equivalents. I suspect the Services submenu. I'm not sure whether  
services override regular menu commands or the other way 'round, but  
that sounds like what's happening in your case.


(I know that Command-Shift-3 and -4 are reserved for screenshots, but  
you're clearly not using Shift...)

—Jens___

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

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

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

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


NSLineBreakByClipping is not clipping

2009-09-07 Thread Seth Willits


I'm drawing an attributed string with drawInRect which is documented  
to clip to the rect you pass in. The line break mode of the paragraph  
style is NSLineBreakByClipping. If the string's text is too wide for  
the rect (even by a lot), it draws outside of the rect. I've noticed  
that this only happens if the string will not vertically clip the text  
with the given rectangle. In other words, if there's enough vertical  
room for the text but not enough horizontal room, it will not clip the  
text. If there's not enough vertical room and not enough horizontal  
room, both axis are properly clipped to the rect.


I've also noticed that if I use NSLineBreakByTruncatingTail, it works  
fine all the time.



Screenshot: http://www.sethwillits.com/temp/StringClippingBug.png
Code: http://www.pasteit4me.com/32015



Is this a bug?

--
Seth Willits



___

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

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

2009-09-07 Thread Peter Duniho

On Sep 7, 2009, at 1:56 PM, Ashley Perrien wrote:

I'm very new to networking via cocoa and need to develop a small  
port scanner application. The core of it is very simple, is address  
1.2.3.4 listening on port X. I've done a bit of looking on NSStream,  
pipes, tasks and such but hopefully what I'm trying to get is a  
short and sweet. What specifically should I be checking into or does  
anyone happen to have a snippet of code that does the above?


Does it have to be a Cocoa API?  You should be able to use the Unix  
BSD sockets API, which IMHO if you're looking for short and sweet  
you might as well use.


If you really want a Cocoa API, then I think NSSocketPort is probably  
what you're looking for.  Alternatively, use NSStream's class method  
+ getStreamsToHost:port:inputStream:outputStream:.


Pete
___

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

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


NSKeyedUnarchiver and memory management

2009-09-07 Thread DKJ
I included this method in the MyObject class as part of implementing  
the NSCoder protocol:


- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
theData = [[aDecoder decodeObjectForKey:@theData] retain];
return self;
}

This is how I read the object from disk:

MyObject *myob = [NSKeyedUnarchiver unarchiveObjectWithFile:filepath];

(Garbage collection is not activated.) My understanding of the memory  
management rules is that I don't need to release myob. And I get  
EXC_BAD_ACCESS errors when I do.


But Instruments is complaining about a memory leak, and mentions  
NSKeyedUnarchiver. The retain message in the initWithCoder makes me  
wonder.


Is this code leaking? Should I add an autorelease to the retain in  
initWithCoder?


dkj


___

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

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

2009-09-07 Thread DKJ

P.S.

Doing the autorelease thing gave me an EXC_BAD_ACCESS too. And theData  
is released in the dealloc method of MyObject.


dkj
___

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

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

2009-09-07 Thread Bryan Henry
According to the memory management rules, yes, you own the object  
returned by that method and you should therefore release it.


You take ownership of an object if you create it using a method whose  
name begins with “alloc” or “new” or contains “copy” (for example,  
alloc,newObject, or mutableCopy), or if you send it a retain message.  
You are responsible for relinquishing ownership of objects you own  
using releaseor autorelease. Any other time you receive an object, you  
must not release it.


Also note the documentation for that method:
An initialized collection view item with the specified object and the  
appropriate view set. The collection view item should not be  
autoreleased.


- Bryan

On Sep 7, 2009, at 6:23:30 PM, Colin Deasy wrote:




Does the returned obj from this method:
- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object
require a release?
ThanksColin
_
Share your memories online with anyone you want.
http://www.microsoft.com/ireland/windows/windowslive/products/photos-share.aspx?tab=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/bryanhenry%40mac.com

This email sent to bryanhe...@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: Need simple port scan

2009-09-07 Thread Ashley Perrien
I'm very new to networking via cocoa and need to develop a small  
port scanner application. The core of it is very simple, is address  
1.2.3.4 listening on port X.


Does it have to be a Cocoa API?  You should be able to use the Unix  
BSD sockets API, which IMHO if you're looking for short and sweet  
you might as well use.


Doesn't need to be cocoa I guess, as long as it ends with a yes or no,  
that should be fine.


If you really want a Cocoa API, then I think NSSocketPort is  
probably what you're looking for.  Alternatively, use NSStream's  
class method + getStreamsToHost:port:inputStream:outputStream:.


I'll look at that again but when I did before it seemed to need lots  
of support around it (creating pipes and streams, archiving data to  
files, etc.) that I was hoping to avoid having to learn about, or find  
some kind of simple tutorials on it as much of that is well beyond  
what I've been doing thus far.


Ashley


___

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

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

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

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


Anti-aliasing in Snow Leopard (10.6) PDFView

2009-09-07 Thread Duncan McGregor
It used to be that PDFView anti-aliased nicely. Now it doesn't, at
least not for some files. Text and scans rendered in both the
PDKKitViewer and PDFLinker2 samples are horrible in 10.6.

I understand that shouldAntiAlias defaults to true, but even setting
it explicitly does not seem to help. The display is the same as in
Preview when PDF smoothing is turned off in Preview preferences.

Am I missing something obvious?

Thanks in anticipation

Duncan McGregor
___

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

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

2009-09-07 Thread Greg Guerin

Ashley Perrien wrote:

I'm very new to networking via cocoa and need to develop a small  
port scanner application.



Why do you need this port scanner?  Are you going to distribute it,  
or just run it yourself?  Is it a class project or assignment?  Does  
it absolutely have to be Cocoa?  If so, why?


Have you tried googling?  I see a lot of hits for keywords open  
source Cocoa port scanner.  If those don't meet your needs, why not?


The Apple-provided application Network Utility.app contains an  
embedded port scanner, which it runs when you use its Port Scan  
tab.  If you don't need to distribute the app, and can do some  
digging to figure out the command-line parameters, you might be able  
to run that embedded port scanner instead of writing your own.  Its  
name is 'stroke', and you can open the Network Utility.app bundle and  
see it in Resources.


Another option would be to google keywords like open source BSD port  
scanner and see what comes up.  Mac OS X can run a lot of BSD code  
without any source changes.


  -- GG

___

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

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

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

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


Re: Need simple port scan

2009-09-07 Thread Brent Gulanowski
Deusty: AsyncSocket
4.3.4http://deusty.blogspot.com/2008/02/asyncsocket-434.html
http://deusty.blogspot.com/2008/02/asyncsocket-434.htmlJust create an
instance with your address and port and connect with a timeout. It's not
conclusive proof of a port being open or closed (there's no way to get
conclusive proof), but does the job. If it fails to connect before the
timeout, you get a delegate message.

On Mon, Sep 7, 2009 at 4:56 PM, Ashley Perrien perr...@earthlink.netwrote:

 I'm very new to networking via cocoa and need to develop a small port
 scanner application. The core of it is very simple, is address 1.2.3.4
 listening on port X. I've done a bit of looking on NSStream, pipes, tasks
 and such but hopefully what I'm trying to get is a short and sweet. What
 specifically should I be checking into or does anyone happen to have a
 snippet of code that does the above?

 Ashley Perrien
 Random Quote of the day:
 No prizes for predicting rain. Prizes only awarded for building arks.

 ___

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

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

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

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




-- 
Brent Gulanowski
___

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

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


(no subject)

2009-09-07 Thread Colin Deasy


Does the returned obj from this method:
- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object
require a release?
ThanksColin
_
Share your memories online with anyone you want.
http://www.microsoft.com/ireland/windows/windowslive/products/photos-share.aspx?tab=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


NSImage rotation regression?

2009-09-07 Thread Marco S Hyman

This image rotation code works when compiled with the 10.5
SDK (64-bit, garbage collected).

- (NSImage *) rotateImage: (NSImage *) anImage
  byDegrees: (CGFloat) degrees
{
// create an image for the rotated size
NSSize originalSize = [[anImage bestRepresentationForDevice:nil]  
size];

NSSize rotatedSize;
if (degrees == 180.0)
rotatedSize = NSMakeSize(originalSize.width, originalSize.height);
else
rotatedSize = NSMakeSize(originalSize.height, originalSize.width);
NSImage *rotatedImage = [[NSImage alloc] initWithSize:  
rotatedSize];


[rotatedImage lockFocus];

NSAffineTransform* transform = [NSAffineTransform transform];
NSPoint centerPoint = NSMakePoint(rotatedSize.width / 2,
  rotatedSize.height / 2);
[transform translateXBy: centerPoint.x yBy: centerPoint.y];
[transform rotateByDegrees: degrees];
[transform translateXBy: -centerPoint.y yBy: -centerPoint.x];
[transform concat];

NSRect rect = NSMakeRect(0, 0, originalSize.width,  
originalSize.height);

[[anImage bestRepresentationForDevice:nil] drawInRect: rect];

[rotatedImage unlockFocus];
return rotatedImage;
}

When the returned image is put in an NSImageView with -setImage: it  
shows

up rotated and centered as expected.   The same code does not work
when the SDK is changed to 10.6.   The image is not rotated.  If I move
-lockFocus to immediately before -drawInRect: the image is rotated, but
not scaled to fit in the NSImageView.   Instead  its origin is placed at
the lower left of the view with the upper portion of the image clipped.

Any pointers on where to look and what to read?  I see that
-bestRepresentationForDevice: is deprecated and I've also read of some
underlying drawing changes, but don't understand how that may effect
my code.

Thanks,

/\/\arc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Turn on zombies in user environment?

2009-09-07 Thread Graham Cox


On 08/09/2009, at 5:27 AM, Kyle Sluder wrote:

IIRC the default shell on Jaguar and earlier was tcsh. If you've  
upgraded your Mac throughout the ages, that might have stuck.


--Kyle Sluder



Indeed, it was set to tcsh. I have upgraded a few times but I  
generally set up a new Mac by copying files from my previous one, so I  
guess the setting was copied too.


Thanks all, I have it working.

--Graham


___

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

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

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

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


Re: NSKeyedUnarchiver and memory management

2009-09-07 Thread Graham Cox


On 08/09/2009, at 7:53 AM, DKJ wrote:


- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
theData = [[aDecoder decodeObjectForKey:@theData] retain];
return self;
}

This is how I read the object from disk:

MyObject *myob = [NSKeyedUnarchiver unarchiveObjectWithFile:filepath];

(Garbage collection is not activated.) My understanding of the  
memory management rules is that I don't need to release myob. And I  
get EXC_BAD_ACCESS errors when I do.


But Instruments is complaining about a memory leak, and mentions  
NSKeyedUnarchiver. The retain message in the initWithCoder makes  
me wonder.


Is this code leaking? Should I add an autorelease to the retain in  
initWithCoder?



Yes, you could keep guessing, making wild stabs in the dark without  
really understanding it until it seems to work. Or you could get your  
nose into the documentation and work it out ;-)


Your initWithCoder method is fine, assuming of course that you release  
'theData' in your dealloc method. Hint: make 'theData' a retained  
property and it becomes much easier to manage.


The problem is in the other line you posted. [NSKeyedUnarchiver  
unarchiveObjectWithData:] does not contain the word 'alloc', 'new' or  
'copy' therefore you do not own the object it returns. If you'd like  
to, you need to retain it, and that would later be balanced by a - 
release when you are no longer interested in it. Releasing without a  
retain is an over-release and will cause the EXC_BAD_ACCESS.


--Graham


___

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

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

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

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


Strangest UITable bug

2009-09-07 Thread Development

Ok I have the weirdest UITableViewBug..
I've set up the delegate, datasource, etc. My data appears correctly  
in the table. HOWEVER, when I click the table once, it ignores the  
first click. Then, if I click it again on a different cell, it shows  
that I clicked the previous cell. In fact each subsequent touch shows  
that I clicked the cell just previous to it. I have no clue how I  
managed to screw up a tableview like this but does any one have any  
idea how I might have done this?


___

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

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

2009-09-07 Thread Erik Buck
The -bestRepresentationFirDrevice: method is doing nothing better than  
[anImage size] would do for you.


You are not doing anything useful with rotatedSize in your code.

Your test for if (degrees == 180.0) is completely pointless. If you  
were going to do it anyway, you should be looking for 90, 180, and 270  
degrees as well as all other multiples of 90 deg.


Why do you copy originalSize into rect?



How about the following alternative code typed in Mail

@implementation NSImage (MYAdditions)

- (NSImage *)copyRotatedByDegrees:(CGFloat)degrees
{
   NSSize originalSize = [self size];
   NSRect originalRect = NSMakeRect(0.0, 0.0, originalSize.width,  
originalSize.height);

   NSSize halfOriginalSize = NSMakeSize(originalSize.width / 2.0,
originalSize.height / 2.0);

   NSAffineTransform* transform = [NSAffineTransform transform];
   [transform rotateByDegrees: fmod(degrees, 45.0)];

   NSSize halfRotatedSize = [transform transformSize:halfOriginalSize];
   NSSize rotatedSize = NSMakeSize( (2.0 * halfRotatedSize.width),  
(2.0 * halfRotatedSize.height));

   [transform rotateByDegrees: -fmod(degrees, 45.0)];

   NSImage *rotatedImage = [[[NSImage alloc]  
initWithSize:rotatedSize] autorelease];

   [rotatedImage setBackgroundColor:[NSColor clearColor]];

   [rotatedImage lockFocus];
   [transform translateXBy:halfRotatedSize.width  
yBy:halfRotatedSize.height];

   [transform rotateByDegrees: degrees];
   [transform translateXBy: -halfRotatedSize.width yBy: - 
halfRotatedSize.height];

   [transform concat];
   [self drawAtPoint:NSZeroPoint fromRect:originalRect
   operation:NSCompositeSourceOver fraction:1.0];
   [[NSColor blackColor] set];
   NSFrameRect(originalRect);
   [rotatedImage unlockFocus];

   return rotatedImage;
}

@end




___

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

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

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

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


Re: NSImage rotation regression?

2009-09-07 Thread Marco S Hyman


On Sep 7, 2009, at 2:16 PM, Erik Buck wrote:

The -bestRepresentationFirDrevice: method is doing nothing better  
than [anImage size] would do for you.


Correct in its first use, incorrect for it's second use.  That
doesn't resolve the issue.


You are not doing anything useful with rotatedSize in your code.


   NSImage *rotatedImage = [[NSImage alloc] initWithSize: rotatedSize];

Looks like I'm doing something with it there, no?

Your test for if (degrees == 180.0) is completely pointless. If you  
were going to do it anyway, you should be looking for 90, 180, and  
270 degrees as well as all other multiples of 90 deg.


Rotated size swaps X and Y for other than 180 degree rotations.
There is an assumption in the code that rotations will only be
mod 90 degrees. I left the comment out that says this in the code
posted to the list.  Oops.


Why do you copy originalSize into rect?


OK, that one I can't answer other to say because the code I copied
did that :-)  Since it worked in the 10.5 SDK I didn't much question
what was going on.


How about the following alternative code typed in Mail


I'll play with that once I understand what it is doing.  Thanks.

/\/\arc

___

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

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

2009-09-07 Thread Hank Heijink (Mailinglists)
Do you want help guessing or help solving? If you're after the latter,  
you should post your code.


Hank

On Sep 7, 2009, at 9:10 PM, Development wrote:


Ok I have the weirdest UITableViewBug..
I've set up the delegate, datasource, etc. My data appears correctly  
in the table. HOWEVER, when I click the table once, it ignores the  
first click. Then, if I click it again on a different cell, it shows  
that I clicked the previous cell. In fact each subsequent touch  
shows that I clicked the cell just previous to it. I have no clue  
how I managed to screw up a tableview like this but does any one  
have any idea how I might have done this?


___

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

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

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


This email sent to hank.l...@runbox.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


UIWebView height calculation

2009-09-07 Thread Dragos Ionel
Hi,

1. I am trying to find how much text fits in a UIWebView of a certain
size (let's say 320x400).

For this, I am using a UIWebViewDelegate in the following way:

- (void)webViewDidFinishLoad:(UIWebView *)webView{
   //...
  CGSize size = [webView sizeThatFits:CGSizeZero];

  int h = size.height;

  if(h=maxHeight) {
    //add another character to the string htmlContent
    ...
  } else {
     //reached the maximum height, do nothing
     return;
  }

  [webView loadHTMLString:htmlContent baseURL:[NSURL URLWithString:@]];
}

Is it a good idea to call loadHTMLString from a delegate?

The delegate is supposed to run in a different thread than the main one


2. Is there a simpler way to find how much content can fit in a UIWebView?

Thanks a lot,
Dragos
___

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

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

2009-09-07 Thread Alex Kac

- (void) webViewDidFinishLoad:(UIWebView *)sender {
	[self performSelector:@selector(calculateWebViewSize) withObject:nil  
afterDelay:0.1];

}

- (void) calculateWebViewSize {
//size the notes view
	float newHeight = [[notesWebView  
stringByEvaluatingJavaScriptFromString 
:@document.documentElement.scrollHeight] floatValue];

}


On Sep 7, 2009, at 9:16 PM, Dragos Ionel wrote:


Hi,

1. I am trying to find how much text fits in a UIWebView of a certain
size (let's say 320x400).

For this, I am using a UIWebViewDelegate in the following way:

- (void)webViewDidFinishLoad:(UIWebView *)webView{
   //...
  CGSize size = [webView sizeThatFits:CGSizeZero];

  int h = size.height;

  if(h=maxHeight) {
//add another character to the string htmlContent
...
  } else {
 //reached the maximum height, do nothing
 return;
  }

  [webView loadHTMLString:htmlContent baseURL:[NSURL  
URLWithString:@]];

}

Is it a good idea to call loadHTMLString from a delegate?

The delegate is supposed to run in a different thread than the main  
one



2. Is there a simpler way to find how much content can fit in a  
UIWebView?


Thanks a lot,
Dragos
___

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

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

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

This email sent to a...@webis.net


Alex Kac - President and Founder
Web Information Solutions, Inc.

Forgiveness is not an occasional act: it is a permanent attitude.
-- Dr. Martin Luther King




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Andy Lee

On Sep 7, 2009, at 5:31 PM, Jens Alfke wrote:

On Sep 7, 2009, at 1:37 PM, Chilton Webb wrote:

I have a situation where if I try to set the key equivalent of a  
menu to 3 or 4, it just won't happen. any other number--it works  
just fine.


There are probably some other menu commands that already have those  
key equivalents. I suspect the Services submenu. I'm not sure  
whether services override regular menu commands or the other way  
'round, but that sounds like what's happening in your case.


I suspect Jens is right.  Command-3 is definitely okay for  
applications.  The Finder has used it forever, and it works in my  
application (as does Command-4).


It looks like you're running Snow Leopard, so maybe go into System  
Preferences - Keyboard - Keyboard Shortcuts and see if Command-3 and  
Command-4 are mapped to a Service (or anything else, for that matter)?


By the way, this isn't related, but you don't need to do [NSString  
stringWithFormat:@5].  You can just say @5.


--Andy


___

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

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

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

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


Re: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Andy Lee


On Sep 7, 2009, at 10:35 PM, Andy Lee wrote:


On Sep 7, 2009, at 5:31 PM, Jens Alfke wrote:

On Sep 7, 2009, at 1:37 PM, Chilton Webb wrote:

I have a situation where if I try to set the key equivalent of a  
menu to 3 or 4, it just won't happen. any other number--it works  
just fine.


There are probably some other menu commands that already have those  
key equivalents. I suspect the Services submenu. I'm not sure  
whether services override regular menu commands or the other way  
'round, but that sounds like what's happening in your case.


I suspect Jens is right.  Command-3 is definitely okay for  
applications.  The Finder has used it forever, and it works in my  
application (as does Command-4).


It looks like you're running Snow Leopard, so maybe go into System  
Preferences - Keyboard - Keyboard Shortcuts and see if Command-3  
and Command-4 are mapped to a Service (or anything else, for that  
matter)?


Hm, it looks like app menus override Services menus.  According to my  
System Preferences, Command-Shift-Y is the shortcut for Make New  
Sticky Note.  I tried it in Mail and it did the Mail thing, which was  
Message - Add Sender to Address Book.  I tried it in Safari and it  
created a new Sticky.  I guess this makes sense.  So it isn't Services  
after all.


Are you positive you don't have Command-3 and Command-4 mapped to  
something else?


--Andy




By the way, this isn't related, but you don't need to do [NSString  
stringWithFormat:@5].  You can just say @5.


--Andy


___

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

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

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

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


NSImage with Core Foundation Console Application failed?

2009-09-07 Thread DairyKnight
Hi all,

I'm trying to use NSImage in a Cocoa Console App, but every time I tried to
save the NSImage into a file through NSImageRep, it failed with
NSData.length = 0.

This is what I did:

NSImage *surface = [[NSImage alloc] initWithSize:NSMakeSize(786 * 2, 1144 *
2)];


NSBitmapImageRep *jpgRep = [NSBitmapImageRep imageRepWithData:[surface
TIFFRepresentation]];

NSDictionary *jpgProp = [NSDictionary dictionaryWithObject:[NSNumber
numberWithFloat:0.7] forKey:NSImageCompressionFactor];

NSData *dat = [jpgRep representationUsingType:NSJPEGFileType properties
:jpgProp];

if ([dat length] == 0)

NSLog(@Data is zero);

[dat writeToFile:@dummyfile.jpg atomically:YES];


Anyone knows why? 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: NSImage with Core Foundation Console Application failed?

2009-09-07 Thread Kyle Sluder

On Sep 7, 2009, at 8:08 PM, DairyKnight dairykni...@gmail.com wrote:



NSBitmapImageRep *jpgRep = [NSBitmapImageRep imageRepWithData:[surface
TIFFRepresentation]];


Is -TIFFRepresentation returning nil?

--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: KVO on Distributed Objects with exception handling.

2009-09-07 Thread Scott Anguish

In spite of the fact that it might be working, it isn't supported.

When I talked to engineering about this, this is what I was told. He  
was a bit shocked it worked at all, and it isn't tested as part of  
releases.




On Sep 7, 2009, at 3:02 PM, Edward Chan wrote:


Hello,

I'm using KVO on a Distributed Object, and I am binding my UI controls
based on the observer.

For example:

MonkeyViewController.isEatingABanana - Binded to a UI checkbox.

MonkeyViewController.m:

@propery (readwrite, assign) BOOL isEatingABanana;

-(id)init {
...
[MonkeyBrainDOObject addObserver:self
forKeyPath:@banana
options:(NSKeyValueObservingOptionNew |
   NSKeyValueObservingOptionOld)
   context:NULL];

...
}

- (void)observeValueForKeyPath:(NSString *)keyPath
 ofObject:(id)object
   change:(NSDictionary *)change
  context:(void *)context
{
  if ([keyPath isEqualToString:@banana]) {
 [self willChangeValueForKey:@isEatingABanana];
 isEatingABanana = [change objectForKey:NSKeyValueChangeNewKey]  
boolValue];

 [self didChangeValueForKey:@isEatingABanana];
 }
}

- (void)setIsEatingABanana:(BOOL)flag
{
[MonkeyBrainDOObject setBanana:flag];
isEatingABanana = flag;
}


This indeed works, and we save some hassles of sending  
NSNotifications and such.


So, what I'm wondering is if the following code is sufficient enough
for the IPC exception handling?
Instead of having to manually write @try/@catch wherever I doing some
IPC, I create a wrapper object around the DO to handle the exceptions.
This wrapper class is simply an NSObject, and will call the methods
methodSignatureForSelector, and forwardInvocation when I try to use
MonkeyBrainDOObject methods (since the wrapper does not understand
them). I can then insert a @try/@catch when I forward the invokations
to the actual DO object.

MonkeyBrainWrapper.m : NSObject

- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
   return [MonkeyBrainDOObject methodSignatureForSelector:selector];
   // maybe I can use extra code to make sure MonkeyBrainDOObject
responds to the selector.
}

- (void)forwardInvocation:(NSInvocation *)invocation
{
  @try {
 [invocation invokeWithTarget:MonkeyBrainDOObject];
  } @catch (NSException *e) {
  // Oh no! some went wrong with the IPC. But it's ok, I caught  
you.. :P

  }
}

So, instead of calling directly on the MonkeyBrainDOObject in my
MonkeyViewController, I would now call my MonkeyBrainWrapper object,
which has explicit exception handling rather than the one handle by
the NSApplication.


Should that be enough for exception handling on both ends of the IPC?
Or do I need some explicit exception handling on the other end? It
seems when I tested it out, my other end never threw anything when the
connection broke.
Also, is there maybe a better approach to all of this? My old code had
a bunch of NSNotifications being sent/received whenever something
needed updating on the UI, and I found this approach to be a lot
cleaner.

Edward
___

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

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

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

This email sent to sc...@cocoadoc.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: KVO on Distributed Objects with exception handling.

2009-09-07 Thread Scott Anguish


On Sep 7, 2009, at 4:45 PM, Edward Chan wrote:


Great...

How long ago did you ask the Apple engineers? I haven't tried this
piece of code with Snow Leopard actually...




It still isn't supported in SL. I'd be shocked if it ever is.

___

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

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


NSController's class accessing NSDocument methods

2009-09-07 Thread BareFeet

Hi all,

I have a fairly simple app, with an Entity table and a DataRows table  
(each has a controller), set up using bindings (no Core Data). I've  
set it up so when I select an Entity in the Entities table, the  
DataRows table refreshes by calling my Entity.selection.dataRows  
accessor method.


I have a MyDocument/File's Owner, NSOutlineView and bound  
NSTreeController in a nib file. The outline/table shows a list of  
Entities (nothing to do with Cocoa or CoreData) in the current  
document/file. I have successfully set up accessor methods for  
properties of Entity such as name and type. But I'm trying to set up  
another accessor method (dataRows) that depends on the document path.  
I can't see how to access the NSDocument methods from an Entity within  
it. How is it done?


Here's some code:

//  Entity.h

#import Cocoa/Cocoa.h

@interface Entity : NSObject
{
}

@property (retain) NSString* type;
@property (retain) NSString* name;

@property (retain) NSMutableArray* dataRows;

@end


//  Entity.m

#import Entity.h
#import MyGenerator.h

@implementation Entity

@synthesize type;
@synthesize name;

@synthesize dataRows;

- (NSMutableArray*) dataRows
{
// ***
// I need this next line to instead get the path of the document that
// shares the controller's nib, rather than being hard coded.
// Something like: fileString = [[linkToDocument fileURL] path]
// ***

NSString* fileString = @/Users/tom/Documents/MyFile.sqlitedb;

NSString* selectedEntityName = [self name];
	NSMutableArray* dataRowsArray = [MyGenerator  
dataRowsGivenFilePath:fileString entityName:selectedEntityName];

return dataRowsArray;
}

Thanks in advance,
Tom
BareFeet

___

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

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


Framework versioning and handling multiple OS SDK's?

2009-09-07 Thread aaron smith
Hey All,

I've got a framework (GDKit) that I maintain - started writing it on
10.5. I'm running into something I'm not sure how to handle.

-So far, everything I've been writing in GDKit links against 10.5, and
applications I've been writing link against GDKit, and 10.5.
-I have some new classes I want to add to the framework, but some of
the API's are in 10.6 only.
-The new classes and features in my framework are optional - because
they require 10.6, but I don't want to have to change all of my
applications to require 10.6.

What I'm trying to figure out is how to keep the framework compiling
for 10.5, but optionally including the new features/classes when it's
compiling for 10.6.

There's just a few things I'm unclear of..

-When it's compiling for 10.5, can I completely exclude files from
compiling (the 10.6 features)? Is that the right way to exclude
features?
-When I link against GDKit from an application, how can I have the app
link against GDKit that include only the 10.5 features? Or optionally
link against the build that includes the 10.6 features?

I've been reading about framework versioning, and what they recommend
is creating a new major version. But that doesn't really help my
problem - as creating a new major version would require the 10.6 SDK.
Hopefully that makes sense.

Does anyone know of any blog posts or tutorials about this particular situation?

Any ideas would be sweet.
___

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

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

2009-09-07 Thread Ken Ferry
Hi Marco,
I dropped the code below in a test app, and it seemed to work fine on 10.6
with 90 as the number of degrees.

Perhaps you could make a full test app that demonstrates the issue?

-Ken

On Mon, Sep 7, 2009 at 4:21 PM, Marco S Hyman m...@snafu.org wrote:

 This image rotation code works when compiled with the 10.5
 SDK (64-bit, garbage collected).

 - (NSImage *) rotateImage: (NSImage *) anImage
  byDegrees: (CGFloat) degrees
 {
// create an image for the rotated size
NSSize originalSize = [[anImage bestRepresentationForDevice:nil] size];
NSSize rotatedSize;
if (degrees == 180.0)
rotatedSize = NSMakeSize(originalSize.width, originalSize.height);
else
rotatedSize = NSMakeSize(originalSize.height, originalSize.width);
NSImage *rotatedImage = [[NSImage alloc] initWithSize: rotatedSize];

[rotatedImage lockFocus];

NSAffineTransform* transform = [NSAffineTransform transform];
NSPoint centerPoint = NSMakePoint(rotatedSize.width / 2,
  rotatedSize.height / 2);
[transform translateXBy: centerPoint.x yBy: centerPoint.y];
[transform rotateByDegrees: degrees];
[transform translateXBy: -centerPoint.y yBy: -centerPoint.x];
[transform concat];

NSRect rect = NSMakeRect(0, 0, originalSize.width, originalSize.height);
[[anImage bestRepresentationForDevice:nil] drawInRect: rect];

[rotatedImage unlockFocus];
return rotatedImage;
 }

 When the returned image is put in an NSImageView with -setImage: it shows
 up rotated and centered as expected.   The same code does not work
 when the SDK is changed to 10.6.   The image is not rotated.  If I move
 -lockFocus to immediately before -drawInRect: the image is rotated, but
 not scaled to fit in the NSImageView.   Instead  its origin is placed at
 the lower left of the view with the upper portion of the image clipped.

 Any pointers on where to look and what to read?  I see that
 -bestRepresentationForDevice: is deprecated and I've also read of some
 underlying drawing changes, but don't understand how that may effect
 my code.

 Thanks,

 /\/\arc

 ___

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

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

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

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

___

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

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

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

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


Re: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Chilton Webb

Hi guys!

Mystery solved--it was something already assigned to that in a menu  
deep in a nested menu, inside the NIB. I had to comb through the  
designable.nib in a text editor, actually, to find it.


So for future reference, not being able to set a menu can be caused by  
another menu item being set to it, elsewhere.


This isn't the first time I've seen this, duplicate settings for key  
equivalents actually caused a recurring crash in an earlier version of  
the app (last week).


So that's all it was.

Thanks everyone for your help!
-Chilton
___

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

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

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

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


Re: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Andy Lee

On Sep 8, 2009, at 12:13 AM, Chilton Webb wrote:
I realize it's not immediately evident, but I'm inside a for loop,  
and I'm checking to see if 'i' is less than 9 prior to doing this.


If it is, in my original code, I would use @%d, i there to  
increase the numbers as it goes down the list.


Ah, I see.

Could this be a problem with the NIB? I'm really grasping at straws  
here--this should 'just work'.


I was about to suggest grepping the nib for 3 and 4, but I see  
you've already solved it.


--Andy


___

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

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

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

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


Re: Menu Weirdness (can't set command + 3 or command + 4)

2009-09-07 Thread Chilton Webb

Hi Andy and Jens,

Thank you for your replies.

It's not something system-wide, as I CAN set it to things like command 
+shift+3. That works fine, oddly enough. And if I set it to all of any  
one number, obviously it lets me set it to those numbers, even though  
they're already in use farther up the menu.


The only problem is that it won't show command+3 and command+4

Furthermore, this works fine in a test app I wrote that just populates  
the menus. It even uses the same code. So it's definitely not system- 
wide.


On Sep 7, 2009, at 9:35 PM, Andy Lee wrote:
By the way, this isn't related, but you don't need to do [NSString  
stringWithFormat:@5].  You can just say @5.


I realize it's not immediately evident, but I'm inside a for loop, and  
I'm checking to see if 'i' is less than 9 prior to doing this.


If it is, in my original code, I would use @%d, i there to increase  
the numbers as it goes down the list. That's where I'm seeing this--my  
finished product works great if you want to use command+anything  
except 3 and 4.


Could this be a problem with the NIB? I'm really grasping at straws  
here--this should 'just work'.


Thanks!
-Chilton
___

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

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

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

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


Re: Weird malloc error when dealing with lots of NSImage objects

2009-09-07 Thread DairyKnight
I found the problem. It seems rather than autoreleasing the outputBitmapRep,
I should first CGImageReleasethe 'thickenedCGImg'. This creates a dilemma
because thickenedCGImg lies inside a function.

I have to change the function to return a CGImage instead. From Apple's
Cocoa document, it says the
NSImageBitmapRep which [NSImgRep CGImage] returns is 'Readonly', so that
probably means releasing
the object doesn't release the correspondent CGImage.




On Tue, Sep 8, 2009 at 12:06 AM, Bill Bumgarner b...@mac.com wrote:

 On Sep 7, 2009, at 4:45 AM, DairyKnight wrote:

  FooProgram(1343,0xa01e1720) malloc: *** mmap(size=30855168) failed (error
 code=12)

 *** error: can't allocate region

 *** set a breakpoint in malloc_error_break to debug

 2009-09-07 19:37:17.606 KindPDF[1343:10b] ***
 NSCopyMemoryPages(0xfc18a000,
 0x0, 30851072) failed


 You have run out of memory and the allocator has failed.  In this case, it
 is a memory-mapped file that is failing which leads to a call to
 NSCopyMemoryPages() with an address of 0x0 as the destination.

 Either your app is leaking memory -- which may be in the form of
 over-caching -- or you are simply trying to shove too much stuff into memory
 at the same time.

 Use Instruments' Object Alloc instrument to see what is chewing up the
 space.

 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: Problem with LSSharedFileListInsertItemURL() usage. (API in LaunchServices/LSSharedFileList.h)

2009-09-07 Thread Parimal Das
The 'url' path is correct as it is adding my app to the login item list,
I suspect that, as i am calling this method in awakeFromNib: , dock is
getting created first and then the app is getting added in the login item
list.

Can you suggest some events, which can be called before app generates its
dock icon.
I tried with applicationWillFinishLaunching,  but did not work for me.

Any insights??

-Parimal

On Mon, Sep 7, 2009 at 9:58 PM, Steven Degutis steven.degu...@gmail.comwrote:

 Parimal,
 Your code looks complete and correct, so my only guess is that the
 variable url is not actually pointing to [[NSBundle mainBundle] bundleURL]
 which might explain it. (Then again, I've only ever dealt with manually
 adding my application to the Login Items programmatically in apps that had
 no Dock icon, and only used status bar items.)

 --
 Steven Degutis
 http://www.thoughtfultree.com/
 http://www.degutis.org/


 On Mon, Sep 7, 2009 at 6:10 AM, Parimal Das parimal@webyog.comwrote:

 Hello all,

 I am trying to do the following- when my app is used for the first
 time - *'open
 at login'* is selected by default. For that i am calling the code below
 for
 the app's first run.

 The code is working fine and my app is getting added in the login item
 list,
 But on ctrl+click on my apps dock icon, its failing to show 'open at
 login'
 as selected (tick mark)

 What i am missing here??
 Please guide.

 *LSSharedFileListRef loginListRef = LSSharedFileListCreate(NULL,
 kLSSharedFileListSessionLoginItems, NULL);
 if (loginListRef) {
 // Insert the item at the bottom of Login Items list.
LSSharedFileListItemRef loginItemRef =
 LSSharedFileListInsertItemURL(loginListRef,

 kLSSharedFileListItemLast,

 NULL,

 NULL,

 (CFURLRef)url,  // url is my app location

 NULL,

 NULL);

if (loginItemRef) {
CFRelease(loginItemRef);
}

 CFRelease(loginListRef);
}*


 Advance Thanks
 -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/steven.degutis%40gmail.com

 This email sent to steven.degu...@gmail.com







-- 
--
Warm Regards,

Parimal Das
Webyog Softworks
___

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

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