Re: Core Animation vs. Basic Cocoa Graphics

2010-03-11 Thread jonat...@mugginsoft.com


On 10 Mar 2010, at 17:13, Mazen M. Abdel-Rahman wrote:

 Hi All,
 
 I was able to write a simple calendar view that uses basic cocoa graphics to 
 draw directly on the view (NSBezierPath, etc.).  I actually use several 
 different paths for drawing the calendar (it's a weekly calendar) to allow 
 different horizontal line widths (hour, half hour, etc.).  The calendar view 
 is inside a scroll view - and is actually about 3 times longer than the view 
 window.   The main problem is that the scrolling is not smooth - and my 
 assumption is that it's because the NSBezier stroke functions  have to be 
 constantly called to render the calendar.
 
 For something as relatively simple as this would moving to core animation - 
 i.e. trying to render the calendar on a layer instead (I am still trying to 
 learn core animation) add performance benefits?  And would it allow for 
 smoother scrolling?
 
As no one else has offered an opinion:

Moving to CA might offer benefits but you can improve the performance of your 
existing code by using an image cache.
I do this for an NSView with animated NSBezierPath content and it works fine.

So I would draw my image when the view resizes and there after service - 
(void)drawRect:(NSRect)rect from the image cache.
You only regen the cache when required, say on resize on content change.

The rough code outline below might help you get something up an running:

NSView subclass:

ivars:

NSRect _cacheRect;
NSImage *_imageCache;
BOOL _useImageCache;

- (void)drawRect:(NSRect)rect 
{   

if (_useImageCache) {

// validate our rect
rect = [self validateDrawRect:rect];

// if cache exists use it to update rect.
// otherwise draw into our rect
if (_imageCache) {
[self drawRectFromCache:rect];
return;
} 

// draw to image cache
_cacheRect  = [self bounds];
_imageCache = [[NSImage alloc] initWithSize:_cacheRect.size];
[_imageCache lockFocus];

}

// draw entire bounds rect
rect = [self bounds];

// draw it
NSBezierPath *bgPath = [NSBezierPath bezierPathWithRect:rect];
NSColor *endColor = [NSColor colorWithCalibratedRed:0.988f green:0.988f 
blue:0.988f alpha:1.0f];
NSColor *startColor = [NSColor colorWithCalibratedRed:0.875f 
green:0.875f blue:0.875f alpha:1.0f];

NSGradient *gradient = [[NSGradient alloc] 
initWithStartingColor:startColor endingColor:endColor];
[gradient drawInBezierPath:bgPath angle:90.0f];


if (_useImageCache) {
[_imageCache unlockFocus];

// refresh view from cache
[self drawRectFromCache:rect];
}

}

/*
 
 draw rect from cache
 
 */
- (void)drawRectFromCache:(NSRect)rect
{
[_imageCache drawInRect:rect fromRect:rect 
operation:NSCompositeSourceOver fraction:1.0f];
}
/*
 
 validate the draw rect
 
 */
- (NSRect)validateDrawRect:(NSRect)rect
{
NSRect boundsRect = [self bounds];

// if bounds rect and cache rect are not equal then
// the cache will have to be updated
if (!NSEqualRects(boundsRect, _cacheRect)) {
[self clearDisplayCache];
}

// if no display cache available then need to draw bounds into cache
if (!_imageCache) {
rect = boundsRect;
}

return rect;
}

Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.com

___

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

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

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

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


Re: Core Animation vs. Basic Cocoa Graphics

2010-03-11 Thread Volker in Lists
Hi,

are you drawing ALL of your paths whenever the user scrolls or only the ones 
that are within the visible rect? If the first, you may try to change that to 
the second and gain lots of performance. I draw a sound wave view and when 
drawing all of it while zoomed into it, it is sooowww. But when I only draw 
what actually needs to be drawn, it is lightning fast.

With CoreAnimation: As soon as you have the image, you get fast drawing. 
Zooming, Size changes etc. may need a redraw of the image. Also, if the image 
is rather large, you'll need CATiledLayers otherwise your gpu memory may not be 
big enough to hold the image for the CALayer.

Volker

Am 10.03.2010 um 18:13 schrieb Mazen M. Abdel-Rahman:

 Hi All,
 
 I was able to write a simple calendar view that uses basic cocoa graphics to 
 draw directly on the view (NSBezierPath, etc.).  I actually use several 
 different paths for drawing the calendar (it's a weekly calendar) to allow 
 different horizontal line widths (hour, half hour, etc.).  The calendar view 
 is inside a scroll view - and is actually about 3 times longer than the view 
 window.   The main problem is that the scrolling is not smooth - and my 
 assumption is that it's because the NSBezier stroke functions  have to be 
 constantly called to render the calendar.
 
 For something as relatively simple as this would moving to core animation - 
 i.e. trying to render the calendar on a layer instead (I am still trying to 
 learn core animation) add performance benefits?  And would it allow for 
 smoother scrolling?
 
___

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

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

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

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


KVO on NSDictionary elements

2010-03-11 Thread Gustavo Pizano
Hello all.
Im implementing a live filter, and each, time I insert a filter in the 
filterDictionary the controller (which is another class) gets notified about 
the insertion.\
I was reading the KVO, and its says something about NSKeyValueChangeKindKey.

So this is what Im doing in the Controller class:

[_filterController addObserver:self forKeyPath:@_filterSettings 
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) 
context:NULL];

so I undertand that as it is above I will get notified only when I setUp a new 
NSDictionary in the ivar _filterSettings, obviously Im not getting notified 
when I insert something in the _filterSettings dictionary.

How should I add the observer? is it possible to do so?

thanks

 Gustavo


___

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

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

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

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


Re: How to debug this error on closing a document?

2010-03-11 Thread Gideon King
Well I spent some of the day going through the application with the analyzer - 
first time I have used it, and I'm pretty impressed - I like the way it draws 
the lines showing the relevant lines of code...but although it did pick up some 
leaks etc, it made no difference to my specific problem.

When I run with zombies enabled outside instruments, it just gets to 

*** -[NSManagedObjectContext release]: message sent to deallocated instance 
0x100e99710

(where I have set a breakpoint) with a backtrace of:

#0  0x7fff80e5be36 in ___forwarding___ ()
#1  0x7fff80e581d8 in __forwarding_prep_0___ ()
#2  0x7fff856fb99e in -[NSConcreteNotification dealloc] ()
#3  0x7fff80e06e43 in __CFArrayReleaseValues ()
#4  0x7fff80de7bc8 in _CFArrayReplaceValues ()
#5  0x7fff8573081a in postQueueNotifications ()
#6  0x7fff80e49427 in __CFRunLoopDoObservers ()
#7  0x7fff80e254af in __CFRunLoopRun ()
#8  0x7fff80e24c2f in CFRunLoopRunSpecific ()
#9  0x7fff831b9a4e in RunCurrentEventLoopInMode ()
#10 0x7fff831b9853 in ReceiveNextEventCommon ()
#11 0x7fff831b970c in BlockUntilNextEventMatchingListInMode ()
#12 0x7fff860f51f2 in _DPSNextEvent ()
#13 0x7fff860f4b41 in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#14 0x7fff860ba747 in -[NSApplication run] ()
#15 0x000100331774 in -[OAApplication run] ()
#16 0x7fff860b3468 in NSApplicationMain ()
#17 0x00011af3 in main (argc=3, argv=0x7fff5fbff478) at 
/Users/gideon/Development/svn/trunk/mac/Source/main.m:11

...and if I continue from there, it just gets a sigkill and dies.

So I'm unsure what I can do with this backtrace to find out what this 
notification is, or whether I would have to subclass NSConcreteNotification and 
override dealloc and then use pose as, so I could  print out the notification 
name etc, to get the info...is there a simpler way of seeing what the 
notification is?

But even if I do find that, I'm really not sure that it would be much help 
because presumably it means that some notification was sent with the managed 
object context as the object, in which case it would just be retained and then 
released when the notification is released, so presumably whatever the 
notification is, it's not the root cause of the problem - just something that 
delays the visibility of the issue. Correct?

I still don't quite understand how there can only be two events on this object 
as per the instruments output:

#   CategoryEvent Type  RefCt   Timestamp   Address Size
Responsible Library Responsible Caller
0   NSManagedObjectContext  Malloc  1   00:12.552   0x1008d01f0 
240 AppKit  -[NSPersistentDocument managedObjectContext]
1   NSManagedObjectContext  Zombie  -1  00:26.194   0x1008d01f0 
0   Foundation  -[NSConcreteNotification dealloc]

And yet it ends up a zombie.

Still totally mystified by this and looking for suggestions on how to track it 
down.

Thanks in advance.

Gideon

On 11/03/2010, at 11:05 AM, Kyle Sluder wrote:

 On Wed, Mar 10, 2010 at 4:45 PM, Gideon King gid...@novamind.com wrote:
 Seeing as none of this appears to have anything to do with my code, I am 
 assuming that some notification created somewhere in my application is 
 somehow the cause, but I'm not sure how to track this down.
 
 Run the analyzer first, then if that doesn't turn up any problems use
 NSZombieEnabled outside of Instruments.
 
 --Kyle Sluder

___

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

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

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

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


Unable to receive keyDown Event in NSBorderlesswindow

2010-03-11 Thread Poonam Virupaxi Shigihalli

Hi,

I am using NSBorderless style mask  for window  and I am unable to receive the 
NSKeyDown event for that window.But if I make the window style as titled then I 
am able to receive the keyDown events.

I am using below function for Keydown event:

- (void)keyDown:(NSEvent *) event




Thanks,
Poonam 

___

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

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

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

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


Re: Unable to receive keyDown Event in NSBorderlesswindow

2010-03-11 Thread Dado Colussi
 I am using NSBorderless style mask  for window  and I am unable to receive 
 the NSKeyDown event for that window.But if I make the window style as titled 
 then I am able to receive the keyDown events.

 I am using below function for Keydown event:

 - (void)keyDown:(NSEvent *) event


Implement -(BOOL)canBecomeKeyWindow and return YES.

The NSWindow implementation returns YES if the receiver has a title
bar or a resize bar, NO otherwise. A borderless window does not have a
titlebar or a resize bar, hence it returns NO and never receives the
event.

/Dado
___

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

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

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

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


Re: Unable to receive keyDown Event in NSBorderlesswindow

2010-03-11 Thread Ron Fleckner


On 11/03/2010, at 10:57 PM, Poonam Virupaxi Shigihalli wrote:



Hi,

I am using NSBorderless style mask  for window  and I am unable to  
receive the NSKeyDown event for that window.But if I make the window  
style as titled then I am able to receive the keyDown events.


I am using below function for Keydown event:

- (void)keyDown:(NSEvent *) event




Thanks,
Poonam


Hello Poonam,

in your window subclass, you need to override -canBecomeKeyWindow to  
return YES


From the NSWindow class reference:

canBecomeKeyWindow
Indicates whether the window can become the key window.

- (BOOL)canBecomeKeyWindow

Return Value
YES if the window can become the key window, NO otherwise.

Discussion
Attempts to make the window the key window are abandoned if this  
method returns NO. The NSWindowimplementation returns YES if the  
window has a title bar or a resize bar, NO otherwise.




Hope that helps,

Ron
___

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

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

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

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


EXC_BAD_ACCESS

2010-03-11 Thread Billy Flatman
Hi All,

I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath.
Below is an outline of my code.


@interface Shape : NSObject {
NSBezierPath *path;
}
- (void)paint;
@end

@implementation Shape
- (void) paint {
[[NSColor redColor] set];
[path fill];
}
@end

@interface Square : Shape Moveable {}
- (Square *) initSquare;
- (void)initBezierPath;
@end

@implementation Square
- (Square *) initSquare {
self = [super init];
if (self) {
path = [[NSBezierPath alloc] init]; 
[self initBezierPath];
}
return self;
}
- (void) initBezierPath {
path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10)
   xRadius:5
   yRadius:5];
[path closePath];
}
@end

it works if I change initBezierPath content to:

path = [path init];
[path appendBezierPathWithRoundedRect:r
  xRadius:5
  yRadius:5];
[path closePath]; 

 From the main body I initialise a Square and call it's paint method in the 
drawRect method of an NSView.

Any help would be greatly appreciated.

Billy Flatman
b.flat...@googlemail.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: EXC_BAD_ACCESS

2010-03-11 Thread Thomas Davie
Your initBezierPath method reallocates and reinitialises a path that's already 
been created.  It also autoreleases the result (as the allocation method 
doesn't start with alloc, copy, mutableCopy, retain or new).

The result is that the first time 'path' is assigned it gets a non-released 
value.

The second time that 'path' is assigned, the original value is leaked, as it is 
never released, and it is given a new value which is autoreleased.  By the time 
you get to your paint method being called, the runloop has completed, and the 
path has been deallocated.

What you probably want is...
- (id)initSquare // Note, id, not Square, this way, when we subclass, the type 
system won't explode.
{
  self = [super init];

  if (nil != self)
  {
path = [[NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10) 
xRadius:5 yRadius:5] retain];
  }
  
  return self;
}

- (void)dealloc
{
  [path release];
}

Bob

On 11 Mar 2010, at 13:38, Billy Flatman wrote:

 Hi All,
 
 I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath.
 Below is an outline of my code.
 
 
 @interface Shape : NSObject {
   NSBezierPath *path;
 }
 - (void)paint;
 @end
 
 @implementation Shape
 - (void) paint {
   [[NSColor redColor] set];
   [path fill];
 }
 @end
 
 @interface Square : Shape Moveable {}
 - (Square *) initSquare;
 - (void)initBezierPath;
 @end
 
 @implementation Square
 - (Square *) initSquare {
   self = [super init];
   if (self) {
   path = [[NSBezierPath alloc] init]; 
   [self initBezierPath];
   }
   return self;
 }
 - (void) initBezierPath {
   path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10)
  xRadius:5
  yRadius:5];
   [path closePath];
 }
 @end
 
 it works if I change initBezierPath content to:
 
 path = [path init];
 [path appendBezierPathWithRoundedRect:r
 xRadius:5
 yRadius:5];
 [path closePath]; 
 
 From the main body I initialise a Square and call it's paint method in the 
 drawRect method of an NSView.
 
 Any help would be greatly appreciated.
 
 Billy Flatman
 b.flat...@googlemail.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/tom.davie%40gmail.com
 
 This email sent to tom.da...@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: EXC_BAD_ACCESS

2010-03-11 Thread Thomas Davie
Oops, sorry, my dealloc was buggy o.O

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

Bob

On 11 Mar 2010, at 13:38, Billy Flatman wrote:

 Hi All,
 
 I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath.
 Below is an outline of my code.
 
 
 @interface Shape : NSObject {
   NSBezierPath *path;
 }
 - (void)paint;
 @end
 
 @implementation Shape
 - (void) paint {
   [[NSColor redColor] set];
   [path fill];
 }
 @end
 
 @interface Square : Shape Moveable {}
 - (Square *) initSquare;
 - (void)initBezierPath;
 @end
 
 @implementation Square
 - (Square *) initSquare {
   self = [super init];
   if (self) {
   path = [[NSBezierPath alloc] init]; 
   [self initBezierPath];
   }
   return self;
 }
 - (void) initBezierPath {
   path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10)
  xRadius:5
  yRadius:5];
   [path closePath];
 }
 @end
 
 it works if I change initBezierPath content to:
 
 path = [path init];
 [path appendBezierPathWithRoundedRect:r
 xRadius:5
 yRadius:5];
 [path closePath]; 
 
 From the main body I initialise a Square and call it's paint method in the 
 drawRect method of an NSView.
 
 Any help would be greatly appreciated.
 
 Billy Flatman
 b.flat...@googlemail.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/tom.davie%40gmail.com
 
 This email sent to tom.da...@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: EXC_BAD_ACCESS

2010-03-11 Thread Roland King
isn't this almost exactly the same question you asked a week ago? It looks like 
you did 1/2 of what Graham told you then but didn't totally understand his 
answer. 

Same answer, you're setting path to a newly-created NSBezierPath you don't own 
and overwriting the one you alloc/init'ed earlier. So you're leaking the first 
one and the second one you don't own so it's being released causing the bad 
access error. 

this line by the way

path = [ path init ];

is illegal, you can't init something twice. The second version happens to work 
(even apart from the illegal extra init) because it appends a path to the 
bezier which already exists, which you then aren't leaking. 

It might help to go read the creation/destruction of objects and memory 
management chapters again until it clicks. 


On 11-Mar-2010, at 9:38 PM, Billy Flatman wrote:

 Hi All,
 
 I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath.
 Below is an outline of my code.
 
 
 @interface Shape : NSObject {
   NSBezierPath *path;
 }
 - (void)paint;
 @end
 
 @implementation Shape
 - (void) paint {
   [[NSColor redColor] set];
   [path fill];
 }
 @end
 
 @interface Square : Shape Moveable {}
 - (Square *) initSquare;
 - (void)initBezierPath;
 @end
 
 @implementation Square
 - (Square *) initSquare {
   self = [super init];
   if (self) {
   path = [[NSBezierPath alloc] init]; 
   [self initBezierPath];
   }
   return self;
 }
 - (void) initBezierPath {
   path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10)
  xRadius:5
  yRadius:5];
   [path closePath];
 }
 @end
 
 it works if I change initBezierPath content to:
 
 path = [path init];
 [path appendBezierPathWithRoundedRect:r
 xRadius:5
 yRadius:5];
 [path closePath]; 
 
 From the main body I initialise a Square and call it's paint method in the 
 drawRect method of an NSView.
 
 Any help would be greatly appreciated.
 
 Billy Flatman
 b.flat...@googlemail.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/rols%40rols.org
 
 This email sent to r...@rols.org

___

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

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

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

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


Re: Help visualizing something in IB

2010-03-11 Thread Brian Postow

On Mar 10, 2010, at 8:04 PM, Quincey Morris wrote:

 On Mar 10, 2010, at 15:54, Brian Postow wrote:
 
 Basically, I want the topView to scroll, but I always want to be able to see 
 the buttonView. So if part of the topView isn't visible because it's been 
 scrolled up, I want the buttonview at the top of the screen.
 
 I think what I want is to have a sort of topView2 which is the intersection 
 between topView and the contentView of the ScrollView, if that makes more 
 sense...
 
 It makes sense, but it doesn't have much precedent in terms of known Mac 
 interfaces. Won't the visual effect be that the buttons appear to float over 
 the window content some of the time? But with the weird side effect that the 
 image below the buttons will get smaller as you scroll, until ... what? At 
 some point does the image view get too small and disappear? When there's not 
 enough vertical room to show the whole buttons, do they start scrolling out 
 of the window?
 
 It seems awfully ad-hoc, but anyway ...

Yeah, I think that that is what I wanted, and yeah, it does sound a little 
ad-hoc...
 
 In case the backstory helps, I'm writing a plugin for Mozilla. So, the 
 outermost scrollwindow is the firefox view, and then my plugin is within 
 an HTML frame inside the page, so I'm scrolling around in the firefox 
 window, and whenever my plugin is visible, I want the buttons at the top of 
 it... 
 
 Yeah, that does help a bit.
 
 If you must follow this approach, then I'd suggest you register to get 
 frame-changed notifications from topView. That way, you'll know if it moved 
 within the window, or if it was resized as a result of the window/enclosing 
 view resizing. Also, turn off auto-resizing for subviews of topView.
 
 When you get a notification, examine the geometry of the page, and re-layout 
 your subviews appropriately (float the buttons, resize the image, etc). 
 You'll then be able to avoid geometry collapse when the visible part of 
 topView gets small.

Interesting. I think I agree with you that this sounds like it's more effort 
than it's worth... I like your approach, and I'll probably end up using it if 
and when this feature makes it back to the top of my list...

 


THANKS!

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

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

Help/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 does not get refreshed after Window deminimized...

2010-03-11 Thread cocoa learner
Hi All,

I have subclassed a custom view in following way -

@implementation AppContentView


- (id)initWithFrame: (NSRect)frame

{

self = [super initWithFrame:frame];

if (self)

{

// Initialization code here.

}

return self;

}


- (void)drawRect:(NSRect)rect

{

[[NSColor colorWithDeviceRed:0.961 green:0.961 blue:0.961 alpha:0.5] set];

[NSBezierPath fillRect: rect];

[super drawRect:rect];

}


@end


And on this custom view I have a progress bar, that progressbar gets it's
progress value from a NSThread. And I am using following function render the
progressbar, from NSThread -


[progBar performSelectorOnMainThread: (display) withObject: nil
waitUntilDone: YES];


Every thing works fine except in following scenario -


1. Minimize window while progress bar is at not completed (non 1.0), say
it's in 0.20 value,

2. After waiting some time, maximize the app window when progress bar is
completed (it's value is 1.0),

3. When window comes up it's only shows the progress bar up *0.20. *I am
handling notification* - NSWindowDidDeminiaturizeNotification.*

*
*

*Here is the code of notification handler and this handler is getting called
-*

*
*

**
*

- (void) deminimizedNotificationHandler

{

if ([progBar doubleValue] == 1.0)

{

[progBar setDoubleValue: 1.0];

[progBar setHidden: YES];

}


}
*

*
*

Does any body know why the why my progress bar is not getting completed...or
refreshed ...??? Even when it's value is 1.0



Regards

Cocoa.learner
___

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

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

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

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


IsFileOnARemoteVolume

2010-03-11 Thread gMail.com
I am trying to code my own API isFileOnARemoteVolume since I didn't find
anything similar on Cocoa. If any, please let me know.

I use statfs to detect whether the filePath I pass as variable is on a
remote volume. Anyway, this wont work in case of broken symlinks.
So I have used a dirty trick to get the volumePath then I pass the
volumePath  to the function statfs. Did I do right? Is a better or faster
way?

- (BOOL)isFileOnARemoteVolume:(NSString*)filePath
{
if([filePath length] == 0 ||
[filePath characterAtIndex:0] != '/') return NO;

NSMutableString*volumePath = [NSMutableString
stringWithString:@/];
if([filePath startsWith:@/Volumes]){
NSArray*comps = [filePath componentsSeparatedByString:@/];
[volumePath appendString:[comps objectAtIndex:1]];
[volumePath appendString:@/];
[volumePath appendString:[comps objectAtIndex:2]];
}
const char*cPathVolume = [mManager
fileSystemRepresentationWithPath:volumePath];

structstatfs stf;
if(statfs(cPathVolume, stf) != 0) return NO;

BOOLisRemoteVolume = ((stf.f_flags  MNT_LOCAL) == 0);

return isRemoteVolume;
}

On the previous version of this method I used FSGetVolParms then
(volParms.vMServerAdr != 0) but now I would like to avoid to use the Carbon
routines.

Regards
--
Leonardo


___

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

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

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

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


NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov

Hi, All.

I have a table view in the main window, where it works fine. And  
have yet another very similar table view in a popup modal panel. where  
it fails immediately after panel is closed. Debugger shows subj, as  
the failure point. In both cases dataSource for table view is assigned  
in the IB statically.


The problem disappears if I clear dataSource assignment in the IB and  
include this assignment into awakeFromNib of the window controller.  
Also I include [myTableView setDataSource:nil] into -windowWillClose  
event handler of the same window controller. I tried to manipulate  
with release when closed option of the window - no effect.


What it could be?

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


NSTextView backed by core data, undo problems

2010-03-11 Thread Martin Hewitson
Dear list,

I have a puzzling problem which is making my puzzler sore.

Here's the outline:

I have a core-data doc based app. I have core data entities which represent 
files on disk. When the entity is created, the contents of the file are loaded 
(in to a binary-data attribute called 'content'). Now I have an outline view 
which shows the project-tree of files. Double-clicking an item in the 
project-tree (outlineview) adds that NSManagedObject to an NSArrayController 
class (opened files). There is then an NSTextView which is bound to the 
'content' attributed of the currently selected file in the array controller.

So far, so good. Almost everything is working as I expect.

The nasty little problem I have is that if I edit the contents of a file via 
the NSTextView, then do 'undo', the cursor (selection) in the NSTextView jumps 
to the end of the document, and the scrollview jumps to the top. Almost as if 
the whole text has been replaced. The only way I can avoid this so far is to 
set the binding so that it doesn't 'update continuously'. One other symptom is 
that each undo removes the last character typed, whereas with 'update 
continuously' off I get the more common behaviour of undoing the last word or 
at least recent group of actions.

Does anyone have any insights in to what I might be doing wrong? I tried with a 
toy project and I'm getting the same results. 

Best wishes,

Martin




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






___

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

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

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

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


Bug with the ABPeoplePicker drag?

2010-03-11 Thread Eric Giguere
Hi all

I've been experiencing problems with the drag and drop from the Address book 
control in my application. The control is in a view where a TableList is the 
destination for the drag.

When the drop message is sent to my view, the following message is sent back to 
the control, as instructed for the File Promise type:
   NSArray *filenames = [sender 
namesOfPromisedFilesDroppedAtDestination:theUrl];

The value assigned to theUrl has been validated.

When the message is sent, the following error is displayed:
-[ABPeoplePickerTableEntry addressBook]: unrecognized selector sent to instance 
0x114b67f20

And of course, no file is created.

But, as I found out with great joy yesterday night, this works perfectly if the 
drag originates from the Address Book application!

So I did some other tests:  take an entry from the control in my application 
and drop it on my desktop. Exact same behaviour, error. But of course again, 
from the Application itself, bingo you have a vCard created.

Any idea? I may have missed a configuration somewhere.. If not, how do we 
signal those potential bugs to the code's rightful owner?

Thank you.
Eric.





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: How to debug this error on closing a document?

2010-03-11 Thread Jerry Krinock

On 2010 Mar 11, at 02:27, Gideon King wrote:

 or whether I would have to subclass NSConcreteNotification and override 
 dealloc and then use pose as, so I could  print out the notification name 
 etc, to get the info

That would work, but Method Replacement [1] was added in Objective-C 2.0 as a 
replacement for pose as class.  However, to do Method Replacement, you need 
to declare and implement a category on, in this case NSConcreteNotification, 
but that won't compile because NSConcreteNotification is Apple-private.  Does 
anyone know how to do Method Replacement for debugging in an Apple-private 
class?

[1] 
http://developer.apple.com/mac/library/samplecode/MethodReplacement/index.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: [[Class alloc] init] preferable over [[Class instance] retain]?

2010-03-11 Thread Matt Neuburg
On Tue, 9 Mar 2010 23:58:55 +, Jeff Laing jeff.la...@spatialinfo.com
said:
The upshot was that apparently the iPhone developers like you to avoid the use
of autorelease pools where possible.  One hidden difference in the above is that
in the first case you have (probably) populated the autorelease pool and in the
other you (probably) haven't.

I don't think it's accurate to say that you're supposed to avoid autorelease
pools on iPhone. The quoted statement seems to me to misrepresent the docs,
the comments from Apple in their examples, and so forth.

What they're trying to say, it seems to me, is just the opposite: you should
*use* autorelease pools on iPhone. What you should *not* do, if you can
avoid it, is rely on the *implicit* autorelease pool.

In other words, the problem with this:

NSString* s = [NSString stringWithFormat...];

...is that you don't know when s will be released. In some situations, you
can easily fill up a lot of memory before the implicit autorelease pool is
drained. One solution is to create an autorelease pool and release it
explicitly. This puts *you* in charge of marking objects for release. In
other words, to alloc and release an autorelease pool is (or can be) just as
good as alloc and release of individual objects. And it takes care of the
problem where autoreleased objects are inevitable or are created behind your
back.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Fritz Anderson
On 11 Mar 2010, at 9:38 AM, Alexander Bokovikov wrote:

 I have a table view in the main window, where it works fine. And have yet 
 another very similar table view in a popup modal panel. where it fails 
 immediately after panel is closed. Debugger shows subj, as the failure point. 
 In both cases dataSource for table view is assigned in the IB statically.

1. You don't say what fail means. A crash? What error code? What stack trace?

2. This is all moot, because, as the leading underscore shows, 
_dataSourceValueForColumn:row: is a private method. It is not meant to be 
called by anyone but Apple. It is likely that only Apple knows what the 
preconditions and postconditions for calling it are; and they can change those 
conditions at any time. 

I Googled _dataSourceValueForColumn:. Have you noticed that virtually all the 
hits have titles like Arbitrary Crashes, Bug, Consistently crashes, 
issue, crashes everytime, Crash in my... data source?

3. Now that I re-read your message, you don't say whether you're implementing 
_dataSourceValueForColumn:row: or calling it; or even whether you're using it 
at all. Even if you're just implementing it, the principle holds: You don't 
know what the method is required to do, and you don't know what it will be 
required to do in 10.6.3. (Note for archives: The current version of Mac OS X 
is 10.6.2.)

What are you trying to accomplish, and why do you think it cannot be done with 
supported API?

— F

___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Corbin Dunn

On Mar 11, 2010, at 7:38 AM, Alexander Bokovikov wrote:

 Hi, All.
 
 I have a table view in the main window, where it works fine. And have yet 
 another very similar table view in a popup modal panel. where it fails 
 immediately after panel is closed. Debugger shows subj, as the failure point. 
 In both cases dataSource for table view is assigned in the IB statically.
 
 The problem disappears if I clear dataSource assignment in the IB and include 
 this assignment into awakeFromNib of the window controller. Also I include 
 [myTableView setDataSource:nil] into -windowWillClose event handler of the 
 same window controller. I tried to manipulate with release when closed 
 option of the window - no effect.
 
 What it could be?

Break on objc_exception_throw.

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: Help visualizing something in IB

2010-03-11 Thread Quincey Morris
On Mar 10, 2010, at 8:04 PM, Quincey Morris wrote:

 If you must follow this approach, then I'd suggest you register to get 
 frame-changed notifications from topView. That way, you'll know if it moved 
 within the window, or if it was resized as a result of the window/enclosing 
 view resizing. Also, turn off auto-resizing for subviews of topView.

For completeness:

I didn't think this through properly. Your topView is inside a view that's what 
is actually scrolled (the scroll view's documentView), so the topView frame 
won't change as a result of scrolling. I think what you'd need would be to 
observe the scroll view's clipView's bounds, which should change on either 
scrolling or resizing. If you ever get to doing this, you'll have to experiment 
to find the right thing to observe, and it's possible you might have to observe 
multiple views to catch all the cases.


___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov

On Thursday, March 11, 2010 at 10:11 PM Fritz Anderson wrote:


1. You don't say what fail means. A crash?
What error code? What stack trace?


EXC_BAD_ACCESS. Assembler call stack view shows line next to the subj call.

OS X 10.5.8 Never tried it in 10.6.X


2. This is all moot, because, as the leading underscore shows,
_dataSourceValueForColumn:row: is a private method.
It is not meant to be called by anyone but Apple. It is likely
that only Apple knows what the preconditions and postconditions
for calling it are; and they can change those conditions at any time.


Of couse, I never called it directly. I never implemented it. I just _use_ 
NSTableView. Nothing more. The fact is that it is working nice in the main 
app, where it is never destroyed explicitly. But it doesn't work correctly 
in a modal window, which I create and then release. As I've described the 
only way I've found is to assign the datasource explicitly in awakeFromNib 
and set it to nil explicitly in windowWillClose handler.


Really my question was - is this a known bug, a feature or my mistake?

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: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov


On Thursday, March 11, 2010 at 10:29 PM Corbin Dunn wrote:


Break on objc_exception_throw.


Could you explain it? What does it mean?

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: View does not get refreshed after Window deminimized...

2010-03-11 Thread Quincey Morris
On Mar 11, 2010, at 06:50, cocoa learner wrote:

 And on this custom view I have a progress bar, that progressbar gets it's
 progress value from a NSThread. And I am using following function render the
 progressbar, from NSThread -
 
 
 [progBar performSelectorOnMainThread: (display) withObject: nil
 waitUntilDone: YES];

There seem to be two things wrong here.

First, you must *not* set the value of the progress bar from a non-main thread. 
Setting the value causes a UI update, and that won't work properly unless it's 
done on the main thread. Instead, you must devise a method for the background 
thread to pass the desired value to the main thread, and have the main thread 
set the progress bar value.

Second, it's rarely correct to invoke [NSView display] yourself. Typically, you 
would use [NSView setNeedsDisplay].

In any case, it's not clear why you think you need to cause the progress bar to 
redisplay. If you set the value properly from the main thread, it will 
redisplay itself as necessary. If you're having a problem with the animation 
not running, you just need to make sure you set (or re-set) the value often 
enough.


___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Fritz Anderson
On 11 Mar 2010, at 11:44 AM, Alexander Bokovikov wrote:

 Of couse, I never called it directly. I never implemented it. I just _use_ 
 NSTableView. Nothing more. The fact is that it is working nice in the main 
 app, where it is never destroyed explicitly. But it doesn't work correctly in 
 a modal window, which I create and then release. As I've described the only 
 way I've found is to assign the datasource explicitly in awakeFromNib and set 
 it to nil explicitly in windowWillClose handler.

I misunderstood. My mistake.

Have you run with zombies enabled? It's almost the first thing you should do if 
you get an EXC_BAD_ACCESS in framework code. Also, be sure Run  Stop on 
Objective-C Exceptions is checked.

— F

___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Eli Bach

On Mar 11, 2010, at 10:44 AM, Alexander Bokovikov wrote:

 Of couse, I never called it directly. I never implemented it. I just _use_ 
 NSTableView. Nothing more. The fact is that it is working nice in the main 
 app, where it is never destroyed explicitly. But it doesn't work correctly in 
 a modal window, which I create and then release. As I've described the only 
 way I've found is to assign the datasource explicitly in awakeFromNib and set 
 it to nil explicitly in windowWillClose handler.
 
 Really my question was - is this a known bug, a feature or my mistake?

Alexander,

This seems to describe that you are releasing the datasource before the 
tableview that uses it is released [possibly by over-releasing it, as I would 
assume the tableview would retain it, but it may not].

Maybe make sure your window is released before the source is released.  Or at 
the very least, that the window is closed/offscreen before the source is 
released.

Eli

___

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

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

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

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


Need help with scrolling marquee

2010-03-11 Thread Michael A. Crawford
I'm trying to create an effect on the iPhone to scroll text across the view in 
a given location.  Not really sure how to go about it so I did some 
experimenting.  Af first I tried to animate the scroll using a timer.  That 
gave me inconsistent movement; the velocity of the scrolling text appeared to 
be non-constant.  Then I remembered that CoreAnimation is really supposed to 
take care of this kind of animation for you so I switch to trying to get it to 
manage the timing for me.  I must be doing it all wrong because I cannot 
control the velocity of the scrolling text.

I expect my whole approach is probably wrong and am hoping that one of you has 
a better approach or suggestions as to how to fix it.  I haven't found much in 
the way of CAScrollView documentation or examples to help.  I've included the 
code below.  Hopefully the length will not be an issue.

//
//  ScrollingMarqueeViewController.m
//  ScrollingMarquee
//
//  Created by Michael A. Crawford on 3/11/10.
//  Copyright Crawford Design Engineering, LLC 2010. All rights reserved.
//

#import QuartzCore/QuartzCore.h

#import ScrollingMarqueeViewController.h

@implementation ScrollingMarqueeViewController

@synthesize scrollLabel;

- (CALayer*)textLayer
{
scrollLabel.text = @this is a long line of text that should be too long 
for 
@the screen width of this label.;
return scrollLabel.layer;
}

- (CAScrollLayer*)scrollLayer
{
CAScrollLayer* layer = [CAScrollLayer layer];
[layer addSublayer:[self textLayer]];
return layer;
}

- (void)timerFireMethod:(NSTimer*)theTimer
{
#if 0
// Here I was using a periodic timer to animate the scroll.  I noticed that
// the animation wasn't smooth and then remembered that CA is supposed to do
// the animating for me.  So, I switched to trying the code below but that
// doesn't work either.  I'm really just grasping at straws here.
static CGPoint origin = {0.0f, 0.0f};
origin.x += 5.0f;
[scrollLayer scrollToPoint:origin];
#else
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:5.0];
[scrollLayer scrollToPoint:CGPointMake(320.0f, 0.0f)];
[UIView commitAnimations];
#endif
}

- (void)viewDidLoad
{
[super viewDidLoad];

// create the scroll layer and add it to our view
scrollLayer = [self scrollLayer];
[self.view.layer addSublayer:scrollLayer];

// make it the same size as our label
scrollLayer.bounds = scrollLabel.frame;

// position it in the middle of the view
scrollLayer.position = CGPointMake(320.0f * 0.5f, 480.0f * 0.5f);

// scroll the text horizontally
scrollLayer.scrollMode = kCAScrollHorizontally;

// use a timer to make the scroll happen
scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
   target:self
 
selector:@selector(timerFireMethod:)
 userInfo:nil
  repeats:/*YES*/NO];
}

@end

___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Corbin Dunn

On Mar 11, 2010, at 9:48 AM, Alexander Bokovikov wrote:

 
 On Thursday, March 11, 2010 at 10:29 PM Corbin Dunn wrote:
 
 Break on objc_exception_throw.
 
 Could you explain it? What does it mean?

http://www.corbinstreehouse.com/blog/2008/08/your-most-important-breakpoint-in-cocoa/

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: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Corbin Dunn

On Mar 11, 2010, at 9:44 AM, Alexander Bokovikov wrote:

 On Thursday, March 11, 2010 at 10:11 PM Fritz Anderson wrote:
 
 1. You don't say what fail means. A crash?
 What error code? What stack trace?
 
 EXC_BAD_ACCESS. Assembler call stack view shows line next to the subj call.
 
 OS X 10.5.8 Never tried it in 10.6.X
 
 2. This is all moot, because, as the leading underscore shows,
 _dataSourceValueForColumn:row: is a private method.
 It is not meant to be called by anyone but Apple. It is likely
 that only Apple knows what the preconditions and postconditions
 for calling it are; and they can change those conditions at any time.
 
 Of couse, I never called it directly. I never implemented it. I just _use_ 
 NSTableView. Nothing more. The fact is that it is working nice in the main 
 app, where it is never destroyed explicitly. But it doesn't work correctly in 
 a modal window, which I create and then release. As I've described the only 
 way I've found is to assign the datasource explicitly in awakeFromNib and set 
 it to nil explicitly in windowWillClose handler.
 
 Really my question was - is this a known bug, a feature or my mistake?

Howdy! We would really need to see a backtrace at the point of the crash or 
exception being thrown. It is probably a bug in your app.

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: Help visualizing something in IB

2010-03-11 Thread Brian Postow

On Mar 11, 2010, at 1:04 PM, Quincey Morris wrote:

 On Mar 10, 2010, at 8:04 PM, Quincey Morris wrote:
 
 If you must follow this approach, then I'd suggest you register to get 
 frame-changed notifications from topView. That way, you'll know if it moved 
 within the window, or if it was resized as a result of the window/enclosing 
 view resizing. Also, turn off auto-resizing for subviews of topView.
 
 For completeness:
 
 I didn't think this through properly. Your topView is inside a view that's 
 what is actually scrolled (the scroll view's documentView), so the topView 
 frame won't change as a result of scrolling. I think what you'd need would be 
 to observe the scroll view's clipView's bounds, which should change on either 
 scrolling or resizing. If you ever get to doing this, you'll have to 
 experiment to find the right thing to observe, and it's possible you might 
 have to observe multiple views to catch all the cases.
 


I should be able to just use the clipRect of the superview, right? 

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

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

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

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


Re: NSTextView backed by core data, undo problems

2010-03-11 Thread Kyle Sluder
On Thu, Mar 11, 2010 at 7:50 AM, Martin Hewitson
martin.hewit...@aei.mpg.de wrote:
 The nasty little problem I have is that if I edit the contents of a file via 
 the NSTextView, then do 'undo', the cursor (selection) in the NSTextView 
 jumps to the end of the document, and the scrollview jumps to the top. Almost 
 as if the whole text has been replaced. The only way I can avoid this so far 
 is to set the binding so that it doesn't 'update continuously'. One other 
 symptom is that each undo removes the last character typed, whereas with 
 'update continuously' off I get the more common behaviour of undoing the last 
 word or at least recent group of actions.

By setting the value continuously you're breaking the text view's undo
coalescing.

Doing this correctly is not going to be an easy task. You will need to
learn much about the Cocoa text system. The 30,000ft overview: you
want to mutate an NSTextStorage hooked up to the text view, rather
than simply setting a property on the model object. Core Data and KVC
don't support this pattern natively; you will need to write code, and
it can get hairy.

--Kyle Sluder
___

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

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

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

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


Noob iPhone Question

2010-03-11 Thread Michael Davey
Hi,

I am now being approached to develop an iPhone application for one of my 
clients which will involve storing a cache of previously downloaded images.  My 
question is whether or not there are constraints as to how my storage space I 
have at my disposal, and whether any of you have a link to further reading on 
this subject?

regards,

M___

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

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

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

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


[MEET] CocoaHeads-NYC tonight - NSOperation

2010-03-11 Thread Andy Lee
Sorry for the two hours' notice...

Marc van Olmen will give the talk entitled Introduction to NSOperation that 
he was unable to give last month.  I have no doubt it'll be worth the wait.

As usual:

(1) Please feel free to bring questions, code, and works in progress. We have a 
projector and we like to see code and try to help.
(2) We'll have food and beer afterwards.
(3) If there's a topic you'd like presented, let us know.
(4) If *you'd* like to give a talk, let me know.

Thursday, March 11
6:00 - 8:00
Downstairs at Tekserve, on 23rd between 6th and 7th
http://tekserve.com/about/hours.php for directions and map
Everyone's welcome. Just tell the person at the front you're there for 
CocoaHeads.

Hope to see you there!

--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: Noob iPhone Question

2010-03-11 Thread Michael Davey
Thanks - I think I may still implement some form of cache control just to keep 
it manageable though.


On 11 Mar 2010, at 21:32, Thomas Mueller wrote:

 Hi Michael,
 
 I don't think there are any artificial limits for how much memory your
 application can use. As long as there is space left on the device you
 should be able to keep using it for storing your downloaded images.
 
 Regards,
 Thomas
 
 
 On 12 March 2010 08:08, Michael Davey frak@gmail.com wrote:
 Hi,
 
 I am now being approached to develop an iPhone application for one of my 
 clients which will involve storing a cache of previously downloaded images.  
 My question is whether or not there are constraints as to how my storage 
 space I have at my disposal, and whether any of you have a link to further 
 reading on this subject?
 
 regards,
 
 M___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/thomasmueller76%40googlemail.com
 
 This email sent to thomasmuelle...@googlemail.com
 

___

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

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

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

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


Re: Need help with scrolling marquee

2010-03-11 Thread Graham Cox

On 12/03/2010, at 5:23 AM, Michael A. Crawford wrote:

 - (void)timerFireMethod:(NSTimer*)theTimer
 {
 #if 0
// Here I was using a periodic timer to animate the scroll.  I noticed that
// the animation wasn't smooth and then remembered that CA is supposed to 
 do
// the animating for me.  So, I switched to trying the code below but that
// doesn't work either.  I'm really just grasping at straws here.
static CGPoint origin = {0.0f, 0.0f};
origin.x += 5.0f;
[scrollLayer scrollToPoint:origin];
 #else


Hi Michael,

This is a classic naive mistake. You're incrementing the position by a fixed 
amount each time the timer fires. Problem is, you can't guarantee that the 
timer will fire exactly at the time it should, so your scrolling speed is at 
the mercy of how busy things are, so will speed up and slow down.

Recall that speed is distance/time, so if you want a constant speed, you have 
to work out how much distance the thing should have moved in the actual time 
interval you got.

Roughly (typed into mail):

- (void)timerFireMethod:(NSTimer*) theTimer
{
NSTimeInterval elapsedTime = [NSDate timeIntervalSinceReferenceDate] - 
m_startTime; // m_startTime ivar set when the animation began
CGFloat distance = m_speed * elapsedTime;  // m_speed is the scrolling 
speed in points per second

[thing setPosition:distance];
}

With this approach, the exact timing intervals don't matter - the position will 
be correct. If things get busy what will happen is that the jumps between 
positions will get a bit larger.

That said, Core Animation might do the job better, but I just wanted to point 
out what the problem was with your original approach.

--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: Need help with scrolling marquee

2010-03-11 Thread Eric E. Dolecki
Isn't there a truncation property that handles this for a UILabel?

On Thu, Mar 11, 2010 at 4:53 PM, Graham Cox graham@bigpond.com wrote:


 On 12/03/2010, at 5:23 AM, Michael A. Crawford wrote:

  - (void)timerFireMethod:(NSTimer*)theTimer
  {
  #if 0
 // Here I was using a periodic timer to animate the scroll.  I noticed
 that
 // the animation wasn't smooth and then remembered that CA is supposed
 to do
 // the animating for me.  So, I switched to trying the code below but
 that
 // doesn't work either.  I'm really just grasping at straws here.
 static CGPoint origin = {0.0f, 0.0f};
 origin.x += 5.0f;
 [scrollLayer scrollToPoint:origin];
  #else


 Hi Michael,

 This is a classic naive mistake. You're incrementing the position by a
 fixed amount each time the timer fires. Problem is, you can't guarantee that
 the timer will fire exactly at the time it should, so your scrolling speed
 is at the mercy of how busy things are, so will speed up and slow down.

 Recall that speed is distance/time, so if you want a constant speed, you
 have to work out how much distance the thing should have moved in the actual
 time interval you got.

 Roughly (typed into mail):

 - (void)timerFireMethod:(NSTimer*) theTimer
 {
NSTimeInterval elapsedTime = [NSDate timeIntervalSinceReferenceDate] -
 m_startTime; // m_startTime ivar set when the animation began
CGFloat distance = m_speed * elapsedTime;  // m_speed is the scrolling
 speed in points per second

[thing setPosition:distance];
 }

 With this approach, the exact timing intervals don't matter - the position
 will be correct. If things get busy what will happen is that the jumps
 between positions will get a bit larger.

 That said, Core Animation might do the job better, but I just wanted to
 point out what the problem was with your original approach.

 --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/edolecki%40gmail.com

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




-- 
http://ericd.net
Interactive design and development
___

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

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

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

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


Re: Need help with scrolling marquee

2010-03-11 Thread Michael A. Crawford
Thanks, Graham, I realized the timer would have jitter.  When I realized what 
was going on and began to think about how to fix it, that is when I had one of 
those head-slap moments where I asked, Why am I not using CoreAnimation for 
this?

-Michael

On Mar 11, 2010, at 4:53 PM, Graham Cox wrote:

 
 On 12/03/2010, at 5:23 AM, Michael A. Crawford wrote:
 
 - (void)timerFireMethod:(NSTimer*)theTimer
 {
 #if 0
   // Here I was using a periodic timer to animate the scroll.  I noticed that
   // the animation wasn't smooth and then remembered that CA is supposed to 
 do
   // the animating for me.  So, I switched to trying the code below but that
   // doesn't work either.  I'm really just grasping at straws here.
   static CGPoint origin = {0.0f, 0.0f};
   origin.x += 5.0f;
   [scrollLayer scrollToPoint:origin];
 #else
 
 
 Hi Michael,
 
 This is a classic naive mistake. You're incrementing the position by a 
 fixed amount each time the timer fires. Problem is, you can't guarantee that 
 the timer will fire exactly at the time it should, so your scrolling speed is 
 at the mercy of how busy things are, so will speed up and slow down.
 
 Recall that speed is distance/time, so if you want a constant speed, you have 
 to work out how much distance the thing should have moved in the actual time 
 interval you got.
 
 Roughly (typed into mail):
 
 - (void)  timerFireMethod:(NSTimer*) theTimer
 {
NSTimeInterval elapsedTime = [NSDate timeIntervalSinceReferenceDate] - 
 m_startTime; // m_startTime ivar set when the animation began
CGFloat distance = m_speed * elapsedTime;  // m_speed is the scrolling 
 speed in points per second
 
[thing setPosition:distance];
 }
 
 With this approach, the exact timing intervals don't matter - the position 
 will be correct. If things get busy what will happen is that the jumps 
 between positions will get a bit larger.
 
 That said, Core Animation might do the job better, but I just wanted to point 
 out what the problem was with your original approach.
 
 --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: Need help with scrolling marquee

2010-03-11 Thread Michael A. Crawford
I played with the truncation property but to make that work you have to 
continually modify the length of the string.  I want to write the string to the 
buffer once and then have CA scroll it for me at a constant speed I can set.  
This is where I'm looking for assistance.

-Michael

On Mar 11, 2010, at 4:58 PM, Eric E. Dolecki wrote:

 Isn't there a truncation property that handles this for a UILabel?
 
 On Thu, Mar 11, 2010 at 4:53 PM, Graham Cox graham@bigpond.com wrote:
 
 On 12/03/2010, at 5:23 AM, Michael A. Crawford wrote:
 
  - (void)timerFireMethod:(NSTimer*)theTimer
  {
  #if 0
 // Here I was using a periodic timer to animate the scroll.  I noticed 
  that
 // the animation wasn't smooth and then remembered that CA is supposed 
  to do
 // the animating for me.  So, I switched to trying the code below but 
  that
 // doesn't work either.  I'm really just grasping at straws here.
 static CGPoint origin = {0.0f, 0.0f};
 origin.x += 5.0f;
 [scrollLayer scrollToPoint:origin];
  #else
 
 
 Hi Michael,
 
 This is a classic naive mistake. You're incrementing the position by a 
 fixed amount each time the timer fires. Problem is, you can't guarantee that 
 the timer will fire exactly at the time it should, so your scrolling speed is 
 at the mercy of how busy things are, so will speed up and slow down.
 
 Recall that speed is distance/time, so if you want a constant speed, you have 
 to work out how much distance the thing should have moved in the actual time 
 interval you got.
 
 Roughly (typed into mail):
 
 - (void)timerFireMethod:(NSTimer*) theTimer
 {
NSTimeInterval elapsedTime = [NSDate timeIntervalSinceReferenceDate] - 
 m_startTime; // m_startTime ivar set when the animation began
CGFloat distance = m_speed * elapsedTime;  // m_speed is the scrolling 
 speed in points per second
 
[thing setPosition:distance];
 }
 
 With this approach, the exact timing intervals don't matter - the position 
 will be correct. If things get busy what will happen is that the jumps 
 between positions will get a bit larger.
 
 That said, Core Animation might do the job better, but I just wanted to point 
 out what the problem was with your original approach.
 
 --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/edolecki%40gmail.com
 
 This email sent to edole...@gmail.com
 
 
 
 -- 
 http://ericd.net
 Interactive design and development

___

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

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

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

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


Answer: Bison with Objective-C Semantic Actions? Works

2010-03-11 Thread Thomas Wetmore
Just a quick thank-you to those who responded to my question about using bison 
to generate a language intepreter in an Cocoa Foundation/Xcode/Objective-C 
environment. Xcode does everything needed to make it seamless.

I named the yacc file Interpreter.ym and made the semantic value type for all 
terminals and non-terminals on the parsing stack to be the general Objective-C 
id type and have had no problems. My semantic actions are all written using 
Objective-C messaging with the $$, $1, ..., $n stack variables. No 
perspiration; no worries.

Thanks again for the great help available from this group.

(Cross posted to the Xcode group since Xcode makes working with yacc/bison 
almost trivial.)

Tom Wetmore, Chief Bottle Washer, DeadEnds Software

___

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

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

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

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


Switching methods in private classes in Apple frameworks

2010-03-11 Thread Gideon King
(following on from the thread How to debug this error on closing a document?, 
but it's really moved on to a new topic at this point)

I was not aware that poseAsClass is not available in 64 bit applications. I 
looked at the Apple example of exchanging a method in NSWindow, and it looked 
easy enough, so I tried the method exchanging by using class-dump to generate 
the header for NSConcreteNotification, and implemented the switch, but it gives 
a linker error:

_OBJC_CLASS_$_NSConcreteNotification, referenced from:
l_OBJC_$_CATEGORY_NSConcreteNotification_$_MethodReplacement in 
MyConcreteNotification.o
__objc_classrefs__d...@0 in MyConcreteNotification.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

So it must be in the foundation binary, but the linker doesn't pick it up. Is 
there a way around this?


Gideon




On 12/03/2010, at 2:00 AM, Jerry Krinock wrote:

 
 On 2010 Mar 11, at 02:27, Gideon King wrote:
 
 or whether I would have to subclass NSConcreteNotification and override 
 dealloc and then use pose as, so I could  print out the notification name 
 etc, to get the info
 
 That would work, but Method Replacement [1] was added in Objective-C 2.0 as a 
 replacement for pose as class.  However, to do Method Replacement, you need 
 to declare and implement a category on, in this case NSConcreteNotification, 
 but that won't compile because NSConcreteNotification is Apple-private.  Does 
 anyone know how to do Method Replacement for debugging in an Apple-private 
 class?
 
 [1] 
 http://developer.apple.com/mac/library/samplecode/MethodReplacement/index.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: Switching methods in private classes in Apple frameworks

2010-03-11 Thread Greg Parker
On Mar 11, 2010, at 4:24 PM, Gideon King wrote:
 (following on from the thread How to debug this error on closing a 
 document?, but it's really moved on to a new topic at this point)
 
 I was not aware that poseAsClass is not available in 64 bit applications. I 
 looked at the Apple example of exchanging a method in NSWindow, and it looked 
 easy enough, so I tried the method exchanging by using class-dump to generate 
 the header for NSConcreteNotification, and implemented the switch, but it 
 gives a linker error:
 
 _OBJC_CLASS_$_NSConcreteNotification, referenced from:
 l_OBJC_$_CATEGORY_NSConcreteNotification_$_MethodReplacement in 
 MyConcreteNotification.o
 __objc_classrefs__d...@0 in MyConcreteNotification.o
 ld: symbol(s) not found
 collect2: ld returned 1 exit status
 
 So it must be in the foundation binary, but the linker doesn't pick it up. Is 
 there a way around this?

On iPhone and 64-bit Mac, the linker enforces internal classes more strictly. 
NSConcreteNotification is private, so you can't link to it or subclass it. You 
can still get the class via runtime introspection like NSClassFromString(), 
which for debugging purposes ought to be good enough.


-- 
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: Help visualizing something in IB

2010-03-11 Thread Quincey Morris
On Mar 11, 2010, at 10:58, Brian Postow wrote:

 I should be able to just use the clipRect of the superview, right? 

Well, you have to observe something that produces notifications -- which means 
the bounds or frame of a view. You're likely not interested in the actual 
bounds or frame you're being notified about. You just want to be told when 
something that matters changes. Once you've received a notification, I think 
you'll simply want to examine the visibleRect of topView. Basically, if I 
understand correctly, you'll want to position the button view at the top of the 
visibleRect, and the image view in the rest of the visibleRect, and also handle 
the edge cases where there isn't enough room to show those subviews.


___

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

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

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

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


Core Data: inverse relationship not updated until next Run Loop

2010-03-11 Thread Eric Lin
In using Core Data, I was under the impression that if I do this:

[department addEmployeesObject:employee]  // department now has 1 employee
[moc deleteObject:employee]

Then department will end up with no employees, assuming that the inverse
relationship is set correctly.

But it turns out within the same run loop, if I inspect
[department.employees count], then the value is 1. But in the next run loop,
the value becomes 0, which is what it should be.

Is my observation accurate or is something wrong?

Does this mean that although I generally don't need to call [department
removeEmployeesObject:employee] after deleting an employee, if I want
department to be in a consistent state within the same event loop, I will
need to make that call?

Thanks,
Eric
___

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

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

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

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


Re: Switching methods in private classes in Apple frameworks

2010-03-11 Thread Gideon King
This is really cool...so I can replace a method without being a subclass or 
category. 

So I implemented an NSObject subclass with the new method, and did the method 
exchange, and my new method was called instead of the old one, but I had a 
problem - the call to the switched out method (dealloc from the 
NSConcreteNotification) didn't work. I assumed that was because the old 
implementation of dealloc was now moved to my class, so I changed the method 
switching so that it ensures that the old dealloc is replaced with the 
implementation of mydealloc, and that I have added a method to the 
NSConcreteNotification which is called mydealloc, and does the things that the 
old dealloc did.

This seems to work, so I thought I'd post it here in case anyone else needs to 
replace a method in a private class, and be able to call the original 
implementation.

#import objc/runtime.h
#import Cocoa/Cocoa.h

@interface MyConcreteNotification : NSObject {
}

- (void)mydealloc;

@end

@implementation MyConcreteNotification

+ (void)load {
Method originalMethod = 
class_getInstanceMethod(NSClassFromString(@NSConcreteNotification), 
@selector(dealloc));
Method replacedMethod = class_getInstanceMethod(self, 
@selector(mydealloc));
IMP imp1 = method_getImplementation(originalMethod);
IMP imp2 = method_getImplementation(replacedMethod);
// Set the implementation of dealloc to mydealloc
method_setImplementation(originalMethod, imp2);
// Add a mydealloc method to the NSConcreteNotification with the 
implementation as per the old dealloc method
class_addMethod(NSClassFromString(@NSConcreteNotification), 
@selector(mydealloc), imp1, NULL);
}

- (void)mydealloc {
NSLog(@My concrete notification is being deallocated);
NSLog(@Name: %...@\nobject: %...@\nuser Info: %...@\n, [self name], 
[self object], [self userInfo]);

// Call the original method, whose implementation was exchanged with 
our own.
// Note:  this ISN'T a recursive call, because this method should have 
been called through dealloc.
NSParameterAssert(_cmd == @selector(dealloc));
[self mydealloc];
}

@end


Regards.

Gideon
 
 On iPhone and 64-bit Mac, the linker enforces internal classes more strictly. 
 NSConcreteNotification is private, so you can't link to it or subclass it. 
 You can still get the class via runtime introspection like 
 NSClassFromString(), which for debugging purposes ought to be good enough.
 -- 
 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: Core Animation vs. Basic Cocoa Graphics

2010-03-11 Thread Mazen M. Abdel-Rahman
Thanks everyone for your help on this.

I started using an image cache - but that did not improve the performance as 
much as I thought it should.  I then removed the section of my code that 
creates NSTrackingsAreas - and the improvement was immediately noticeable.

For the calendar grid I was creating an NSTrackingArea for each cell - in my 
case (the calendar is for 7 days with 15 minutes per cell) there was 672 
NSTrackingAreas.

I will have to look at alternative solutions to all these NSTrackingAreas to 
improve the performance.

Thanks,
Mazen


On Mar 11, 2010, at 2:44 AM, jonat...@mugginsoft.com wrote:

 
 
 On 10 Mar 2010, at 17:13, Mazen M. Abdel-Rahman wrote:
 
 Hi All,
 
 I was able to write a simple calendar view that uses basic cocoa graphics to 
 draw directly on the view (NSBezierPath, etc.).  I actually use several 
 different paths for drawing the calendar (it's a weekly calendar) to allow 
 different horizontal line widths (hour, half hour, etc.).  The calendar view 
 is inside a scroll view - and is actually about 3 times longer than the view 
 window.   The main problem is that the scrolling is not smooth - and my 
 assumption is that it's because the NSBezier stroke functions  have to be 
 constantly called to render the calendar.
 
 For something as relatively simple as this would moving to core animation - 
 i.e. trying to render the calendar on a layer instead (I am still trying to 
 learn core animation) add performance benefits?  And would it allow for 
 smoother scrolling?
 
 As no one else has offered an opinion:
 
 Moving to CA might offer benefits but you can improve the performance of your 
 existing code by using an image cache.
 I do this for an NSView with animated NSBezierPath content and it works fine.
 
 So I would draw my image when the view resizes and there after service - 
 (void)drawRect:(NSRect)rect from the image cache.
 You only regen the cache when required, say on resize on content change.
 
 The rough code outline below might help you get something up an running:
 
 NSView subclass:
 
 ivars:
 
 NSRect _cacheRect;
 NSImage *_imageCache;
 BOOL _useImageCache;
 
 - (void)drawRect:(NSRect)rect 
 { 
 
   if (_useImageCache) {
   
   // validate our rect
   rect = [self validateDrawRect:rect];
 
   // if cache exists use it to update rect.
   // otherwise draw into our rect
   if (_imageCache) {
   [self drawRectFromCache:rect];
   return;
   } 
 
   // draw to image cache
   _cacheRect  = [self bounds];
   _imageCache = [[NSImage alloc] initWithSize:_cacheRect.size];
   [_imageCache lockFocus];
   
   }
   
   // draw entire bounds rect
   rect = [self bounds];
   
   // draw it
   NSBezierPath *bgPath = [NSBezierPath bezierPathWithRect:rect];
   NSColor *endColor = [NSColor colorWithCalibratedRed:0.988f green:0.988f 
 blue:0.988f alpha:1.0f];
   NSColor *startColor = [NSColor colorWithCalibratedRed:0.875f 
 green:0.875f blue:0.875f alpha:1.0f];
   
   NSGradient *gradient = [[NSGradient alloc] 
 initWithStartingColor:startColor endingColor:endColor];
   [gradient drawInBezierPath:bgPath angle:90.0f];
   
   
   if (_useImageCache) {
   [_imageCache unlockFocus];
   
   // refresh view from cache
   [self drawRectFromCache:rect];
   }
   
 }
 
 /*
 
 draw rect from cache
 
 */
 - (void)drawRectFromCache:(NSRect)rect
 {
   [_imageCache drawInRect:rect fromRect:rect 
 operation:NSCompositeSourceOver fraction:1.0f];
 }
 /*
 
 validate the draw rect
 
 */
 - (NSRect)validateDrawRect:(NSRect)rect
 {
   NSRect boundsRect = [self bounds];
   
   // if bounds rect and cache rect are not equal then
   // the cache will have to be updated
   if (!NSEqualRects(boundsRect, _cacheRect)) {
   [self clearDisplayCache];
   }
   
   // if no display cache available then need to draw bounds into cache
   if (!_imageCache) {
   rect = boundsRect;
   }
   
   return rect;
 }
 
 Regards
 
 Jonathan Mitchell
 
 Developer
 http://www.mugginsoft.com
 

___

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

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

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

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


Re: View does not get refreshed after Window deminimized...

2010-03-11 Thread cocoa learner
Hummm... looks like my approach has flaw.

Thanks a ton,
Cocoa.learner

On Thu, Mar 11, 2010 at 11:52 PM, Quincey Morris 
quinceymor...@earthlink.net wrote:

 On Mar 11, 2010, at 06:50, cocoa learner wrote:

  And on this custom view I have a progress bar, that progressbar gets it's
  progress value from a NSThread. And I am using following function render
 the
  progressbar, from NSThread -
 
 
  [progBar performSelectorOnMainThread: (display) withObject: nil
  waitUntilDone: YES];

 There seem to be two things wrong here.

 First, you must *not* set the value of the progress bar from a non-main
 thread. Setting the value causes a UI update, and that won't work properly
 unless it's done on the main thread. Instead, you must devise a method for
 the background thread to pass the desired value to the main thread, and have
 the main thread set the progress bar value.

 Second, it's rarely correct to invoke [NSView display] yourself. Typically,
 you would use [NSView setNeedsDisplay].

 In any case, it's not clear why you think you need to cause the progress
 bar to redisplay. If you set the value properly from the main thread, it
 will redisplay itself as necessary. If you're having a problem with the
 animation not running, you just need to make sure you set (or re-set) the
 value often enough.


 ___

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

 Please do not post admin requests or moderator comments to the list.
 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.learner%40gmail.com

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


Use of KVC Array operators

2010-03-11 Thread Eli Bach
The operators mentioned on this page, particularly @unionOfSets.

http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html

I have the following Core Data object's setup

ClassA  ClassB  ClassC
relationA  --  relationB -- relation C

where each of the relations is a many to one [one class A, many class B, and 
one class B, many class C].
Not all ClassB's will have ClassC objects attached to them

I have an instance of classA, and I want an NSArrayController with all the 
ClassC objects for all the ClassB objects that are related to that specific 
instance of ClassA, preferably in a way that uses KVO instead of 
programmatically updating with fetches/predicates/etc.

What would be the right way to bind the NSArrayController, assuming the nib 
owner has an instance of classA:

ie:

bind content set to

File Owner.instanceOfA.?

Thanks,

Eli

___

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

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

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

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


Re: Switching methods in private classes in Apple frameworks

2010-03-11 Thread Jerry Krinock

On 2010 Mar 11, at 18:00, Gideon King wrote:

 This is really cool...so I can replace a method without being a subclass or 
 category.

I just need to chime in here, in case anyone missed it, to emphasize how 
*ALL-CAPS COOL* this is indeed.

In the ReadMe of Apple's MethodReplacement.zip sample code, it states The 
trick is to define a category on the class whose method you want to replace.  
We have just learned that this sentence is incorrect.  You do *not* need to 
define a category on the class whose method you want to replace.

As Gideon showed in his code, the first argument of class_getInstanceMethod() 
need *not* be self, and therefore you can replace any method in *any* class, 
even a private one that's unknown to the SDK, with any other method in *any 
class*, even a different class.

This makes Method Replacement much more powerful in debugging, and even 
patching bugs in Cocoa.

I just sent Apple a wasn't helpful gram on that ReadMe.

Thanks, Gideon.  I hope you've found out who's sending that notification 
releasing your moc :)

___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov


On 11.03.2010, at 23:25, Corbin Dunn wrote:


http://www.corbinstreehouse.com/blog/2008/08/your-most-important-breakpoint-in-cocoa/


I've done what was told there. No difference. I just get  
EXC_BAD_ACCESS in XCode status line and debugger's call stack list  
shows:


objc_msgSend
- [NSTableView _dataSourceValueForColumn:row: ]


and a long chain is below, but there are no my project lines there.  
All lines are from Cocoa itself. It looks like the window requires for  
update after dataSource is already released.


This is how I call the modal window:

- (void) doModalWnd{
MyWnd *wnd = [[MyWnd alloc] init];
[[NSApplication sharedApplication] runModalForWindow:[wnd window]];
[wnd release];
}

- (IBAction) myBtnClick:(NSButton *)sender {
[self performSelector:@selector(doModalWnd)
   withObject:nil
   afterDelay:0];
}

There is such code within MyWnd.m:

- (void)windowWillClose:(NSNotification *)notification {
[[NSApplication sharedApplication] stopModalWithCode:NSCancelButton];
}

Is there anything criminal here?

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


Making a beta version expire

2010-03-11 Thread Ulai Beekam

For a beta version of an app, let's say I want to make sure that users cannot 
use the beta for far too long, far longer than the app goes out of beta. (Note 
that this case would in reality rarely occur. Most users would end up getting 
notified of a new update far sooner. This is just a safety measure.)

So this is how I thought of doing it. Let's say I want to make the app expire 
on January 1, 2011 (since I'm sure that I'll have a new beta release or go out 
of beta before then). What do you think about putting the following code in 
AppController's awakeFromNib?

---
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comp setDay:1]; [comp setMonth:1]; [comp setYear:2011];
NSCalendar *gregorian = [[NSCalendar alloc] 
initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *expiryDate = [gregorian dateFromComponents:comps];

NSDate *now = [NSDate date];

if ([now compare:expiryDate] == NSOrderedDescending)
{
  NSRunAlertPanel(@App Expired,@Visit website,@OK,nil,nil);
  [NSApp terminate:self];
  return;
}
---

Do you think this would work? I mean, it seems that it should, but one can 
never be sure. Plus, this might be a lousy method, compared to what some of you 
geniuses in here might have conjured up over the ages.

Thanks, U.



  
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969___

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

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

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

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


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Eli Bach

On Mar 11, 2010, at 8:55 PM, Alexander Bokovikov wrote:

 Is there anything criminal here?

Is the datasource for the NSTableView still a valid, non-released object when 
the window is closed?

Eli

___

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

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

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

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


Re: Making a beta version expire

2010-03-11 Thread Jim Correia
On Mar 11, 2010, at 11:03 PM, Ulai Beekam wrote:

 Do you think this would work? I mean, it seems that it should, but one can 
 never be sure

Why can’t you be sure? 

After reading your algorithm and convincing yourself that the code is correct, 
step through it in the debugger with expirations dates both in the past and the 
future.

- Jim___

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

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

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

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


Re: Switching methods in private classes in Apple frameworks

2010-03-11 Thread Gideon King
Thanks Jerry, I should mention that I did get this caveat note from Greg Parker 
(Apple's runtime wrangler):

..you must be cautious about what your replacement method does. In particular, 
you must not use any of the class's ivars and you must not call [super 
something]. As long as you follow those, you can swap in a method from any 
class, or even a C function with a matching argument list.

So as long as you are careful about what you do, yes it is entirely possible to 
replace methods at will. I hope nobody misuses it, but it certainly was 
essential in my debugging - yes, I found it! Yay! 

Essentially what appeared to be happening was that I had a notification queued 
which had an object in it which held a reference to a managed object, but by 
the time the notification was destroyed, the managed object had turned to a 
fault (but was not released because the notification was causing it to be 
retained), and the managed object context had been released as part of the 
document deallocation, so when my object tried to access the managed object, it 
tried to fire the fault on a freed managed object context...or something like 
that. Even if that's not exactly right in every detail, I now have the 
conceptual understanding of the problem and believe I will be able to fix it. 
What a relief!

Regards

Gideon

On 12/03/2010, at 1:54 PM, Jerry Krinock wrote:

 
 On 2010 Mar 11, at 18:00, Gideon King wrote:
 
 This is really cool...so I can replace a method without being a subclass or 
 category.
 
 I just need to chime in here, in case anyone missed it, to emphasize how 
 *ALL-CAPS COOL* this is indeed.
 
 In the ReadMe of Apple's MethodReplacement.zip sample code, it states The 
 trick is to define a category on the class whose method you want to replace. 
  We have just learned that this sentence is incorrect.  You do *not* need to 
 define a category on the class whose method you want to replace.
 
 As Gideon showed in his code, the first argument of class_getInstanceMethod() 
 need *not* be self, and therefore you can replace any method in *any* class, 
 even a private one that's unknown to the SDK, with any other method in *any 
 class*, even a different class.
 
 This makes Method Replacement much more powerful in debugging, and even 
 patching bugs in Cocoa.
 
 I just sent Apple a wasn't helpful gram on that ReadMe.
 
 Thanks, Gideon.  I hope you've found out who's sending that notification 
 releasing your moc :)
 

___

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

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

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

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


Re: Cocoa-dev Digest, Vol 7, Issue 294

2010-03-11 Thread Shripada Hebbar
Hi Michael,

You can use a text filed inside a scrollview. And use CAKeyFrameAnimation on
the layer  of the text field on its 'position' property.
The idea is something like this:
You need to compute the appropriate duration for the animation from the size
of the text you have. The duration needs to be proportional to the length of
string. And appropriately compute the target position (again this is decided
by the length of the string).

HTH
Regards
Shripada

On 12/03/10 7:45 AM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:

 From: Michael A. Crawford michaelacrawf...@me.com
 Subject: Re: Need help with scrolling marquee
 To: Cocoa-dev@lists.apple.com
 Message-ID: 852bbcde-6e39-4e73-adcb-8c63f4d4d...@me.com
 Content-Type: text/plain; charset=us-ascii
 
 I played with the truncation property but to make that work you have to
 continually modify the length of the string.  I want to write the string to
 the buffer once and then have CA scroll it for me at a constant speed I can
 set.  This is where I'm looking for assistance.
 
 -Michael
 
 On Mar 11, 2010, at 4:58 PM, Eric E. Dolecki wrote:
 
 Isn't there a truncation property that handles this for a UILabel?
 
 On Thu, Mar 11, 2010 at 4:53 PM, Graham Cox graham@bigpond.com wrote:
 
 On 12/03/2010, at 5:23 AM, Michael A. Crawford wrote:
 
 - (void)timerFireMethod:(NSTimer*)theTimer
 {
 #if 0
// Here I was using a periodic timer to animate the scroll.  I noticed
 that
// the animation wasn't smooth and then remembered that CA is supposed to
 do
// the animating for me.  So, I switched to trying the code below but
 that
// doesn't work either.  I'm really just grasping at straws here.
static CGPoint origin = {0.0f, 0.0f};
origin.x += 5.0f;
[scrollLayer scrollToPoint:origin];
 #else
 
 
 Hi Michael,
 
 This is a classic naive mistake. You're incrementing the position by a
 fixed amount each time the timer fires. Problem is, you can't guarantee that
 the timer will fire exactly at the time it should, so your scrolling speed is
 at the mercy of how busy things are, so will speed up and slow down.
 
 Recall that speed is distance/time, so if you want a constant speed, you have
 to work out how much distance the thing should have moved in the actual time
 interval you got.
 
 Roughly (typed into mail):
 
 - (void)timerFireMethod:(NSTimer*) theTimer
 {
NSTimeInterval elapsedTime = [NSDate timeIntervalSinceReferenceDate] -
 m_startTime; // m_startTime ivar set when the animation began
CGFloat distance = m_speed * elapsedTime;  // m_speed is the scrolling
 speed in points per second
 
[thing setPosition:distance];
 }
 
 With this approach, the exact timing intervals don't matter - the position
 will be correct. If things get busy what will happen is that the jumps
 between positions will get a bit larger.
 
 That said, Core Animation might do the job better, but I just wanted to point
 out what the problem was with your original approach.
 
 --Graham
 
 


---
Robosoft Technologies - Come home to Technology

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

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

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

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

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


Re: Core Data: inverse relationship not updated until next Run Loop

2010-03-11 Thread Jim Correia
On Mar 11, 2010, at 8:11 PM, Eric Lin wrote:

 In using Core Data, I was under the impression that if I do this:
 
 [department addEmployeesObject:employee]  // department now has 1 employee
 [moc deleteObject:employee]
 
 Then department will end up with no employees, assuming that the inverse
 relationship is set correctly.
 
 But it turns out within the same run loop, if I inspect
 [department.employees count], then the value is 1. But in the next run loop,
 the value becomes 0, which is what it should be.
 
 Is my observation accurate or is something wrong?

Deletes are propagated at the end of he current event, or at save time, 
depending how the MOC is configured.

Jim

___

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

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

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

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


Re: Core Animation vs. Basic Cocoa Graphics

2010-03-11 Thread Alvaro Costa Neto
Hi Mazen, how are you?

Maybe I can offer a tip on how to improve your performance: there is a 
technique called  BSP-Tree which divides the space in two equal parts 
recursively, creating a tree of subdivisions. This technique improves the 
search of which area of the space (in your case, the view) that a point is 
located by constructing and traversing the binary tree. It's really neat!

As for the actual implementation, I am very new to the Cocoa framework and the 
Objective-C language and I wouldn't be of much help with it. Maybe someone else 
who is more experienced on the Mac ways of programming may be of more use to 
you than me.

Hope that helps.

Best regards,
Alvaro Costa Neto

On Mar 11, 2010, at 11:13 PM, Mazen M. Abdel-Rahman wrote:

 Thanks everyone for your help on this.
 
 I started using an image cache - but that did not improve the performance as 
 much as I thought it should.  I then removed the section of my code that 
 creates NSTrackingsAreas - and the improvement was immediately noticeable.
 
 For the calendar grid I was creating an NSTrackingArea for each cell - in my 
 case (the calendar is for 7 days with 15 minutes per cell) there was 672 
 NSTrackingAreas.
 
 I will have to look at alternative solutions to all these NSTrackingAreas to 
 improve the performance.
 
 Thanks,
 Mazen
 
 
 On Mar 11, 2010, at 2:44 AM, jonat...@mugginsoft.com wrote:
 
 
 
 On 10 Mar 2010, at 17:13, Mazen M. Abdel-Rahman wrote:
 
 Hi All,
 
 I was able to write a simple calendar view that uses basic cocoa graphics 
 to draw directly on the view (NSBezierPath, etc.).  I actually use several 
 different paths for drawing the calendar (it's a weekly calendar) to allow 
 different horizontal line widths (hour, half hour, etc.).  The calendar 
 view is inside a scroll view - and is actually about 3 times longer than 
 the view window.   The main problem is that the scrolling is not smooth - 
 and my assumption is that it's because the NSBezier stroke functions  have 
 to be constantly called to render the calendar.
 
 For something as relatively simple as this would moving to core animation - 
 i.e. trying to render the calendar on a layer instead (I am still trying to 
 learn core animation) add performance benefits?  And would it allow for 
 smoother scrolling?
 
 As no one else has offered an opinion:
 
 Moving to CA might offer benefits but you can improve the performance of 
 your existing code by using an image cache.
 I do this for an NSView with animated NSBezierPath content and it works fine.
 
 So I would draw my image when the view resizes and there after service - 
 (void)drawRect:(NSRect)rect from the image cache.
 You only regen the cache when required, say on resize on content change.
 
 The rough code outline below might help you get something up an running:
 
 NSView subclass:
 
 ivars:
 
 NSRect _cacheRect;
 NSImage *_imageCache;
 BOOL _useImageCache;
 
 - (void)drawRect:(NSRect)rect 
 {
 
  if (_useImageCache) {
  
  // validate our rect
  rect = [self validateDrawRect:rect];
 
  // if cache exists use it to update rect.
  // otherwise draw into our rect
  if (_imageCache) {
  [self drawRectFromCache:rect];
  return;
  } 
 
  // draw to image cache
  _cacheRect  = [self bounds];
  _imageCache = [[NSImage alloc] initWithSize:_cacheRect.size];
  [_imageCache lockFocus];
  
  }
  
  // draw entire bounds rect
  rect = [self bounds];
  
  // draw it
  NSBezierPath *bgPath = [NSBezierPath bezierPathWithRect:rect];
  NSColor *endColor = [NSColor colorWithCalibratedRed:0.988f green:0.988f 
 blue:0.988f alpha:1.0f];
  NSColor *startColor = [NSColor colorWithCalibratedRed:0.875f 
 green:0.875f blue:0.875f alpha:1.0f];
  
  NSGradient *gradient = [[NSGradient alloc] 
 initWithStartingColor:startColor endingColor:endColor];
  [gradient drawInBezierPath:bgPath angle:90.0f];
  
  
  if (_useImageCache) {
  [_imageCache unlockFocus];
  
  // refresh view from cache
  [self drawRectFromCache:rect];
  }
  
 }
 
 /*
 
 draw rect from cache
 
 */
 - (void)drawRectFromCache:(NSRect)rect
 {
  [_imageCache drawInRect:rect fromRect:rect 
 operation:NSCompositeSourceOver fraction:1.0f];
 }
 /*
 
 validate the draw rect
 
 */
 - (NSRect)validateDrawRect:(NSRect)rect
 {
  NSRect boundsRect = [self bounds];
  
  // if bounds rect and cache rect are not equal then
  // the cache will have to be updated
  if (!NSEqualRects(boundsRect, _cacheRect)) {
  [self clearDisplayCache];
  }
  
  // if no display cache available then need to draw bounds into cache
  if (!_imageCache) {
  rect = boundsRect;
  }
  
  return rect;
 }
 
 Regards
 

Cannot find symbol(s) in release version

2010-03-11 Thread Wade Guangwu Xia
Hi,

 

I met a issue that there are several link errors when build a project
which can be built successfully in debug version. The detail information
is below:

1.   There are two projects, the targets of both projects is
framework.

2.   Project A dependents project B's output.

3.   Project B builds successfully both Debug and Release version.

4.   Project A builds successfully in debug version.

5.   Project A builds failed in release version, there are several
link errors, the error list is below:.

Build QualityMgmt of project QualityMgmt with configuration Release

Ld ../../twk_results_mac/ViewLocal/MC_out/Release/libQualityMgmt.dylib
normal i386

cd /Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt

setenv MACOSX_DEPLOYMENT_TARGET 10.4

/Developer/usr/bin/g++-4.0 -arch i386 -dynamiclib -isysroot
/Developer/SDKs/MacOSX10.4u.sdk
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../twk_results_mac/ViewLocal/MC_out/Release
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../msn_shared/mac/wkgpframework_sdk/third-party/codemesh/junc++ion/maco
s/cpp/darwin-all-universal
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../mtl_sharedbuilds/mac/Release/bin
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../twk_results_mac/ViewLocal/MC_out/Release
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../mtl_sharedbuilds/mac/MediaIndexer/Release/bin
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../msn_shared/mac/wkgpframework_sdk/third-party/codemesh/junc++ion/maco
s/models/javacore/cpp
-L/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../mtl_sharedbuilds/mac/MediaIndexer/Release/bin
-F/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/..
/../twk_results_mac/ViewLocal/MC_out/Release -filelist
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/../.
./twk_results_mac/ViewLocal/MC_inter/QualityMgmt.build/Release/QualityMg
mt.build/Objects-normal/i386/QualityMgmt.LinkFileList -install_name
@executable_path/libQualityMgmt.dylib -mmacosx-version-min=10.4
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/twk_results_mac/ViewLo
cal/MC_out/Release/TaskScheduler.framework/TaskScheduler
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/twk_results_mac/ViewLo
cal/MC_out/Release/AvidCoreThreads.framework/AvidCoreThreads -framework
Carbon -framework CoreServices
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/twk_results_mac/ViewLo
cal/MC_out/Release/libStringFunctions.a
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/twk_results_mac/ViewLo
cal/MC_out/Release/libTimeFunctions.a -lJavaMISupport -lxmogrt-g++G.3
-single_module -compatibility_version 1 -current_version 1 -o
/Users/sow11_Mac1/dev.ws.FlyingCircus_dxsow11_Int/xplat/QualityMgmt/../.
./twk_results_mac/ViewLocal/MC_out/Release/libQualityMgmt.dylib

Undefined symbols:

  TaskScheduler::addTask(TaskSchedulerTask*, bool), referenced from:

 
QualityMatch::CQFXUpdateAccumulator::CQFXUpdateAccumulatorImpl::addChann
el(QualityMatch::CQFXChannelKey const)in CQFXUpdateAccumulator.o

  TaskSchedulerTask::TaskSchedulerTask(char const*, int,
boost::functionvoid ()(), std::allocatorvoid , bool, int, bool),
referenced from:

 
QualityMatch::CQFXUpdateAccumulator::CQFXUpdateAccumulatorImpl::addChann
el(QualityMatch::CQFXChannelKey const)in CQFXUpdateAccumulator.o

  TaskScheduler::instance(), referenced from:

 
QualityMatch::CQFXUpdateAccumulator::CQFXUpdateAccumulatorImpl::addChann
el(QualityMatch::CQFXChannelKey const)in CQFXUpdateAccumulator.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

 

 

 

Thanks,

Wade

___

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

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

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

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


Re: Load data from csv file and plot line graph

2010-03-11 Thread Ni Lei
For the code example,

 CPTestAppScatterPlotController.m
 that I downloaded from core-plot Google website, a line graph can be
 plotted based on randomly
 generated initial data x, y.

   // Add some initial data
NSMutableArray *contentArray = [NSMutableArray
 arrayWithCapacity:100];
NSUInteger i;
for ( i = 0; i  60; i++ ) {
id x = [NSNumber numberWithFloat:1+i*0.05];
id y = [NSNumber numberWithFloat:1.2*rand()/
 (float)RAND_MAX + 1.2];
[contentArray addObject:[NSMutableDictionary
 dictionaryWithObjectsAndKeys:x, @x, y, @y, nil]];
}
self.dataForPlot = contentArray;

 Then i modified the code,
 NSString *filePath = [[NSBundle mainBundle] 
 pathForResource:@ECG_Data
 ofType:@csv];
 NSString *myText = [NSString stringWithContentsOfFile:filePath
 encoding:NSUTF8StringEncoding error:nil ];
 NSScanner *scanner = [NSScanner scannerWithString:myText];
 [scanner setCharactersToBeSkipped:[NSCharacterSet
 characterSetWithCharactersInString:@\n, ]];
 NSMutableArray *newPoints = [NSMutableArray array];
 float time, data;
 while ( [scanner scanFloat:time]  [scanner scanFloat:data]
 ) {
 [newPoints addObject:
  [NSMutableDictionary dictionaryWithObjectsAndKeys:
   [NSNumber numberWithFloat:time], @time,
   [NSNumber numberWithFloat:data], @data,
   nil]];
 }
 self.dataForPlot = newPoints;
 It seems that my code could not read the data from csv file.
 (there are two cols of the data in ECG_Data.csv, one for time and one for
 data)
 Can anyone give me some suggestion???
 Thanks

 regards,
 Ni Lei

___

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

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

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

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


Re: Better sorting using threads?

2010-03-11 Thread Andrew James
Does Cocoa have sorted containers so that an object can be inserted in sorted 
order?  If so it seems like this would be far less expensive.

--aj





From: Ken Ferry kenfe...@gmail.com
To: Ken Thomases k...@codeweavers.com
Cc: Cocoa-Dev List cocoa-dev@lists.apple.com
Sent: Wed, March 10, 2010 11:37:31 PM
Subject: Re: Better sorting using threads?

On Wed, Mar 10, 2010 at 10:34 PM, Ken Thomases k...@codeweavers.com wrote:

 On Mar 10, 2010, at 11:50 PM, Graham Cox wrote:

  I've got a situation where sorting an array using sort descriptors is
 slow. The number of items being sorted is not enormous - about 2,000 - but
 there could be several sort descriptors and the main string one is using a
 localized and natural numeric comparison. I cache the results and take a lot
 of care only to resort when needed, but that doesn't help on the first run
 through which often takes in the order of 10-20 seconds. The interface that
 displays the results therefore beachballs for this time.
 
  I'm considering using threads to help, where a thread is used to perform
 the sort itself, and until the sort has finished the UI can display a busy
 indicator (indeterminate circular progress indicator) next to the selected
 row in the table. This is in the master table of a master-detail interface
 where the detail displays the sorted items selected. While busy the detail
 view can be blank or show the previous arrangement.
 
  So my question is, is threading a good solution? While NSMutableArray
 isn't marked as thread-safe, the array in question can be arranged to not be
 used outside of the sorting thread, and only substituted for the returned
 sorted items when complete. Or can array sorting not be done on a thread at
 all?

 This is a sensible solution.  NSMutableArray is safe so long as only one
 thread is accessing it at a time.


Even more specifically, NSMutableArray is safe so long as either

(1) no thread is mutating the array (but an arbitrary number are accessing
it)
(2) only one thread is accessing the array (and possibly mutating it)

Same deal for NSDictionary, and, for that matter, NSImage.

Also, rest of email, seconded. :-)

-Ken

However, sorting 2000 items should not take 10-20 seconds!  Have you
 profiled to find out what's actually taking the time?


 If a property of the objects has to be massaged into another form before
 the comparison can take place, it can be a performance win to do that
 massaging once for each object before the sort and cache the result.
  Otherwise, it may end up being performed over and over, each time one
 object is compared to another.  (I wouldn't worry about the localized,
 numeric comparison of strings, though.  I don't think there's a good way to
 preflight those, and I wouldn't think that would be a significant factor in
 the slowness.  But, of course, don't trust my intuition -- measure.)

 Regards,
 Ken

 ___

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

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

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

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

___

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

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

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

This email sent to andrew_a_ja...@yahoo.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: Core Data: inverse relationship not updated until next Run Loop

2010-03-11 Thread Frank Illenberger
 In using Core Data, I was under the impression that if I do this:
 
 [department addEmployeesObject:employee]  // department now has 1 employee
 [moc deleteObject:employee]
 
 Then department will end up with no employees, assuming that the inverse
 relationship is set correctly.
 
 But it turns out within the same run loop, if I inspect
 [department.employees count], then the value is 1. But in the next run loop,
 the value becomes 0, which is what it should be.
 
 Is my observation accurate or is something wrong?
 
 Deletes are propagated at the end of he current event, or at save time, 
 depending how the MOC is configured.

But you can call [moc processPendingChanges] directly after the delete to 
propagate the changes immediately. 

Frank
___

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

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

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

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


Re: NSServices - Validation bug

2010-03-11 Thread Jim Correia
On Mar 8, 2010, at 5:02 AM, tr...@atheeva.com wrote:

 I have some queries regarding Services menu validation . I would like to 
 enable different services provided by my app based on whether a file or 
 folder is selected in the Finder. I have set NSFilenamesPboardType  as the 
 send type for the services.I have gone through the 

 
 - (id) validRequestorForSendType:(NSString*)sendType returnType:(NSString 
 *)returnType
 
 method but my issue is that the validation there seems to be done based on 
 the sendType and return type. In my case , the selected file and folder 
 pasteboard type is the same and I cannot determine whether the selected item 
 in the Finder is a file or folder during the validation process(This is 
 before the actual service gets invoked i.e when the services menu is being 
 shown to the user )?

 
 So my question is that is there any way I can get some info about the 
 selected item in the Finder and validate the different service menus offered 
 by my application based on some info regarding the item rather than the basic 
 validation of the send and return types ?

You can only validate by the type in your service validation method, not the 
contents of the pasteboard.

You can switch to using more specific UTIs for our service (if you only, for 
example, want to accept a file, folder, or package). You can also use 
NSRequiredContext in your service specification to restrict service 
availability based on pasteboard content.

- Jim___

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

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

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

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


Re: Switching methods in private classes in Apple frameworks

2010-03-11 Thread Bill Bumgarner

On Mar 11, 2010, at 8:58 PM, Gideon King wrote:

 So as long as you are careful about what you do, yes it is entirely possible 
 to replace methods at will. I hope nobody misuses it, but it certainly was 
 essential in my debugging - yes, I found it! Yay! 

Where careful about what you do includes only use this in debugging code or 
non-production instrumentation, sure

Do *not* ship such shenanigans in production code.   One software update later 
and suddenly the presumptions made about that internal method you are 
replacing/overriding/augmenting are no longer true and *boom*.

(been there, done that, the scars run deep -- seriously, don't ship it that 
way. :)

b.bum

___

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

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

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

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


Re: Better sorting using threads?

2010-03-11 Thread Bill Bumgarner

On Mar 11, 2010, at 11:15 AM, Andrew James wrote:

 Does Cocoa have sorted containers so that an object can be inserted in sorted 
 order?  If so it seems like this would be far less expensive.

Depends entirely on need.   Keeping a container sorted on insert can be quite 
expensive;  potentially considerably more expensive than doing a single batch 
sort at the end.

On-the-fly sorted containers are generally only applicable when updates to the 
container will be frequently interleaved with read operations. 

b.bum
___

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

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

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

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


Re: [MEET] CocoaHeads-NYC tonight - NSOperation

2010-03-11 Thread Symadept
Hi Andy,

Can you please record the discussion and presentation since the people like
me non US Residents can view them. I am really looking for such topic.

Thanks  regards
Mustafa Shaik


On Fri, Mar 12, 2010 at 5:11 AM, Andy Lee ag...@mac.com wrote:

 Sorry for the two hours' notice...

 Marc van Olmen will give the talk entitled Introduction to NSOperation
 that he was unable to give last month.  I have no doubt it'll be worth the
 wait.

 As usual:

 (1) Please feel free to bring questions, code, and works in progress. We
 have a projector and we like to see code and try to help.
 (2) We'll have food and beer afterwards.
 (3) If there's a topic you'd like presented, let us know.
 (4) If *you'd* like to give a talk, let me know.

 Thursday, March 11
 6:00 - 8:00
 Downstairs at Tekserve, on 23rd between 6th and 7th
 http://tekserve.com/about/hours.php for directions and map
 Everyone's welcome. Just tell the person at the front you're there for
 CocoaHeads.

 Hope to see you there!

 --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/symadept%40gmail.com

 This email sent to symad...@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: Better sorting using threads?

2010-03-11 Thread Ken Ferry
 Does Cocoa have sorted containers so that an object can be inserted in
sorted order?  If so it seems like this would be far less expensive.

Probably the best thing to do if you want this is to maintain the sort
yourself by inserting new objects in the correct position.  You can find the
position using
-[NSArray indexOfObject:inSortedRange:options:usingComparator:].  That's two
lines instead of one to add an object to an array, which is not bad.

That method is new in 10.6, but something similar has been in CoreFoundation
for a while.  CFArrayBSearchValues is usable on NSArray since CFArray is
bridged.

You can also look at -[NSArray sortedArrayHint].  The deal there is that you
extract an opaque hint from a sorted array, change the array, and resort
passing in the hint.  This is optimized for the case when the array is still
mostly sorted, but with some things out of place.

-Ken

On Thu, Mar 11, 2010 at 10:38 PM, Bill Bumgarner b...@mac.com wrote:


 On Mar 11, 2010, at 11:15 AM, Andrew James wrote:

  Does Cocoa have sorted containers so that an object can be inserted in
 sorted order?  If so it seems like this would be far less expensive.

 Depends entirely on need.   Keeping a container sorted on insert can be
 quite expensive;  potentially considerably more expensive than doing a
 single batch sort at the end.

 On-the-fly sorted containers are generally only applicable when updates to
 the container will be frequently interleaved with read operations.

 b.bum
 ___

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

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

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

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

___

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

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

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

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


Re: NSTextView backed by core data, undo problems

2010-03-11 Thread Martin Hewitson
Thanks, Kyle. I figured the answer would be something like this. OK, then I'll 
need to rethink the architecture a bit. I was aiming for an Xcode-like 
interface with potentially multiple views to the same file content, but without 
using 'updates continuously' this is going to be more difficult to achieve. If 
anyone has any good suggestions, I'd be delighted to hear them.

Thanks again,

Martin


On Mar 11, 2010, at 8:52 PM, Kyle Sluder wrote:

 On Thu, Mar 11, 2010 at 7:50 AM, Martin Hewitson
 martin.hewit...@aei.mpg.de wrote:
 The nasty little problem I have is that if I edit the contents of a file via 
 the NSTextView, then do 'undo', the cursor (selection) in the NSTextView 
 jumps to the end of the document, and the scrollview jumps to the top. 
 Almost as if the whole text has been replaced. The only way I can avoid this 
 so far is to set the binding so that it doesn't 'update continuously'. One 
 other symptom is that each undo removes the last character typed, whereas 
 with 'update continuously' off I get the more common behaviour of undoing 
 the last word or at least recent group of actions.
 
 By setting the value continuously you're breaking the text view's undo
 coalescing.
 
 Doing this correctly is not going to be an easy task. You will need to
 learn much about the Cocoa text system. The 30,000ft overview: you
 want to mutate an NSTextStorage hooked up to the text view, rather
 than simply setting a property on the model object. Core Data and KVC
 don't support this pattern natively; you will need to write code, and
 it can get hairy.
 
 --Kyle Sluder


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






___

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

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

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

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