Re: Changing NSTableView cell immediately before editing

2009-03-04 Thread Paul Sanders
> Thanks for this.  I think this would solve part of the problem (when
> it was clicked on by the user), but not if the text edit field were
> selected in some way other than a mouse click.

I thought about this a little bit too.  It seems to me that the change in 
firstResponser is the key to this.  I don't know how to trap this - I'm new 
to Cocoa - but maybe that observation helps a bit.

Rgds - Paul. 

___

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

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

Help/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: where to store this kind of data

2009-03-04 Thread Andreas Mayer


Am 03.03.2009 um 23:17 Uhr schrieb Benjamin Dobson:


Store it in ~/Library/Application Support/YourAppName/


And make sure not to hard code the path.

See the NSSearchPathForDirectoriesInDomains() function and NSString's - 
stringByAppendingPathComponent:.



Andreas
___

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

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

Help/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: "setAffineTransform:" behaves differently around "setLayer:"

2009-03-04 Thread rajesh

I tried changing some lines
[self setWantsLayer:YES];
pages = [[NSMutableArray alloc] init];
drawLayer = self.layer;
	drawLayer.backgroundColor = CGColorCreateGenericRGB(1.0f,1.0f,1.0f, 
1.0f);
	CGAffineTransform  trans =  
CGAffineTransformMake(1.0,0.0,0.0,-1.0,0.0,0.0);

self.layer.affineTransform =   trans;

but the layers appear only after resizing the view and not to mention  
scrolling totally messes with the sublayer and they just disappear, i  
need to resize the view to make the sublayers appear again.


Any help is appreciated.

Thanks
Rajesh
On Mar 3, 2009, at 10:43 AM, rajesh wrote:


Hi All,

I am stuck again at seemingly obvious point, but I can't figure out  
where


In MyView Class , below lines work fine for flipping the layer (but  
whenever I try to resize or add a subLayer to it, view flashes for  
the reason I don't know)


-(void)awakeFromNib{
drawLayer = [CALayer layer];
drawLayer.backgroundColor = CGColorCreateGenericRGB(1.0f,1.0f,1.0f, 
1.0f);

CGAffineTransform transform = CGAffineTransformIdentity;
/*	CGAffineTransform transform = CGAffineTransformMake (1.0f,0.0f, 
0.0f,-1.0f,0.0f,0.0f); */

transform.d = -1.0f;
drawLayer.affineTransform = transform;
[self setLayer:drawLayer];
[self setWantsLayer:YES];
}

but when I try to check the flag uses CoreAnimation layer in  
interface builder for MyView and use below lines


-(void)awakeFromNib
{
drawLayer = [self layer];
drawLayer.backgroundColor = CGColorCreateGenericRGB(1.0f,1.0f,1.0f, 
1.0f);

CGAffineTransform transform = CGAffineTransformIdentity;
transform.d = -1.0f;
drawLayer.affineTransform = transform;
}

now I don't see any layer added , if I omit the affineTransform  
part , then view behaves perfectly with no flashes whatsoever but  
layer isn't flipped.


Thanks in advance for any help.

~Rajesh
___

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

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

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

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


SyncServices ...

2009-03-04 Thread Mic Pringle
Hi,

I've been searching around for sometime trying to find an example of
using sync services with Safari's bookmarks. Does anyone know of one,
or any information that may help with this particular task ?

Also, is it possbile to have a client sync with more than one other
client ? I have a user-agent that run in the background and
periodically downloads some updates to information stored via CoreData
and then syncs this with a GUI app, so that when the user opens the
GUI they are always presented with the most up to date information.
What I'd also like to do is have the user-agent sync with Safari's
bookmarks too. So it would have two things to sync, Safari & the GUI
app. Is this possible ?

Thanks

-Mic
___

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

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

Help/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: Newbie: Learning path for my GTD app...

2009-03-04 Thread Mike Abdullah


On 4 Mar 2009, at 05:40, Biagio wrote:


Hello.  My first post.  I'm learning to program using Xcode 3.1.2 in
OS X Leopard. My current plan of attack is working through these
books:

Learn C on the Mac
C All in One Desktop Reference for Dummies
Learn Objective-C On the Mac
Cocoa Programming for Mac OS X 3rd edition by Aaron Hillegass

I decided to make my "long term" learning goal the coding of a
simplified GTD app (ala iGTD/Things/EasyTask) that is designed around
my quirks and a few features I wish my app had. I realize this won't
be easy.  From my initial research, it seems I'll need to really focus
on Core Data, and possibly the use of OpenBase or some other type of
SQL technology.  I admit, I'm a bit overwhelmed, and would just like
some guidance as to where to focus my attention after I get through
the above books.  Any thoughts would be much appreciated.


Trust me, you really don't want to start learning Core Data at this  
stage. As the docs clearly state, it is an advanced technology.  
Instead, I would suggest that you implement your application using a  
technology like NSCoding for persisting your GTD data. This should be  
plenty fast to start with, much simpler to implement, and then  
valuable experience for optimising performance later.


Mike.
___

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

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

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

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


Date parsing problem (when running on iphone only)

2009-03-04 Thread Jacob Rhoden
Anyone experience this weird behaviour with date formatting? Given the 
following code, it produces a different log output when running in the 
simulator or on the iPhone!!!


NSString* test = @"Monday 26 January 2009 3:47:33 pm +";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat: @" dd   h:mm:ss a Z"];
NSLog(@"DATE: %@ to %i", test, [df dateFromString: test]);

This is the NSLog output on the iphone:
2009-03-04 22:08:49.645 Test[2875:20b] DATE: Monday 26 January 2009 
3:47:33 pm + to 0


And this on the simulator:
2009-03-04 22:09:05.095 Test[68041:20b] DATE: Monday 26 January 2009 
3:47:33 pm + to 5432224


Im completely stuck on this one! Are are there any other easy ways to 
parse dates? Any help appreciated.


Thanks,
Jacob


Jacob Rhoden  http://jacobrhoden.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: Moving oneself to /Applications (or ~/Applications)

2009-03-04 Thread Jeremy Pereira
If you really want to test whether an application is running from the  
distribution dmg, I would have thought the easiest way is to put a  
hidden file on the dmg in the same directory as the application bundle  
and merely test for the existence of that hidden file at start up.



On 24 Feb 2009, at 02:34, Shawn Erickson wrote:


On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
 wrote:

The following code will test if you are running from the DMG:

NSString * volName = @"Mother";
NSString * appName = @"MyApp.app";

if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {

 //Here you can show an alert telling the user to to copy the  
app to

the applications folder

}


If a disk image it mounted a second time (can happen in a few ways) it
won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
can mount disk images in location other then under /Volumes/...

If you really want to check this you should utilize
DiskImages.framework (IIRC) or possibly use "hdutil info -plist" and
look for your disk image and its current mount location. Then compare
that to your bundles location.

-Shawn

For example...

MacPro:~ shawnce$ hdiutil info -plist

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


framework
195.2.2
images


autodiskmount

blockcount
1138724
blocksize
512
hdid-pid
7098
icon-path
			/System/Library/PrivateFrameworks/DiskImages.framework/ 
Resources/CDiskImage.icns

image-alias

AAFuAAIAAARNYWluAADD
STB4SCsDpvcQaVdvcmswOVRyaWFsLmRtZwAA
AMSJ
7MWHd2YAAP8AAAkgCURv
d25sb2FkcwAAEAAIAADDSZLoEQAIAADFh+fmAQAMAAOm
9wADClAAAHmMAAIALU1haW46VXNlcnM6c2hhd25jZTpEb3dubG9h
ZHM6aVdvcmswOVRyaWFsLmRtZwAADgAiABAAaQBXAG8AcgBrADAA
OQBUAHIAaQBhAGwALgBkAG0AZwAPAAoABABNAGEAaQBuABIAKFVz
ZXJzL3NoYXduY2UvRG93bmxvYWRzL2lXb3JrMDlUcmlhbC5kbWcA
EwABLwAAFQACAA7//wAA

image-encrypted

image-path

/Users/shawnce/Downloads/iWork09Trial.dmg
image-type
UDIF read-only compressed (zlib)
owner-uid
501
removable

system-entities


content-hint
Apple_partition_scheme
dev-entry
/dev/disk7


content-hint
Apple_partition_map
dev-entry
/dev/disk7s1


content-hint
Apple_Driver_ATAPI
dev-entry
/dev/disk7s2


content-hint
Apple_HFS
dev-entry
/dev/disk7s3
mount-point
/Volumes/iWork '09 Trial Install 
DVD


writeable



revision
10.5v195.2.2
vendor
Apple


___

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

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

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

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


___

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

Please do not post admin requests or moderator comments to the list.
Contact the

Re: Date parsing problem (when running on iphone only)

2009-03-04 Thread Jacob Rhoden

On 4/3/09 10:15 PM, Jacob Rhoden wrote:
Anyone experience this weird behaviour with date parsing? Given the 
following code, it produces a different log output when running in the 
simulator or on the iPhone!!!


NSString* test = @"Monday 26 January 2009 3:47:33 pm +";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat: @" dd   h:mm:ss a Z"];
NSLog(@"DATE: %@ to %i", test, [df dateFromString: test]);

This is the NSLog output on the iphone:
2009-03-04 22:08:49.645 Test[2875:20b] DATE: Monday 26 January 2009 
3:47:33 pm + to 0


And this on the simulator:
2009-03-04 22:09:05.095 Test[68041:20b] DATE: Monday 26 January 2009 
3:47:33 pm + to 5432224
It seems that if you have your Regional settings to Chinese the date is 
not parsed. What is the proper way to parse an "English" formatted date?


Thanks,
Jacob

--

Jacob Rhoden  http://jacobrhoden.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


Mouse Dragged Event not working using CGEvent

2009-03-04 Thread sheen mac

Hi All,

I tried to post a mouse dragged event using CGEvent.But its not working.
I added the code here.

Thanks In Advance,
Sheen

CGEventRef  eventRef = CGEventCreateMouseEvent(NULL, 
kCGEventLeftMouseDragged , point,kCGMouseButtonLeft);
CGEventSetType(eventRef, kCGEventLeftMouseDragged); 
CGEventPost(kCGSessionEventTap, eventRef);
CFRelease(eventRef);




  
___

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

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

Help/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: Date parsing problem (when running on iphone only)

2009-03-04 Thread Michael Vannorsdel
You're trying to print an NSDate object returned by dateFromString:  
with a %i format which is for integers.  So the number you're seeing  
is the memory address of the returned date converted to an int.



On Mar 4, 2009, at 4:15 AM, Jacob Rhoden wrote:

Anyone experience this weird behaviour with date formatting? Given  
the following code, it produces a different log output when running  
in the simulator or on the iPhone!!!


   NSString* test = @"Monday 26 January 2009 3:47:33 pm +";
   NSDateFormatter *df = [[NSDateFormatter alloc] init];
   [df setDateFormat: @" dd   h:mm:ss a Z"];
   NSLog(@"DATE: %@ to %i", test, [df dateFromString: test]);

This is the NSLog output on the iphone:
2009-03-04 22:08:49.645 Test[2875:20b] DATE: Monday 26 January 2009  
3:47:33 pm + to 0


And this on the simulator:
2009-03-04 22:09:05.095 Test[68041:20b] DATE: Monday 26 January 2009  
3:47:33 pm + to 5432224


Im completely stuck on this one! Are are there any other easy ways  
to parse dates? Any help appreciated.


___

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

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

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

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


SOLVED Re: All my leaks are gone... but now a memory warning?!

2009-03-04 Thread James Cicenia

I used this after opening sqlite:

// Modify cache size so we don't overload memory. 50 * 1.5kb
if (sqlite3_exec(database, "PRAGMA CACHE_SIZE=50;", NULL, NULL, NULL) ! 
= SQLITE_OK) {
NSAssert1(0, @"Error: failed to set cache size with message '%s'.",  
sqlite3_errmsg(database));

}


Thanks
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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?

2009-03-04 Thread Eric Gorr

I have recently experienced some of these same issues.

You can check out the message:

http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00179.html

for what I was concerned with.

As best I can determine, a NSTextView relies upon a NSScrollView to  
handle it's scrolling behavior. Unfortunately, there does not appear  
to be any way to place a fieldEditor inside of a NSScrollView in order  
to provide this behavior - but I haven't had that confirmed by anyone.


What I ended up doing is creating a NSTextView inside of a  
NSScrollView on the fly and using that as my field editor.


Although, I suppose creating a NSTextField would have worked as  
well...I may try switching to that as it would be less code.



On Mar 3, 2009, at 10:04 PM, Luke Evans wrote:

I've been trying to implement label editing a la Finder, and found  
this useful so far:

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

Essentially, this approach uses the regular NSTextView instance  
served up by -[NSWindow fieldEditor:forObject], and recomputes the  
size of that is required for the current text.  You can then  
position the frame of the text view according to taste.  This works  
great up to the point where I limit the size of the text view  
reaches the maximum size for my "text area" (under the icon, like  
Finder).  What I'd like to have happen then is for the text to  
scroll like a multiline NSTextField, so that the caret remains in  
view, but instead the text view remains with its top lines visible,  
and the caret disappears below along with any typed text, clipped by  
the frame.


I'm beginning to think that I'm barking up the wrong tree hoping for  
text scrolling behaviour to appear from NSTextView.  I have no  
enclosing scroll view at the moment (though I suppose I could have a  
tiny one that has its scrollbar furniture turned off), and I see  
that NSTextView is a rather different animal to NSTextField (that  
owns a text field cell that in turn provides -setScrollable, which  
is what I think I want).   However, before I rip the current  
fieldEditor/NSTextView stuff apart and try again with creating an  
NSTextField on demand, I thought I'd seek a few simple answers:


- Is there any way to get NSTextView to have a text scrolling  
behaviour intrinsically?  Perhaps this is really only behaviour  
produced by an object, like a cell, that wraps the field editor when  
its hosted there.
- If this is a non-starter, is it best to create an NSTextField, or  
would an NSTextFieldCell work somehow on its own?


___

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

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

Help/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: Moving oneself to /Applications (or ~/Applications)

2009-03-04 Thread Sean McBride
On 3/4/09 11:37 AM, Jeremy Pereira said:

>If you really want to test whether an application is running from the
>distribution dmg, I would have thought the easiest way is to put a
>hidden file on the dmg in the same directory as the application bundle
>and merely test for the existence of that hidden file at start up.

But then what if I copy the mounted volume itself?  That invisible file
would come along.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

Help/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: binding to number of selected rows in a table

2009-03-04 Thread Sean McBride
On 3/3/09 6:38 PM, James Walker said:

>I want to use bindings to set certain control attributes (enabled state,
>tool tip) depending on the number of selected rows in an outline table.
>  I have a controller object that owns an NSOutlineView, and I gave it
>an accessor
>
>- (NSOutlineView*) outlineView;
>
>Then I tried to bind to my controller with key paths like
>outlineView.numberOfSelectedRows and outlineView.selectedRowIndexes, and
>using value transformers.  It looks like the bindings are setting the
>attributes appropriately once, but then not updating when the selection
>changes.  Are these NSOutlineView methods not KVO-friendly, or am I
>doing something wrong?

Are you using NSTreeController?  If so, you can bind to
selectionIndexPaths and use @count also.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

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


[Q] Responder Chain & makeFirstResponder

2009-03-04 Thread Eric Gorr

The documentation for NSWindow's makeFirstResponder states:

   If responder does not accept first responder status,
   the NSWindow object becomes first responder; in this
   case, the method returns YES even if responder
   refuses first responder status.

In my case, the behavior I would like to see if if responder does not  
accept first responder status, that the superview is made the first  
responder and if that fail's then it's superview is tried, etc.


It appears I can make this happen if I alter the the  
becomeFirstResponder method for the views whose superviews should  
actually be made the first responder to be the following:


- (BOOL)becomeFirstResponder
{
  return [[self window] makeFirstResponder:[self superview]];
}

However, this does not seem like it is the right way to do this. Or,  
is it?


The right thing to do may be to just store a variable with what I know  
should be made the first responder and just call makeFirstResponder on  
it, but I wasn't sure if this would be considered the right way either.



If you need more details on what I am doing, overall, what I am doing  
looks like:


http://ericgorr.net/cocoadev/outlinetable/outlineview.png

This is a custom implementation of a table of items. (If you need to  
know why, it is because none of the Apple supplied controls have all  
the features I need.)


The items in the table are:

http://ericgorr.net/cocoadev/outlinetable/namedparts.png
(although, the NSTextField is now just my own custom NSView  
(MyItemLabel) which draws text using a NSLayoutManager.)


Neither an item or the label of the image should ever be the first  
responder. What should become the first responder is my custom table.


When the user double-clicks on a label, I insert an editable  
NSTextView and make it the first responder. When the user presses  
return, MyItemLabel gets a textDidEndEditing: notification which  
removed the NSTextView being used to edit the text.


The question becomes how to get the first responder back to the table  
view where it belongs.


Before I had fully read the documentation on makeFirstResponder, I  
expected:


[[self window] makeFirstResponder:self];

which I placed in the textDidEndEditing: method, to automatically  
propagate first responder status up through the superviews. But, since  
MyItemLabel rejects first responder status, the window was being made  
the first responder.






___

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

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

Help/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: Odd crash

2009-03-04 Thread Reza Farhad

Paul

I switched on Guard Malloc from the Run Menu in Xcode

It appears that I am getting the crash for a call that is trying to  
load an AppleScript.


NSDictionary*errors = [ NSDictionary dictionary ];
	NSAppleScript 	*script = [[ NSAppleScript alloc ]  
initWithContentsOfURL:url error:&errors ];


I check the URL to make sure that it is valid.
Now if I dont use Guard Malloc the scripts load properly and I dont  
get any errors either.

So any ideas? Could I just by pass this in my exception handling?

Also is it a bad idea to leave MallocStackLogging,  
MallocStackLoggingNoCompact, MallocScribble in the release version.


Thanks
Reza

Does this make any sense to you. From that point the app goes into


On 3 Mar 2009, at 06:38, Paul Sanders wrote:

(Reza sent me the message below privately but I thought it might be  
useful
to copy the reply to the list.  Excuse me if you have heard it all  
before).



So you would think this is happening in the Exception Handling code?


No, I don't think it's happening on the exception handler.   I think  
that is
trapping it, rather than causing it.  To help track the problem  
down, take a

look at this:

http://developer.apple.com/technotes/tn2004/tn2124.html

As a starting point, try running your program under GDB with Guard  
Malloc
enabled.  This often traps memory allocation errors at source,  
although it

can slow things down a lot.  If that is too slow, try setting
MallocScribble, MallocPreScribble, MallocGuardEdges and  
MallocStackLogging

in your environment as described in the article.  You can set these
variables in XCode via Get Info - Arguements on your executable.   
Check out
also NSZombieEnabled, see http://www.cocoadev.com/index.pl?NSZombieEnabled 
.
When this is set in the environment, the runtime will trap any  
reference to

a freed object.

Hope this helps and thanks very much for sending me your code  - Paul.



___

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

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

Help/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: Date parsing problem (when running on iphone only)

2009-03-04 Thread Christopher Kane

On Mar 4, 2009, at 4:22 AM, Jacob Rhoden wrote:


On 4/3/09 10:15 PM, Jacob Rhoden wrote:
Anyone experience this weird behaviour with date parsing? Given the  
following code, it produces a different log output when running in  
the simulator or on the iPhone!!!


   NSString* test = @"Monday 26 January 2009 3:47:33 pm +";
   NSDateFormatter *df = [[NSDateFormatter alloc] init];
   [df setDateFormat: @" dd   h:mm:ss a Z"];
   NSLog(@"DATE: %@ to %i", test, [df dateFromString: test]);

This is the NSLog output on the iphone:
2009-03-04 22:08:49.645 Test[2875:20b] DATE: Monday 26 January 2009  
3:47:33 pm + to 0


And this on the simulator:
2009-03-04 22:09:05.095 Test[68041:20b] DATE: Monday 26 January  
2009 3:47:33 pm + to 5432224
It seems that if you have your Regional settings to Chinese the date  
is not parsed. What is the proper way to parse an "English"  
formatted date?



Yes, the date formatter you're creating defaults to using the user's  
locale, which can have settings which override even your attempt to  
set a specific format string.  Do this after creating the formatter:  
[df setLocale:[NSLocale systemLocale]]; to set a generic locale object  
on the formatter.


[This applies to Mac OS X as well as iPhone OS, it's just that iPhone  
OS tends to exercise such override settings more -- currently.]



Chris Kane
Cocoa Frameworks, Apple

___

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

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

Help/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: Odd crash

2009-03-04 Thread Sean McBride
On 3/4/09 3:36 PM, Reza Farhad said:

>Also is it a bad idea to leave MallocStackLogging,
>MallocStackLoggingNoCompact, MallocScribble in the release version.

They are environment variables, so do not affect the compilation/linking
of your app.  You can and should test both your debug and release builds
with these variables.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

Help/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: binding to number of selected rows in a table

2009-03-04 Thread Corbin Dunn


On Mar 3, 2009, at 6:38 PM, James Walker wrote:

I want to use bindings to set certain control attributes (enabled  
state, tool tip) depending on the number of selected rows in an  
outline table.  I have a controller object that owns an  
NSOutlineView, and I gave it an accessor


- (NSOutlineView*) outlineView;

Then I tried to bind to my controller with key paths like  
outlineView.numberOfSelectedRows and outlineView.selectedRowIndexes,  
and using value transformers.  It looks like the bindings are  
setting the attributes appropriately once, but then not updating  
when the selection changes.  Are these NSOutlineView methods not KVO- 
friendly, or am I doing something wrong?


It sounds like you are trying to do something like [foo bind:@".."  
toObject:controller withKeyPath:@"outlineView.selectedRowIndexes"..].


This is trying to watch for changes on the selected rows. Cocoa does  
not support binding to view properties like this. Most are not KVC  
compliant.


corbin

___

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

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

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

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


Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem

2009-03-04 Thread Mark D. Gerl

On Mar 3, 2009, at 2:30 PM, Mark D. Gerl wrote:


On Mar 3, 2009, at 11:52 AM, Nick Zitzmann wrote:

Can you please show your code? I've done this before, and it worked  
when I tried it.


SURE, see below.  I should point out that I've also tried  
implementing other delegate methods, with no luck.  And, I've tried  
setting the menu's delegate AFTER setting the menu for the  
NSStatusItem - with the same results.


Any ideas??? I'm still stuck.

Thanks!
Mark

--
Mark D. Gerl, Multimedia Design Group, 

___

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

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

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

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


View Caching Issues and Questions

2009-03-04 Thread James Cicenia

Hello -

I am a bit confused on when or why a view is cached and what is the  
best possible way to clear it.


First:

I have a UITabBarController. The views that this brings up are cached.  
This is actually great as I can test to see if something is changed  
and if so, do nothing and it brings up my view quick. So far so good.  
However, when I issue a viewWillAppear it seems that instead of "re- 
creating" my view it is actually overlaying my new image views on it  
without the old ones going away. I have done something like:


		NSEnumerator *itemEnum = [	[veggieScrollView subviews]  
objectEnumerator];

UIView *tView;
while (tView = [itemEnum nextObject]) {
if([tView tag]==101)[tView removeFromSuperview];
}

And it clears those images but that seems rather poor to me and that  
their must be a better and cleaner way.


Now I also have views that I popup from those parent views above and  
they DON'T cache the view so they have to be reconstituted in their  
viewWillAppear each time. This is bad because those popups have  
content that never changes once the program loads.

So in their case, I want them to be cached.

Any help would be greatly appreciated.

James Cicenia

___

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

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

Help/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: Can't get setDelegate to work on NSMenu attached to NSStatusItem

2009-03-04 Thread Nick Zitzmann


On Mar 4, 2009, at 9:42 AM, Mark D. Gerl wrote:


Any ideas??? I'm still stuck.



I already pointed out several problems with your code. But let me show  
you what worked for me:


	NSMenu *statusMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init]  
autorelease];


	_statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: 
25.0] retain];

[_statusItem setImage:[NSImage imageNamed:...]];
[_statusItem setMenu:statusMenu];
[_statusItem setHighlightMode:YES];
[statusMenu setDelegate:self];

Then the delegate gets -menuNeedsUpdate: messages with no problems.

Nick Zitzmann


___

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

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

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

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


Re: SyncServices ...

2009-03-04 Thread Nick Zitzmann


On Mar 4, 2009, at 3:07 AM, Mic Pringle wrote:


I've been searching around for sometime trying to find an example of
using sync services with Safari's bookmarks. Does anyone know of one,
or any information that may help with this particular task ?


Just look at the sample code in /Developer/Examples/Sync Services. I  
found the People one to be especially helpful.



Also, is it possbile to have a client sync with more than one other
client ?



Of course; that happens by default unless the entities in the client  
have been disabled.


There is a stand-alone list for Sync Services that you might want to  
consider joining, called syncservices-dev.


Nick Zitzmann


___

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

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

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

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


Sheet not ending

2009-03-04 Thread Mr. Gecko
Hello, I'm finding something weird. I am writing an application that  
posts comments. I am able to open the sheet and I have a post and  
cancel button, they work when you push them, but when I call endSheet  
with NSApplication, it doesn't end until you quit the application.

Here is my code below, tell me if I'm doing anything wrong.

- (IBAction)postComment:(id)sender {
[commentView setString:@""];
[countField setStringValue:@"500 Remaining"];
	[[NSApplication sharedApplication] beginSheet:postCommentWindow  
modalForWindow:commentWindow modalDelegate:nil didEndSelector:nil  
contextInfo:nil];

}
- (IBAction)cancelPost:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSCancelButton];

}
- (IBAction)post:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSOKButton];

}
___

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

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

Help/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: Can't get setDelegate to work on NSMenu attached to NSStatusItem

2009-03-04 Thread Andy Lee

On Mar 3, 2009, at 2:30 PM, Mark D. Gerl wrote:

SampleController *menuController =
[[[SampleController alloc] init] autorelease];

[menu setAutoenablesItems:NO];

NSMenuItem *item = [menu addItemWithTitle:@"Quit"
		action:@selector(menuHandler:) keyEquivalent:@""];[item  
setTarget:menuController];

[item setTag:9];
[item autorelease];

// *** DOING this causes the menu to NOT pop down ***
[menu setDeligate:menuController];

[statusItem setMenu:menu];


Nick Zitzmann has already pointed out that item is overreleased, so it  
is probably being dealloc'ed prematurely.  I suspect this in turn is  
causing menuController (which is autoreleased) to be dealloc'ed  
prematurely, since item had the only strong reference to it.  Note  
that delegates are not retained, so [menu setDelegate:menuController]  
does not retain menuController and in fact is now holding on to a bad  
pointer.  I'm only guessing here, but you can test the theory by  
putting a breakpoint or NSLog in SampleController's dealloc method.


Do you see any error messages in the Run console?

--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: Sheet not ending

2009-03-04 Thread Gerd Knops


On Mar 4, 2009, at 11:45 AM, Mr. Gecko wrote:

Hello, I'm finding something weird. I am writing an application that  
posts comments. I am able to open the sheet and I have a post and  
cancel button, they work when you push them, but when I call  
endSheet with NSApplication, it doesn't end until you quit the  
application.

Here is my code below, tell me if I'm doing anything wrong.

- (IBAction)postComment:(id)sender {
[commentView setString:@""];
[countField setStringValue:@"500 Remaining"];
	[[NSApplication sharedApplication] beginSheet:postCommentWindow  
modalForWindow:commentWindow modalDelegate:nil didEndSelector:nil  
contextInfo:nil];

}
- (IBAction)cancelPost:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSCancelButton];

}
- (IBAction)post:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSOKButton];

}


You'll need a "orderOut:" call on the sheet somewhere, see


http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCustomSheets.html

Gerd

___

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

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

Help/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: Sheet not ending

2009-03-04 Thread Nick Zitzmann


On Mar 4, 2009, at 10:45 AM, Mr. Gecko wrote:


- (IBAction)postComment:(id)sender {
[commentView setString:@""];
[countField setStringValue:@"500 Remaining"];
	[[NSApplication sharedApplication] beginSheet:postCommentWindow  
modalForWindow:commentWindow modalDelegate:nil didEndSelector:nil  
contextInfo:nil];



First, SEL is a C data structure and not an ObjC class, so you should  
technically be using NULL instead of nil when such a thing is  
requested. But I'm being pedantic, and that's not the real problem.  
The real problem is, in addition to ending the sheet, you need to  
close it, and I don't see the code doing that.


Nick Zitzmann


___

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

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

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

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


Re: All my leaks are gone... but now a memory warning?!

2009-03-04 Thread Shawn Erickson
On Tue, Mar 3, 2009 at 7:49 PM, Roland King  wrote:
> You said "when I debug on the device one of my screens is getting memory
> warning". What is a 'memory warning', what is the text of the warning you
> are receiving, what does it say?

He is talking about UIKit (iPhone) which has things like the following...

-[ applicationDidReceiveMemoryWarning:]
-[UIViewController didReceiveMemoryWarning]

...and...

UIApplicationDidReceiveMemoryWarningNotification

...but provides no information beyond the notification.

-Shawn
___

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

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

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

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


Re: Sheet not ending

2009-03-04 Thread Mr. Gecko
I did some more searching and I finally found that I needed to order  
out the window.


- (IBAction)postComment:(id)sender {
[commentView setString:@""];
[countField setStringValue:@"500 Remaining"];
	[[NSApplication sharedApplication] beginSheet:postCommentWindow  
modalForWindow:commentWindow modalDelegate:nil didEndSelector:nil  
contextInfo:nil];

}
- (IBAction)cancelPost:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSCancelButton];

[postCommentWindow orderOut:sender];
}
- (IBAction)post:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSOKButton];

[postCommentWindow orderOut:sender];
}

On Mar 4, 2009, at 11:45 AM, Mr. Gecko wrote:

Hello, I'm finding something weird. I am writing an application that  
posts comments. I am able to open the sheet and I have a post and  
cancel button, they work when you push them, but when I call  
endSheet with NSApplication, it doesn't end until you quit the  
application.

Here is my code below, tell me if I'm doing anything wrong.

- (IBAction)postComment:(id)sender {
[commentView setString:@""];
[countField setStringValue:@"500 Remaining"];
	[[NSApplication sharedApplication] beginSheet:postCommentWindow  
modalForWindow:commentWindow modalDelegate:nil didEndSelector:nil  
contextInfo:nil];

}
- (IBAction)cancelPost:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSCancelButton];

}
- (IBAction)post:(id)sender {
	[[NSApplication sharedApplication] endSheet:postCommentWindow  
returnCode:NSOKButton];

}


___

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

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

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

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


Re: Changing NSTableView cell immediately before editing [solved?]

2009-03-04 Thread K. Darcy Otto
Thanks Corbin and Paul.  I am using the  
windowWillReturnFieldEditor:toObject: delegate method, testing to see  
if anObject is a DeductionTable (a subclass of NSTextView), and  
testing to see if the first responder is an NSTextView, and then  
changing the textColor of the first responder to black.  This changes  
the text to black before the user edits anything, so it works.  Here  
is the code:


-(id)windowWillReturnFieldEditor:(NSWindow *)sender toObject: 
(id)anObject

{
if ([anObject isKindOfClass:[DeductionTable class]] &&  
[[[deductionTable window] firstResponder] isKindOfClass:[NSTextView  
class]])

{
		NSTextView *firstResponder = (NSTextView *)[[deductionTable window]  
firstResponder];

[firstResponder setTextColor:[NSColor blackColor]];
return firstResponder;
}
return nil;
}

I do wonder about the efficiency of this though.  It turns out that  
this method is called dozens of times for a single edit.  Can this  
really be the right way to solve the problem?


On 4-Mar-09, at 1:04 AM, Paul Sanders wrote:


Thanks for this.  I think this would solve part of the problem (when
it was clicked on by the user), but not if the text edit field were
selected in some way other than a mouse click.


I thought about this a little bit too.  It seems to me that the  
change in
firstResponser is the key to this.  I don't know how to trap this -  
I'm new

to Cocoa - but maybe that observation helps a bit.

Rgds - Paul.



___

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

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

Help/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: Odd crash

2009-03-04 Thread has

Reza Farhad wrote:


Paul

I switched on Guard Malloc from the Run Menu in Xcode

It appears that I am getting the crash for a call that is trying to
load an AppleScript.

NSDictionary*errors = [ NSDictionary dictionary ];
NSAppleScript   *script = [[ NSAppleScript alloc ]
initWithContentsOfURL:url error:&errors ];



One point, which may or may not be related: as with **NSError  
arguments, you do not need to allocate an NSDictionary instance  
yourself. If there is an error to report, initWithContentsOfURL:error:  
will create it for you.


HTH

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

___

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

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

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

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


Re: binding to number of selected rows in a table

2009-03-04 Thread Jerry Krinock


On 2009 Mar 04, at 08:21, Corbin Dunn wrote:

Cocoa does not support binding to view properties like this. Most  
are not KVC compliant.


But you can make them KVO-compliant as I described yesterday.  It's a  
slight kludge, but I think of it as a necessary "bridge" from the old  
world of dataSource to the new world of bindings.


So, if you are already using NSTreeController, observe it instead of  
NSOutlineView.  Otherwise, either replace your dataSource with  
NSTreeController, or else use the bridge/kludge.


___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?

2009-03-04 Thread Luke Evans

Thanks Eric.

It makes sense, I suppose, that NSTextView wouldn't have an built-in  
way to do this - it just acts as a 'sheet' of text over which you must  
create a viewport in the form of a scroll view.


Actually, I've _literally_ just bumped into the reference below, while  
writing this:

http://developer.apple.com/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
... previously I'd avoided trawling through the text system  
documentation - probably because I didn't think I was _really_ doing  
anything for which I wanted The Text System per se ;-)


I think I'm going to try programmatically popping the field editor  
into an scroll view configured per this note and adding this whole kit  
and caboodle to to my view hierarchy, rather than just the  
NSTextView.  Hopefully all the resizing will work as I need that.   
Anyway, I'll report back...


-- lwe



On 4-Mar-09, at 6:59 AM, Eric Gorr wrote:


I have recently experienced some of these same issues.

You can check out the message:

http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00179.html

for what I was concerned with.

As best I can determine, a NSTextView relies upon a NSScrollView to  
handle it's scrolling behavior. Unfortunately, there does not appear  
to be any way to place a fieldEditor inside of a NSScrollView in  
order to provide this behavior - but I haven't had that confirmed by  
anyone.


What I ended up doing is creating a NSTextView inside of a  
NSScrollView on the fly and using that as my field editor.


Although, I suppose creating a NSTextField would have worked as  
well...I may try switching to that as it would be less code.


___

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

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

Help/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: binding to number of selected rows in a table [solved]

2009-03-04 Thread James Walker
Thanks to Jerry Krinock, Sean McBride, and Corbin Dunn for the replies. 
 NSTreeController didn't seem to be a good fit for my data, so here's 
how I did it:


* Add an NSMutableIndexSet* member to my controller, to store the selection.
* Add KVO-friendly accessors for that index set.
* Update the index set (using the setter) in the 
outlineViewSelectionDidChange: delegate method.

--
  James W. Walker, Innoventive Software LLC
  
___

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

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

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

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


NSTextField woes

2009-03-04 Thread Robert Bielik

Hi all,

I have a NSTextField in which I'd like to change the selected text color. From 
various sources I've got this:

NSTextView* tv = (NSTextView*)[[m_nstextfield window] fieldEditor:YES 
forObject:m_nstextfield];
[tv setSelectedTextAttributes:[NSDictionary dictionaryWithObject:[NSColor 
blackColor] forKey:NSForegroundColorAttributeName]];

but noo... I can't get anything but the default color, i.e. same as the normal 
text color.

Ideas?

TIA
/Rob
___

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

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

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

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


Re: NSTextField woes

2009-03-04 Thread Nick Zitzmann


On Mar 4, 2009, at 12:13 PM, Robert Bielik wrote:

but noo... I can't get anything but the default color, i.e. same as  
the normal text color.


Ideas?



Did you try -setTextColor:?

Nick Zitzmann


___

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

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

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

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


Re: Newbie: Learning path for my GTD app...

2009-03-04 Thread Ryan Thompson
Hi Biagio

As a just-barely-ex-newbie myself I felt compelled to reply to this one.

Although learning C is nice, you don't necessarily need a good
knowledge of C programming to learn Obj-C.  I did some very
lightweight C in university a long time ago, but it was more than
enough to get started with Cocoa/Obj-C.

*But* you should take advantage of the very nice documentation that
Apple has ... the Cocoa and Obj-C guides are a great start.

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_section_1.html
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html

>From there you should be able to start digging into the specifics of
what you need.  For example ... if you take the other poster's advice
and check out NSCoding ... you find the class reference here:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html

... which has a link to the "companion guide" at the very top of the page:

http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Archiving.html

I found, for myself at least, the only way I could get a handle on
what was happening was to read (practically) the whole guide from
start to finish.  But once that's done, you'll be in a much better
spot to drill through the docs to find what you need, and to make
choices about "how" to do things in your code.

Also -- Hillegass' book is awesome (if you like the tutorial-style
presentation); if you can work your way through that, you'll be in a
good position from there on in to search the documentation for the
rest of what you need.

My only other comment is that I agree with the other poster who said
that Core Data is not an intro-level technology.  You'll be able to
play around with it soon, but don't use it in your first app!

Hope this helps.  Good luck!

-Ryan.
___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?

2009-03-04 Thread Eric Gorr


On Mar 4, 2009, at 2:37 PM, Luke Evans wrote:


Thanks Eric.

It makes sense, I suppose, that NSTextView wouldn't have an built-in  
way to do this - it just acts as a 'sheet' of text over which you  
must create a viewport in the form of a scroll view.


Actually, I've _literally_ just bumped into the reference below,  
while writing this:

http://developer.apple.com/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
... previously I'd avoided trawling through the text system  
documentation - probably because I didn't think I was _really_ doing  
anything for which I wanted The Text System per se ;-)


I think I'm going to try programmatically popping the field editor  
into an scroll view configured per this note and adding this whole  
kit and caboodle to to my view hierarchy, rather than just the  
NSTextView.  Hopefully all the resizing will work as I need that.   
Anyway, I'll report back...


If you succeed, I would be interested.

While I was able to successfully place my own NSTextView into a  
NSScrollView and have the text scroll as I typed, I was unable to  
accomplish the same when I tried it with the fieldEditor. Perhaps you  
will be able to figure out where I went wrong.


But, actually, I ran into another problem involving drawing a focus  
ring around the field. You should be aware that a NSTextView 
+NSScrollView will not automatically draw a focus ring around  
themselves. You will have to do that yourself. Unfortunately, I was  
unable to get it to work correctly under different circumstances which  
you may or may not run into - assuming you want a focus ring. I didn't  
have the time to figure out exactly what was going wrong. My old  
thread on this topic was:


http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00142.html

But, it does not cover the problem I had with it.


So, I ended up dumping my NSTextView entirely and, as you mentioned in  
your initial posting, used a NSTextField to do the editing. An  
NSTextField will automatically draw a focus ring, seems to know how to  
do it the right way, and provides all of the text editing support I  
need.





___

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

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

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

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


Re: NSTextField woes

2009-03-04 Thread David Blanton

the following works for me ...



NSMutableParagraphStyle *ps;

ps = [[NSMutableParagraphStyle alloc] init];
[ps setAlignment:NSLeftTextAlignment];

	_leftAlign = [[NSDictionary alloc] initWithObjectsAndKeys: [NSFont  
systemFontOfSize:12.0], NSFontAttributeName, ps,  
NSParagraphStyleAttributeName, [NSColor blueColor],  
NSForegroundColorAttributeName, nil];


[_value drawInRect:cellFrame withAttributes:_leftAlign];





On Mar 4, 2009, at 12:13 PM, Robert Bielik wrote:


Hi all,

I have a NSTextField in which I'd like to change the selected text  
color. From various sources I've got this:


NSTextView* tv = (NSTextView*)[[m_nstextfield window]  
fieldEditor:YES forObject:m_nstextfield];
[tv setSelectedTextAttributes:[NSDictionary dictionaryWithObject: 
[NSColor blackColor] forKey:NSForegroundColorAttributeName]];


but noo... I can't get anything but the default color, i.e. same as  
the normal text color.


Ideas?

TIA
/Rob
___

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

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

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


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




David Blanton




___

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

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

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

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


Re: Date parsing problem (when running on iphone only)

2009-03-04 Thread Jacob Rhoden

On 5/3/09 2:42 AM, Christopher Kane wrote:
It seems that if you have your Regional settings to Chinese the date 
is not parsed. What is the proper way to parse an "English" formatted 
date?
Yes, the date formatter you're creating defaults to using the user's 
locale, which can have settings which override even your attempt to 
set a specific format string.  Do this after creating the formatter: 
[df setLocale:[NSLocale systemLocale]]; to set a generic locale object 
on the formatter. 
Thanks very much, that was the hint I needed to get it working. To share 
in case someone else has this problem for future reference: If you are 
trying to parse a date that will always be English, ie from a web page 
or web service, you need to tell the date parser to use the language of 
that web service.


ie:
NSString* test = @"Monday 26 January 2009 3:47:33 pm +";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setLocale: [[[NSLocale alloc] 
initWithLocaleIdentifier:@"en_UK"] autorelease]];

[df setDateFormat: @" dd   h:mm:ss a Z"];

If you don't do this, when you run your code on say a Chinese computer, 
it will fail (I am assuming its because January and Monday are not valid 
Chinese words).


Imagine tracking down a bug that your software works on most computers 
except that one person in the office or that one iphone user who has 
changed their Regional Settings (It threw me because I am used to Java's 
date parsing being language agnostic)


Best regards,
Jacob

--

Jacob Rhoden  http://jacobrhoden.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: Saving a plist file from a thumbdrive

2009-03-04 Thread Benjamin Dobson


On 4 Mar 2009, at 20:17:21, Francois Cournoyer wrote:


Hi,

We have an installer app that runs from the root folder of a  
thumbdrive like device,
The installer is ran from a subfolder or from subfolder on a hard  
disk works correctly.
The problem is when it runs from the root of the thumbdrive,  
everything seems to be installing fine, but there’s 1 area which  
seems to fail.
We create a plist file for preferences in users/shared/Application  
Support/myApp/myApp.plist


for some reason, the creation of this file fails, but works if it’s  
launched for a subfolder on the same drive.


Is there anyway to fix this? (the installer is already running with  
Admin rights)


Probably, but is there any reason you can't create the plist on first  
launch instead of install?___


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

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

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

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


Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Mark D. Gerl

On Mar 4, 2009, at 12:11 AM, Michael Ash wrote:


On Tue, Mar 3, 2009 at 4:30 PM, Quincey Morris
 wrote:

On Mar 3, 2009, at 12:50, Nick Zitzmann wrote:
It doesn't seem to be documented, but I think it will return nil  
only if

(1) there was not enough contiguous RAM in the program's VM space to
allocate the object, or (2) there was, but the user has run out of  
disk
space for swap files. But if this happens, the program is pretty  
much

screwed anyway, because it's going to crash.


Yes, I'm aware of the "is pretty much screwed" scenario, but I  
think there
are in fact some recoverable scenarios. One involves a sequence of  
very
large (valid) allocations gobbling up VM space so that it becomes  
impossible
to create a humbler NS... object of some kind. If the application  
doesn't
crash right away, returning nil (or NO) back through the sequence  
could
release all the memory and allow the application to continue with  
an error

message.

Another scenario is a memory-limited environment like the iPhone.


In either environment, once allocations start to fail for any reason,
you are doomed.

Recovery is possible, nay reasonable, if you control all of the code
in the process. But you don't, and you can bet that Cocoa is *not*
written with an eye toward gracefully recovering when malloc() begins
to return NULL.

You can try to recover from an allocation error, but what if the first
NULL allocation happens inside Cocoa code somewhere? If you're lucky
it'll end up trying to insert it into a collection or something
similar, trigger an assert, and throw an exception. If you're unlucky,
the NULL allocation will happen while trying to resize an
NSDictionary's hash table and you'll be set up for a crash.

Even if you could trap it and recover gracefully by dumping a large
allocation, multithreading means that you still have a window of
opportunity in between the failure and the allocation dumping where
other threads will see allocation failures too. And again, these can
happen deep in Cocoa code where you have no chance to survive.

Realistically, unless you're a pure libc program, the only way to deal
with out-of-memory situations is to detect it in advance and free up
memory *before* the allocations begin to fail, the way the iPhone
frameworks do it.


In an attempt to NOT derail my original topic, I've renamed this  
thread (I hope)...


Perhaps it's because I come from the old school ways, I find it nearly  
impossible for me to write code that doesn't check for NULL -  
regardless of the API's documentation or intent.  The one true thing  
is that things can and do go wrong -- logically -- in computer  
programs.  So, I am just in the habit of always checking for NULL.   
I'm just not yet that comfortable of stacking things up and doing the  
Cocoa/Java way.  I also wrap things up inside of try...catch blocks as  
well, which will help protect in the case of legitimate memory  
failure.  Of course, in this case, if something as small as an NSMenu  
fails due to memory issues, something's going to go terribly wrong.   
However, loading a large image, maybe not - and (graceful) recovery is  
much more possible.


Long ago in Classic MacOS programming days, we had some nice hooks  
into memory heap allocation - and you could plug in a function that  
would get called if a memory allocation failed, which would give you a  
chance to deallocate cached data or to gracefully recover without user  
data loss.  I'm not as familiar with Cocoa (yet) as many on this list,  
but I'd be surprised if the Obj-C/Cocoa system didn't have something  
similar.


I also know that many mission-critical software development projects  
employ their own memory management schemes - and don't rely on the  
underlying Standard Lib stuff.


In any case, and perhaps based purely on habit, I find it difficult to  
even write:


NSStatusItem statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength] retain];

...in favor of:

NSStatusBar *systemBar = [NSStatusBar systemStatusBar];
if (systemBar != NULL)
{
NSStatusItem statusItem =
[systemBar statusItemWithLength:
NSVariableStatusItemLength];
if (statusItem != NULL)
{
[statusItem retain];
...
}
}

There's something that's just "uncomfortable" about dereferencing  
pointers without first checking for validity.  Is it just me?

M
M

--
Mark D. Gerl, Multimedia Design Group, 

___

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

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

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

NSButton image drawn 1 pixel too high

2009-03-04 Thread James Walker
I guess I'm being picky, but it bugs me... I have a 23x23 square button, 
displaying a 17x17 image, with NSImageOnly positioning.  It should 
center perfectly, with 2 pixels between the image and the border on each 
side, but in fact there's 1 pixel above and 3 below.  I can work around 
it by subclassing NSButtonCell and reimplementing 
drawInteriorWithFrame:inView:, but I wondered if there is a better way?

--
  James W. Walker, Innoventive Software LLC
  
___

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

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

Help/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: Newbie: Learning path for my GTD app...

2009-03-04 Thread Jacob Rhoden

Hi,

When I was first learning, the thing that really helped getting me 
started is the Aaron Hillegass book. This book should be enough to get 
you to the point where you can write basic applications. Once you have 
conquered the book, then the apple documentation at 
http://developer.apple.com/ is a really good reference point (its a bit 
more terse, and uses language that beginners dont always understand).


(I sent this earlier but it seems to have gotten lost)

Best regards,
Jacob


On 4/3/09 4:40 PM, Biagio wrote:

Hello.  My first post.  I'm learning to program using Xcode 3.1.2 in
OS X Leopard. My current plan of attack is working through these
books:

Learn C on the Mac
C All in One Desktop Reference for Dummies
Learn Objective-C On the Mac
Cocoa Programming for Mac OS X 3rd edition by Aaron Hillegass

   



--

Jacob Rhoden  http://jacobrhoden.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: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Shawn Erickson
On Wed, Mar 4, 2009 at 12:57 PM, Mark D. Gerl  wrote:

> In any case, and perhaps based purely on habit, I find it difficult to even
> write:
>
>        NSStatusItem statusItem = [[[NSStatusBar systemStatusBar]
>                statusItemWithLength:NSVariableStatusItemLength] retain];
>
> ...in favor of:
>
>        NSStatusBar *systemBar = [NSStatusBar systemStatusBar];
>        if (systemBar != NULL)
>        {
>                NSStatusItem statusItem =
>                        [systemBar statusItemWithLength:
>                                NSVariableStatusItemLength];
>                if (statusItem != NULL)
>                {
>                        [statusItem retain];
>                        ...
>                }
>        }
>
> There's something that's just "uncomfortable" about dereferencing pointers
> without first checking for validity.  Is it just me?

No "dereferencing" of pointers take place in the first version... If
you attempt to send a message to a pointer that is nil the Objective-C
runtime simply doesn't send the message (aka no attempt to deference
the pointer).

In your second version you are basically duplicating what the runtime
is already doing for you... why right more code then you need. Of
course you need to understand what happens with the return value when
you send a message to nil but once you understand that you can write
fairly clean code that will handle nils correctly.

Review the following...

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_2_section_4.html#//apple_ref/doc/uid/TP30001163-CH11-SW7

-Shawn
___

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

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

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

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


Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem (SOLVED)

2009-03-04 Thread Mark D. Gerl

On Mar 3, 2009, at 2:30 PM, Mark D. Gerl wrote:


// *** DOING this causes the menu to NOT pop down ***
[menu setDeligate:menuController];


DOH!  Spelling error.  I never noticed the wee warning triangle next  
to the call - I spelled "delegate" wrong.  I do miss C++ compiler  
errors!  Serves me right for not looking closer at the runlog:


*** -[NSMenu setDeligate:]: unrecognized selector sent...

Thanks for all the suggestions!
M

--
Mark D. Gerl, Multimedia Design Group, 

___

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

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

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

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


Re: CoreData and NSUndoManager/Undo Grouping...

2009-03-04 Thread Jean-Nicolas Jolivet
Well, I have absolutely no idea why I managed to get it to work but,  
all I did was this:


Changed this code:

- (IBAction)saveChanges:(id)sender
{
[[[myDoc managedObjectContext] undoManager] endUndoGrouping];
	[[[myDoc managedObjectContext] undoManager]  setActionName:@"Item  
Editing"];

[self hideView:sender];

}

To this:

- (IBAction)saveChanges:(id)sender
{
	[[[myDoc managedObjectContext] undoManager]  setActionName:@"Item  
Editing"];

[[[myDoc managedObjectContext] undoManager] endUndoGrouping];

[self hideView:sender];

}


So basically, I'm setting the action name BEFORE ending undo  
grouping... and it's working just fine... I have no idea why but... it  
works now...




On 4-Mar-09, at 1:41 AM, Jean-Nicolas Jolivet wrote:

I'm trying to set up undo grouping properly for my editing dialog  
(i.e. when a user edits a ManagedObject, the whole editing process  
can be undo...)
I've read a couple of articles/tutorials about using undo grouping  
for Core Data but they all involved 2 things: An editing window/ 
sheet and a non-document based app...


In my case, I'm using a Document-based Core Data application and the  
editing is done in an NSView, not a window/sheet...


What I tried to do was the following: My view (let's call it  
EditView) has a controller (EditViewController)... in the  
EditViewController, when I'm showing the view (i.e. the editing  
process begins..) I'm doing this:


//Prepare undo manager
[[[myDoc managedObjectContext] undoManager] beginUndoGrouping];

where myDoc is an outlet to MyDocument...

I also have two actions in my editController;  one for the save  
button and one for the cancel button:


- (IBAction)saveChanges:(id)sender
{
[[[myDoc managedObjectContext] undoManager] endUndoGrouping];
	[[[myDoc managedObjectContext] undoManager]  setActionName:@"Item  
Editing"];

[self hideView:sender];

}

- (IBAction)cancelChanges:(id)sender
{
[self hideView:sender];
[[[myDoc managedObjectContext] undoManager]  endUndoGrouping];
[[[myDoc managedObjectContext] undoManager]  undo];
}


Now, the cancel button is working nicely... if I click on it, the  
view is hidden and the changes are undo... the problem is when I  
save the changes... in that case, the view does disappear and the  
action gets added and named correctly ("Undo Item Editing") but if I  
undo it (by selecting it from the "Edit" menu, or pressing Cmd+Z),  
nothing happens...


I'm not sure what's happening... could it be that a different  
NSUndoManager is used? Because basically both the save and cancel  
buttons are using the same code, the only thing that cancel does is  
to actually call the undo method directly on the undo manager... so  
the only thing I could see is that the "Undo" from the Edit menu is  
calling a different Undo Manager but I'm not sure why this would  
happen since my EditView/EditViewController doesn't have one  
(well...not that I know off anyway??)


It's also possible that I'm completely missing the point with  
NSUndoManagers/NSManageObjectContext etc...


Any help/suggestion would be appreciated...

Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.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


Doing NSStringDrawingTruncatesLastVisibleLine with NSLayoutManger

2009-03-04 Thread Eric Gorr

I am drawing a string with a NSLayoutManager by doing:

 [layoutManager drawGlyphsForGlyphRange:glyphRange  
atPoint:NSMakePoint( [self bounds].origin.x,[self bounds].origin.y )];


What I would like is if the string I am drawing goes beyond the last  
visible line, is for the string to draw a truncated form of itself  
with an elipses at the last visible part of the string.


As near as I can tell, this is what the NSString drawing option  
NSStringDrawingTruncatesLastVisibleLine will do.


The paragraph style NSLineBreakByTruncatingTail comes close, but I  
have a single string that can be drawn over multiple lines and still  
be visible. The NSLineBreakByTruncatingTail style restrict my drawing  
to just a single line which isn't enough.


Anyone tried to emulate NSStringDrawingTruncatesLastVisibleLine with  
NSLayoutManager drawing?


Is there any sample code out there demonstrating the technique?




___

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

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

Help/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: Can't get setDelegate to work on NSMenu attached to NSStatusItem (SOLVED)

2009-03-04 Thread Nick Zitzmann


On Mar 4, 2009, at 2:53 PM, Mark D. Gerl wrote:

DOH!  Spelling error.  I never noticed the wee warning triangle next  
to the call - I spelled "delegate" wrong.  I do miss C++ compiler  
errors!  Serves me right for not looking closer at the runlog:



Yes; I pointed that out to you yesterday. You can, if you wish, turn  
on the warnings/errors option for your target in Xcode to treat all  
warnings as errors. You should also set a global breakpoint on  
objc_exception_throw so you can catch exceptions like that one.


Nick Zitzmann


___

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

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

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

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


RE: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Jeff Laing
Mark D. Gerl asked:
> There's something that's just "uncomfortable" about dereferencing  
> pointers without first checking for validity.  Is it just me?

I don't think its just you, though most Cocoa types eventually give up
and go with the simpler 'just trust it, it works' approach.  Personally,
I think relying on the 'nil eats all messages' is the road to damnation,
but the Cocoa frameworks do it internally so there's no avoiding it, its
never going to change.

(For the record, when I add an IBOutlet to a class definition, I add the
corresponding assertion that its non-nil to the awakeFromNib method
because I *know* that I forget to connect those things up, and have
wasted days chasing unexpected 'nil' objects)

One thing I wonder about in your example, however, is why you don't have
the else cases populated? (I realise it's a coded-in-email example, but
it's the quality of the paranoia I'm interested in)  ie,  if I'm going
to be so paranoid as to check that the status bar exists, I'm going to
have a strategy for when it isn't.  ie,

if (systemBar != NULL)
{
...
} else {
// what would you put in here to let the user know that
the system has
// gone kablooey?
}

My attitude comes down to "unless its going to be a state where the
system is still stable enough to display alert messages, I might as well
just let it dump core - at least that way, I get a stacktrace".

I realise that's a bit radical but I've spent too many years *removing*
badly-formed paranoia from (other peoples) code that did this 'check for
nil' protection but didn't bother propagating the problem out to a layer
that should actually do something about it, instead just returning an
'it worked ok' status.

(Personally, I think this is the only place where throwing exceptions is
truly justified)

But if you aren't going to raise an error somehow, then there's no
reason for not cascading the method calls together.  Except perhaps ease
of breakpointing when chasing that elusive failure that "couldn't
possibly" be in the middle of a complex expression...
___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell? [SOLVED]

2009-03-04 Thread Luke Evans

OK.  I managed to get things working.

The main feature of the change was simply to create an NSScrollView  
when editing starts and drop the acquired and configured NSTextView  
inside it.  This was actually very straight forward - and finding that  
bit of documentation provided the confidence that wrapping a scroll  
view in this way was the Right Thing.


The thing that has been fiddly and sensitive to getting upset (causing  
bad sizing) is the use of -sizeToFit on the NSTextView.

What I've found is this:
I have to set the text container initially to the maximum width of the  
label area (i.e. as wide as the label is allowed to grow), and with  
the maximum height (FLT_MAX).
In the method that resizes both the text view and its enclosing  
NSScrollView, I need to do two lots of sizing.  Here's what I have at  
the moment:


- (void)adjustEditorForContents {
	// XXX? The two-stage sizing by 'sizeToFit' is a bit of magique  
noir.  How does one do this in one go?
	// First get the active field editor to produce its minimum size and  
remember this for the proposed editor rect.
	[activeFieldEditor setFrameSize:NSMakeSize(MIN_TEXT_CONTAINER_WIDTH,  
[self twoLineHeight]/2)];

[activeFieldEditor sizeToFit];
NSSize editorProposedSize = [activeFieldEditor frame].size;

	// Now get the field editor to size naturally, allowing for multi- 
line sizes (and scrolling)
	[activeFieldEditor setFrameSize:NSMakeSize(MIN_TEXT_CONTAINER_WIDTH,  
FLT_MAX)];

[activeFieldEditor sizeToFit];

// Determine where this should go (centred at the top of the text area)
	NSRect editorFrame = ESRectConstructWithinAndClip([self  
labelAreaRect], ES_RECT_CENTRE | ES_RECT_TOP, editorProposedSize);

[fieldEditorScroller setFrame:editorFrame];

	// Redraw the underlying view to get the focus highlight in the right  
place

[self setNeedsDisplay:YES];
}

I'm not happy with this code - but mostly because it was arrived at  
empirically, I don't fully understand it.
To get the actual size for the editor bounds, you seem to need to  
constrain smaller than the text might actually need to fit.
However, in order to have the correct scrolling behaviour, you have to  
do this sizing again, this time allowing effectively having the height  
of the text view unconstrained when sizing is done.


As I've been writing this, I've done another search and found this:
http://www.omnigroup.com/mailman/archive/macosx-dev/1999-April/007703.html
... which seems to delve into the arcane behaviour of -sizeToFit  
(thanks Mike Ferris!).


Anyway, I've got a nice dynamically resizing label editor now, so I'm  
happy :-)


-- lwe



On 4-Mar-09, at 12:08 PM, Eric Gorr wrote:


If you succeed, I would be interested.



___

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

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

Help/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: Newbie: Learning path for my GTD app...

2009-03-04 Thread Steve Steinitz

Hi Biagio

On 4/3/09, cocoa-dev-requ...@lists.apple.com wrote:


would just like
some guidance as to where to focus my attention after I get through
the above books.  Any thoughts would be much appreciated.


Core Data is a wonderful, powerful technology that, to a certain 
extent, makes persistence transparent.  Its descends from an 
older, mature Apple/Next technology, called EOF, which is a 
shining example of the young Steve Jobs in full flight.  But as 
Mike points out it can get a bit hairy.  Even so, Core Data is 
simple at first so why not try to create a simple list of your 
GTD to-do 'items' (NSTableView bound to an NSArrayController 
which holds your Core Data 'Items' table).  You might even give 
the to-do item 'context' and 'done' attributes and a date or two 
for good GTD measure.  Someone who knew Core Data could set that 
up in 3 minutes flat.  It might take you a day :) but you'd 
learn a lot.   The default Core Data projects in Xcode will take 
you a long way.


Then, when all that's done you could make your GTD to-do list 
hierarchical by giving the to-do items a parent and swapping the 
NSTableView for an NSOutlineView and struggling with bindings a 
little.  Once you've done all that you'll know whether or not 
you like Core Data.  I think you'll be starry-eyed about it just 
like the rest of us :)


For your future Core Data education read everything that Ben 
Trumbull has posted on this list.  The day you finally 
understand what he's talking about you will have arrived :)


Cheers,

Steve

___

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

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

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

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


Re: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Stuart Malin


On Mar 4, 2009, at 12:15 PM, cocoa-dev-requ...@lists.apple.com wrote:


In any case, and perhaps based purely on habit, I find it difficult to
even write:

NSStatusItem statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength] retain];

...in favor of:

NSStatusBar *systemBar = [NSStatusBar systemStatusBar];
if (systemBar != NULL)
{


AFAIU(nderstand):

While nil and NULL may operate interchangeably (in most cases?),  
semantically, they are not the same thing.


In your code fragment above, I believe most Cocoa programmers would  
expect to see:


if (systemBar != nil) 

NULL is used more to indicate a null value c pointer.

At one time I was under the impression they were defined differently:
nil being of type id, and NULL being a void*
But in trying to research this, I run across much conflicting info and  
suspect perhaps this has either changed over time, and/or depends on  
whether the use is in/with C++ or not. Perhaps some of the experts on  
this list can provide some clarity


___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell? [COROLLARY]

2009-03-04 Thread Luke Evans
Flushed with some semblance of success I'm now trying to get Finder's  
behaviour with inserting centre ellipses when the text is too large  
for its container.


I can get the ellipsis at the tail of the text easily enough  
(NSStringDrawingTruncatesLastVisibleLine), and I thought I had a bead  
on the problem remembering that NSParagraphStyle has a setting for  
this - but actually it has a setting for breaking each line in the  
paragraph (i.e. according to end-of-lines in the text), rather than  
what happens typographical wrapping.   As I have no line breaks in my  
text I'll always get one line of laid-out text, with the ellipsis in  
the middle - not what I'm after.


Is there some other mechanism to achieve what I'm after?  Perhaps this  
requires NSTextView-Fu (of which I currently have next to none).




On 4-Mar-09, at 2:23 PM, Luke Evans wrote:


OK.  I managed to get things working.


___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell? [COROLLARY]

2009-03-04 Thread Eric Gorr


On Mar 4, 2009, at 5:55 PM, Luke Evans wrote:

Flushed with some semblance of success I'm now trying to get  
Finder's behaviour with inserting centre ellipses when the text is  
too large for its container.


I can get the ellipsis at the tail of the text easily enough  
(NSStringDrawingTruncatesLastVisibleLine), and I thought I had a  
bead on the problem remembering that NSParagraphStyle has a setting  
for this - but actually it has a setting for breaking each line in  
the paragraph (i.e. according to end-of-lines in the text), rather  
than what happens typographical wrapping.   As I have no line breaks  
in my text I'll always get one line of laid-out text, with the  
ellipsis in the middle - not what I'm after.


Is there some other mechanism to achieve what I'm after?  Perhaps  
this requires NSTextView-Fu (of which I currently have next to none).



Hello again...

Well, to try to accomplish this, I have my own NSView which is drawing  
a string with a NSLayoutManager.


I haven't quite come up with a solution, but I believe I am close and  
need to leave for today. Just moments ago, I started a thread on this  
topic with this message:


http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00246.html

___

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

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

Help/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: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Clark Cox
On Wed, Mar 4, 2009 at 2:40 PM, Stuart Malin  wrote:
>
> On Mar 4, 2009, at 12:15 PM, cocoa-dev-requ...@lists.apple.com wrote:
>
>> In any case, and perhaps based purely on habit, I find it difficult to
>> even write:
>>
>>        NSStatusItem statusItem = [[[NSStatusBar systemStatusBar]
>>                statusItemWithLength:NSVariableStatusItemLength] retain];
>>
>> ...in favor of:
>>
>>        NSStatusBar *systemBar = [NSStatusBar systemStatusBar];
>>        if (systemBar != NULL)
>>        {
>
> AFAIU(nderstand):
>
> While nil and NULL may operate interchangeably (in most cases?),
> semantically, they are not the same thing.
>
> In your code fragment above, I believe most Cocoa programmers would expect
> to see:
>
>        if (systemBar != nil) 
>
> NULL is used more to indicate a null value c pointer.

And all object pointers are c pointers, so NULL is still appropriate.
There is no situation where nil can be used that NULL (or even just a
literal zero) cannot.

> At one time I was under the impression they were defined differently:
> nil being of type id, and NULL being a void*

The null pointer constant, in C, can either be a compile-time integer
constant with the value zero, or such a constant cast to (void*). (I'm
paraphrasing), so all of the following are valid definitions of the
NULL macro:

#define NULL 0
#define NULL (42-42)
#define NULL !1
#define NULL (void*)0

or even:

#define NULL __some_special_token_that_is_specific_to_your_compiler

etc.

> But in trying to research this, I run across much conflicting info and
> suspect perhaps this has either changed over time, and/or depends on whether
> the use is in/with C++ or not.

In C++, on the other hand, it must *not* be cast to (void*). Because
of the need for compatibility with both C and C++ in their headers,
most implementations either define it as a simple, literal zero, or
use some compiler built-in.

> Perhaps some of the experts on this list can
> provide some clarity

-- 
Clark S. Cox III
clarkc...@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: Newbie: Learning path for my GTD app...

2009-03-04 Thread Biagio
Everyone,

This is EXACTLY the guidance I was hoping and crossing my fingers
for.  I hesitated to write a "thank you" so as to keep the noise on
the list to a minimum, but as a newbie who was (honestly) nervous
about posting, you've been incredibly welcoming and encouraging.  Just
wanted to say thanks for all of the informative and kind replies.  My
future questions will be much more specific, and, as Steve said, when
I can understand anything Ben Trumbull is saying about Core Data, I
will do a little dance of joy :)

Thanks again!
Biagio

On Mar 4, 2:37 pm, Steve Steinitz  wrote:
> Hi Biagio
>
> On 4/3/09, cocoa-dev-requ...@lists.apple.com wrote:
> >would just like
> >some guidance as to where to focus my attention after I get through
> >the above books.  Any thoughts would be much appreciated.
>
> Core Data is a wonderful, powerful technology that, to a certain
> extent, makes persistence transparent.  Its descends from an
> older, mature Apple/Next technology, called EOF, which is a
> shining example of the young Steve Jobs in full flight.  But as
> Mike points out it can get a bit hairy.  Even so, Core Data is
> simple at first so why not try to create a simple list of your
> GTD to-do 'items' (NSTableView bound to an NSArrayController
> which holds your Core Data 'Items' table).  You might even give
> the to-do item 'context' and 'done' attributes and a date or two
> for good GTD measure.  Someone who knew Core Data could set that
> up in 3 minutes flat.  It might take you a day :) but you'd
> learn a lot.   The default Core Data projects in Xcode will take
> you a long way.
>
> Then, when all that's done you could make your GTD to-do list
> hierarchical by giving the to-do items a parent and swapping the
> NSTableView for an NSOutlineView and struggling with bindings a
> little.  Once you've done all that you'll know whether or not
> you like Core Data.  I think you'll be starry-eyed about it just
> like the rest of us :)
>
> For your future Core Data education read everything that Ben
> Trumbull has posted on this list.  The day you finally
> understand what he's talking about you will have arrived :)
>
> Cheers,
>
> Steve
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your 
> Subscription:http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev-garchive-9...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Greg Parker


On Mar 4, 2009, at 2:40 PM, Stuart Malin wrote:



On Mar 4, 2009, at 12:15 PM, cocoa-dev-requ...@lists.apple.com wrote:

In any case, and perhaps based purely on habit, I find it difficult  
to

even write:

NSStatusItem statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength] retain];

...in favor of:

NSStatusBar *systemBar = [NSStatusBar systemStatusBar];
if (systemBar != NULL)
{


AFAIU(nderstand):

While nil and NULL may operate interchangeably (in most cases?),  
semantically, they are not the same thing.


In your code fragment above, I believe most Cocoa programmers would  
expect to see:


if (systemBar != nil) 

NULL is used more to indicate a null value c pointer.

At one time I was under the impression they were defined differently:
nil being of type id, and NULL being a void*
But in trying to research this, I run across much conflicting info  
and suspect perhaps this has either changed over time, and/or  
depends on whether the use is in/with C++ or not. Perhaps some of  
the experts on this list can provide some clarity


Technically, nil and NULL are identical. As of Mac OS X 10.5, nil and  
NULL are both defined as __DARWIN_NULL, which is handled specially by  
the compiler for typechecking and a few C vs C++ corner cases.


Stylistically, you may prefer to distinguish nil and NULL as a C vs  
Objective-C hint to the reader.


(Before 10.5, nil was defined as 0, which would have caused trouble  
for 64-bit: sizeof(nil) != sizeof(id). There's also a Nil, which was  
originally intended to be the nil class but is now mostly unused.)



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

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

Help/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: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell? [COROLLARY]

2009-03-04 Thread Luke Evans

We seem to be developing in sync at the moment ;-)

I'll watch your thread to see what develops...

On 4-Mar-09, at 3:04 PM, Eric Gorr wrote:



On Mar 4, 2009, at 5:55 PM, Luke Evans wrote:


I can get the ellipsis at the tail of the text easily enough  
(NSStringDrawingTruncatesLastVisibleLine), and I thought I had a  
bead on the problem remembering that NSParagraphStyle has a setting  
for this - but actually it has a setting for breaking each line in  
the paragraph (i.e. according to end-of-lines in the text), rather  
than what happens typographical wrapping.   As I have no line  
breaks in my text I'll always get one line of laid-out text, with  
the ellipsis in the middle - not what I'm after.


Well, to try to accomplish this, I have my own NSView which is  
drawing a string with a NSLayoutManager.


I haven't quite come up with a solution, but I believe I am close  
and need to leave for today. Just moments ago, I started a thread on  
this topic with this message:


http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00246.html



___

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

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

Help/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: binding to number of selected rows in a table [solved]

2009-03-04 Thread Jerry Krinock


On 2009 Mar 04, at 11:39, James Walker wrote:

* Add an NSMutableIndexSet* member to my controller, to store the  
selection.

* Add KVO-friendly accessors for that index set.
* Update the index set (using the setter) in the  
outlineViewSelectionDidChange: delegate method.


James, you've added an instance variable which is simply a copy of  
other data.  This is always a dangerous practice that must be  
exercised with great care.  Although this practice is occasionally  
necessary for performance reasons, other alternatives should be  
considered first.  In my judgment, getting KVObservability for a  
variable is not a enough good reason.


Maybe you'll be able to get away with it this time, because it's just  
an index set, but don't make a habit of this.  If you ever try this  
with, for example, Core Data managed objects, you'll be spending some  
time bug-hunting.


I'm sticking with my method.

___

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

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

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

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


Re: Newbie: Learning path for my GTD app...

2009-03-04 Thread Graham Cox


On 05/03/2009, at 8:01 AM, Jacob Rhoden wrote:

When I was first learning, the thing that really helped getting me  
started is the Aaron Hillegass book



I wholeheartedly second that.

I think its explanation of memory management should be required  
reading for anyone starting out with Cocoa (along with the official  
docs of course). That simple bit of self-help would probably halve the  
number of newbie errors that crop up daily on this list.


--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: Can't get setDelegate to work on NSMenu attached to NSStatusItem (SOLVED)

2009-03-04 Thread Mark D. Gerl

On Mar 4, 2009, at 5:03 PM, Nick Zitzmann wrote:

Yes; I pointed that out to you yesterday. You can, if you wish, turn  
on the warnings/errors option for your target in Xcode to treat all  
warnings as errors. You should also set a global breakpoint on  
objc_exception_throw so you can catch exceptions like that one.


Yeah, that was an odd situation... one of those things right in front  
of my face that I ignored and missed (run log)... since it didn't  
work, I just commented it out and went on with other things and  
waiting for responses on the list... so, I didn't notice the either  
compiler warning or xcode run log message - until I happened on the  
spelling error myself (THOUGH, I sure wish I had seen your message  
first -- stupid delayed Mail delivery!).


Breakpoint is a good idea - I usually do that for C++.  As for  
warnings are errors - not possible, because I'm working with a larger  
beast that has plenty of benign but odd warnings that I'm not  
authorized to spend the time removing.  Sigh.


Thanks again, for all the good advice from everyone.
M

--
Mark D. Gerl, Multimedia Design Group, 

___

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

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

Help/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: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Mark D. Gerl


On Mar 4, 2009, at 5:12 PM, Jeff Laing wrote:

(For the record, when I add an IBOutlet to a class definition, I add  
the

corresponding assertion that its non-nil to the awakeFromNib method
because I *know* that I forget to connect those things up, and have
wasted days chasing unexpected 'nil' objects)


Great idea... I'm going to try that myself.  Though, I don't do much  
nib stuff right now, b/c I'm still wrapped up in the Carbon world with  
pre-nib code.


One thing I wonder about in your example, however, is why you don't  
have
the else cases populated? (I realise it's a coded-in-email example,  
but

it's the quality of the paranoia I'm interested in)  ie,  if I'm going
to be so paranoid as to check that the status bar exists, I'm going to
have a strategy for when it isn't.  ie,


Precisely.. code-in-email.  I do handle all else cases, and wrap it  
all up inside exceptions.  Kind of habit by now.


What I was kind of fishing for in the nil/NULL checking - was - to  
recognize that it seems Cocoa programmers are trending towards the  
lazy side (like Java); and there's too much "just trust the force,  
Luke" stuff going on there.  Preventative programming seems to go  
right out the window, and what makes me think twice about all of this  
stuff is this - it's all sitting on top of C; and no amount of magic  
will help you track down gnarly memory overwrites and such, than  
trying to trap anomalies as soon as you can.  The key, though, is not  
just checking for nil; as you mention.  You have to respond/react to  
all alternate/undesirable/fringe cases in code - and bring it to the  
engineer's attention.  Just some of the coding behaviors that I've  
learned along the way.  Food for thought.


Thanks!
M

--
Mark D. Gerl, Multimedia Design Group, 

___

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

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

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

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


A question about Apple Policy

2009-03-04 Thread Development
Ok I'm working on a program that allows system administrators to  
access some features of the OS which are otherwise not normally  
available. In cases where required I've followed the guidlines for  
using the security framework. So what concerns me is because this app  
allows a user to make changes to system preferences, if I release the  
application am I going to get black listed?





April.
___

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

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

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

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


CrashReporter alternatives for third-party apps?

2009-03-04 Thread Rick Mann
Can you guys suggest something I can use to submit crash reports to my  
own servers (and perhaps to suppress Apple's CrashReporter)?


TIA,
--
Rick

___

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

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

Help/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: binding to number of selected rows in a table [solved]

2009-03-04 Thread James Walker

Jerry Krinock wrote:


On 2009 Mar 04, at 11:39, James Walker wrote:

* Add an NSMutableIndexSet* member to my controller, to store the 
selection.

* Add KVO-friendly accessors for that index set.
* Update the index set (using the setter) in the 
outlineViewSelectionDidChange: delegate method.


James, you've added an instance variable which is simply a copy of other 
data.  This is always a dangerous practice that must be exercised with 
great care.  Although this practice is occasionally necessary for 
performance reasons, other alternatives should be considered first.  In 
my judgment, getting KVObservability for a variable is not a enough good 
reason.



For brevity, I didn't tell the whole story.  Contrary to what I said in 
my original post, what I really needed was not all the selected rows, 
but just the ones at the lowest level of the hierarchy.  So in my 
outlineViewSelectionDidChange: method, I'm not just copying the result 
of [NSOutlineView selectedRowIndexes], but computing a subset.


But your comments are interesting, thanks.


Maybe you'll be able to get away with it this time, because it's just an 
index set, but don't make a habit of this.  If you ever try this with, 
for example, Core Data managed objects, you'll be spending some time 
bug-hunting.


I'm sticking with my method.


--
  James W. Walker, Innoventive Software LLC
  
___

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

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

Help/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: A question about Apple Policy

2009-03-04 Thread Andrew Farmer

On 04 Mar 09, at 18:07, Development wrote:
Ok I'm working on a program that allows system administrators to  
access some features of the OS which are otherwise not normally  
available. In cases where required I've followed the guidlines for  
using the security framework. So what concerns me is because this  
app allows a user to make changes to system preferences, if I  
release the application am I going to get black listed?


There's no such thing as "blacklisted" for desktop applications. In  
fact, there are already a number of programs which do exactly what  
you're describing - TinkerTool[1] and Secrets.app[2], for instance.


[1] http://www.bresink.de/osx/TinkerTool.html

[2] http://secrets.blacktree.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: Newbie: Learning path for my GTD app...

2009-03-04 Thread mmalc Crawford


On Mar 4, 2009, at 2:37 PM, Steve Steinitz wrote:

On 4/3/09 4:40 PM, Biagio wrote:

Hello.  My first post.  I'm learning to program using Xcode 3.1.2 in
OS X Leopard. My current plan of attack is working through these
books:
Core Data is a wonderful, powerful technology that, to a certain  
extent, makes persistence transparent. Its descends from an older,  
mature Apple/Next technology, called EOF, which is a shining example  
of the young Steve Jobs in full flight.  But as Mike points out it  
can get a bit hairy.  Even so, Core Data is simple at first so why  
not try to create a simple list of your GTD to-do  
'items' (NSTableView bound to an NSArrayController which holds your  
Core Data 'Items' table).  You might even give the to-do item  
'context' and 'done' attributes and a date or two for good GTD  
measure.  Someone who knew Core Data could set that up in 3 minutes  
flat.  It might take you a day :) but you'd learn a lot.   The  
default Core Data projects in Xcode will take you a long way.


Experience has shown that this is a truly awful way to learn Cocoa,  
and Core Data and Cocoa bindings in particular.
The documentation could hardly be more explicit about this, at least  
as far as Core Data is concerned:



To mostly mix metaphors, running before you can walk is simply going  
to leave you confused and frustrated when you find you have no idea  
where you are and how you got there.
Learn the basics first, then progress to the more complex technologies  
that build on them.
This document  provides a general learning path.  A tutorial-based text such as  
Aaron's is a good way to get started.


mmalc

___

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

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

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

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


Re: Saving a plist file from a thumbdrive

2009-03-04 Thread Olivier Palliere


On Mar 4, 2009, at 9:49 PM, Benjamin Dobson wrote:



On 4 Mar 2009, at 20:17:21, Francois Cournoyer wrote:


Hi,

We have an installer app that runs from the root folder of a  
thumbdrive like device,
The installer is ran from a subfolder or from subfolder on a hard  
disk works correctly.
The problem is when it runs from the root of the thumbdrive,  
everything seems to be installing fine, but there’s 1 area which  
seems to fail.
We create a plist file for preferences in users/shared/Application  
Support/myApp/myApp.plist


I know this is a trivial question, but you are using a leading / in  
the path you try to save (just asking cause it's not in your mail).



Olivier./.





for some reason, the creation of this file fails, but works if it’s  
launched for a subfolder on the same drive.


Is there anyway to fix this? (the installer is already running with  
Admin rights)


Probably, but is there any reason you can't create the plist on  
first launch instead of install? 
___


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

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

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

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


Tag-At-Selected-Item?

2009-03-04 Thread Dave
With regard to Menus and PopUpButtons;
How do I get the item tag using the indexOfSelectedItem?

Dave






  
___

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

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

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

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


Caps Lock Icon in NSTextField

2009-03-04 Thread Rich Collyer
Is there a standard way to have the Caps Lock icon show up in an  
NSTextField?


If not, is the icon available for general use, so I can place it there  
when I notice the state change of the caps lock key?


+++
Rich Collyer - Senior Software Engineer
+++






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

MVC - Model View Control

2009-03-04 Thread Smith, Steven (MCP)
Hi List!

I'm trying to do coding with adherence to MVC, but I haven't found
a good reference (eg book, ebook, amazon.com, et.al.) that wraps
the elements together. There are are lots of white-papers and blogs,
but can any recommend a good book that 'glues' the ideas together.
I think I understand the concept, I just want to make sure the
practice is in play.

Regards and 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: Tag-At-Selected-Item?

2009-03-04 Thread Graham Cox


On 05/03/2009, at 11:39 AM, Dave wrote:


With regard to Menus and PopUpButtons;
How do I get the item tag using the indexOfSelectedItem?



with a pop-up button:

[[popUpButton itemAtIndex:[popUpButton indexOfSelectedItem] tag];

or far more simply:

[[popUpButton selectedItem] tag];



For a plain NSMenu, your question doesn't have an answer, because  
NSMenu doesn't have a concept of a "selected item" and doesn't  
implement -indexOfSelectedItem, -selectedItem or anything similar.


--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: MVC - Model View Control

2009-03-04 Thread Graham Cox


On 05/03/2009, at 2:34 PM, Smith, Steven (MCP) wrote:


I'm trying to do coding with adherence to MVC, but I haven't found
a good reference (eg book, ebook, amazon.com, et.al.) that wraps
the elements together. There are are lots of white-papers and blogs,
but can any recommend a good book that 'glues' the ideas together.
I think I understand the concept, I just want to make sure the
practice is in play.



There's the classic "Design Patterns" by Gamma, Helm, Johnson and  
Vlissides which covers MVC and much more besides. It's required  
reading for any serious developer.


I assume you've been through the Cocoa guides on this?

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


Making NSTableView behave more like a spreadsheet with arrow keys

2009-03-04 Thread Dave Geering
Hi all,

Is there a clean way to subclass NSTableView or the field editor to
provide a way for users to change the currently editable cell in an
NSTableView by pressing the arrow keys? I've already tried subclassing
NSTableView but that will only be sent keyDown if a cell isn't being
edited, and I've tried creating a custom field editor but I cannot
reliably get the current position in the table so I don't know what to
pass to [tableView editColumn:row:withEvent:select] (assuming that's
the way I need to go).

Is NSTableView even the control I want? The table of data in my
application can span perhaps 100 rows and up to 5 columns. The user
will be expected to enter data into a fair majority of these cells. I
already have everything set up using bindings so that the user can
edit the data but it is painstakingly tedious to double-click on each
cell to change it's value. Tabbing works quite well but because there
are other responders in my window, tabbing in the last column takes
you to the next key view.

Thanks,
Dave.
___

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

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

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

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


Re: NSTextField woes

2009-03-04 Thread Robert Bielik

Nick Zitzmann skrev:



Did you try -setTextColor:?



setTextColor sets the nominal text color of the NSTextField, works fine, but I 
want a *different* color when the text (or part of it) is selected in the 
NSTextField (for contrast) and setTextColor has nothing to do with that...

/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