Porting ResEdit Text Resources to OS X

2011-06-19 Thread Robert Hard

Cocoa list
I want to port a System 9 tutorial to an OSX using Cocoa. This tutorial 
consists of a series of units, each in turn consisting of a series of short RTF 
text panels that appear in relation to animated drawing sequences in a separate 
window when the user clicks a button. The RTF text originally was stored in 
ResEdit text resources with each called when appropriate. There is NO user 
editing of the text panels.
Is there an equivalent way of doing this with OS X in a Cocoa app?
Would it be better to use NSTextStorage/NSText view approach or  CoreData 
methods? There are about 30 text units, each about 2-4 kbytes each. I have RFT 
TextEdit files of each panel.
Thanks.. 
Robert
___

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

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

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

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


Setting the firstResponder in a view

2011-06-19 Thread Andre Masse
Hi List,

I've been banging my head on this for awhile... I'm using a non document, non 
core data application. At this point this is a fairly common (I think) 
master/detail single window design. The window has a NSTabView with the master 
on one tab and detail on another, and a SourceView (like Mail) on the left 
side. This application is a front end to a PostgreSQL database.

The common use case is:
1- user select a database table on the source view which sends a query to the 
backend
2- result is shown on the tableView
3- user select a row and click a button or double-click to see the detail view.

Now, although I've set nextKeyView for all textFields, I just cant set focus 
on the NSTextField that I want to be first responder... It's always the topmost 
field that get the focus first. I tried to put [window 
makeFirstResponder:myFirstResponderField] everywhere I could think of without 
success. Since when the window appear on screen none of the views are present, 
I cant set the initialFirstResponder on the detail view, which is probably why 
my fancy key view loop is ignored.

The only thing that works is using a button on the detail view which calls 
makeFirstResponder:myFirstResponderField on the window. Obviously, this is not 
an ideal solution...

I'm probably missing something obvious and feel free to call me an idiot for 
overlooking this :-)

Thanks and Cheers,

Andre Masse



___

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

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

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

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


Re: Tab Bar iPad App With Table View(Conrad Shultz)

2011-06-19 Thread Sivakumar Kandappan
Hi
For the the kind of view which you were mentioning you should create a
standard or customised tableview controller and set the tabbar controllers
property.After setting this add the tabbar view to the view which will
show the tab bar. Once you click the tab bar button. Tableview controller
load view will be called which will help to load all the items.

UITabBarcontroller *tabbarcontroller=[UITabBarController alloc] init];
tabbarcontroller.viewcontrollers=[NSArray
arrayWithObjects:tablecontroller,nil];
Self.view=tabbarcontroller.view;
that¹s it I guess. The above code was not tested. I advise you to test it

Cheers
Sivakumar

On 6/19/11 1:57 AM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:

Conrad Shultz


___

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

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

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

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


Re: Porting ResEdit Text Resources to OS X

2011-06-19 Thread Graham Cox

On 19/06/2011, at 3:18 AM, Robert Hard wrote:

  I have RFT TextEdit files of each panel.


Just use the files as resources. They can simply be added to the project and 
will be copied into your app's bundle. At runtime, load the one you want into a 
NSTextView. One line of code, pretty much. I wouldn't bother doing anything 
with the original RedEdit resources, just use the RTF files as is.

The original Mac resource manager was basically a sort of filesystem (or 
database) within a filesystem. Since the very original Mac didn't have real 
directories, it was necessary to provide a way to load things from disk that 
couldn't be individual files inside a (hidden) directory. That situation has 
thankfully long since been superseded. Resources these days are just files 
inside your bundle, which is in itself just a disguised directory.

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


CATransactions having no effect in CALayer draw delegate

2011-06-19 Thread Ken Tozier
HI

I'm writing a subclass of CALayer and what I'm seeing is that regardless of 
whether I wrap CG drawing commands in a CATransaction, or not, it still 
animates. One of the properties of the subclass is a suppressAnimations BOOL 
which, if set, is used in the draw method to dispatch the incoming layer and 
context to a  suppressed or normal draw method. Here's the my drawInContext 
method:

- (void) drawInContext:(CGContextRef) inContext
{
 if (suppressAnimations == YES)
  [self drawInContextSuppressed: inContext];
 else
  [self drawInContextNormal: inContext];
}
 

And here are the suppressed and normal draw methods

- (void) drawInContextSuppressed:(CGContextRef) inContext
{
 NSLog(@Entered: drawInContextSuppressed);
 [CATransaction begin];
 [CATransaction setValue:[NSNumber numberWithFloat:0.0f] 
forKey:kCATransactionAnimationDuration];
 [self drawInContextNormal: inContext];
 [CATransaction commit];
} 

- (void) drawInContextNormal:(CGContextRef) inContext
{
 CGPathRef  path = [self bezelPath]; // doesn't do any drawing, just 
generates a CGPathRef
 NSData  *imgData = [properties objectForKey: @backgroundImage];

 CGContextSaveGState(inContext);
 CGContextBeginPath(inContext);
 CGContextAddPath(inContext, path );
 CGContextEOClip(inContext);

 if (imgData != nil)
  [self drawImage: imgData inContext: inContext];

 CFRelease(path);
 CGContextRestoreGState(inContext);
}

I tried the suggestion by David Duncan here 
(http://www.cocoabuilder.com/archive/cocoa/279886-calayer-with-no-animation.html)
 and overrode 

- (id) actionForKey:(NSString *) inKey
{
 NSLog(@actionForKey: %@, inKey);

 if ([inKey isEqualToString: @contents])
  return nil;
}

But I'm still getting animation.

Anyone see where I'm going 
astray?___

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

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

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

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


Re: Tab Bar iPad App With Table View

2011-06-19 Thread Conrad Shultz
(Somehow your mail client inserted my name in the subject line.)

Let's not get ahead of ourselves here. The OP stated they're totally new to the 
platform and as such it's probably ill-advised to have them start building a 
view hierarchy in code when it could be done satisfactorily in Interface 
Builder with a lot less head banging in the process.

(I am not opposed to designing in code - it's how I do _most_ of my interface 
work - but it's not the most productive way to spend one's time when getting 
off the ground.)

As an aside, from the description the OP gave I would surmise that a 
UINavigationController hosting a UITableView would better suit the requested 
design.  If so, this is even more code to write and amplifies the utility of IB 
even more. 

(Sent from my iPad.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Jun 19, 2011, at 0:07, Sivakumar Kandappan sivak...@buffalo.edu wrote:

 Hi
 For the the kind of view which you were mentioning you should create a
 standard or customised tableview controller and set the tabbar controllers
 property.After setting this add the tabbar view to the view which will
 show the tab bar. Once you click the tab bar button. Tableview controller
 load view will be called which will help to load all the items.
 
 UITabBarcontroller *tabbarcontroller=[UITabBarController alloc] init];
 tabbarcontroller.viewcontrollers=[NSArray
 arrayWithObjects:tablecontroller,nil];
 Self.view=tabbarcontroller.view;
 that¹s it I guess. The above code was not tested. I advise you to test it
 
 Cheers
 Sivakumar
 
 On 6/19/11 1:57 AM, cocoa-dev-requ...@lists.apple.com
 cocoa-dev-requ...@lists.apple.com wrote:
 
 Conrad Shultz
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/conrad%40synthetiqsolutions.com
 
 This email sent to con...@synthetiqsolutions.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


making a clickable link in NSTableView

2011-06-19 Thread Rick C.
Hello,

I currently have a NSTableView which displays a list of files and normally the 
table view is not clickable or selectable.  In this list of files I actually 
display the file path as a subtitle to the file name.  What I would like to do 
is to turn that file path into a clickable link that when clicked would do the 
equivalent of Reveal in Finder.  Ideally the file path in my table view would 
look the way it does currently but when the mouse hovers over it then the 
cursor would change to a hand indicating it's a link.  I'm assuming I would 
have to turn the file path into an NSURL but could someone point me in the 
right direction how to make all of this happen?  Thanks!

rc___

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

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

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

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


Re: Setting the firstResponder in a view

2011-06-19 Thread Andre Masse
Hi,

Well after a good night sleep, found the problem. I was using this call on my 
controller:

[[[self view] window] makeFirstResponder:myFirstResponderField]

I found that this kind of one liner is bad because it assumes too many things. 
I'll be more careful now. In this case, the problem was that the view's window 
was nil! I assumed that a view always had a window. I was wrong. Need to find 
why though.

Sorry for the noise,

Andre Masse



On 18/06/2011, at 16:51 , Andre Masse wrote:

 Hi List,
 
 I've been banging my head on this for awhile... I'm using a non document, non 
 core data application. At this point this is a fairly common (I think) 
 master/detail single window design. The window has a NSTabView with the 
 master on one tab and detail on another, and a SourceView (like Mail) on the 
 left side. This application is a front end to a PostgreSQL database.
 
 The common use case is:
 1- user select a database table on the source view which sends a query to the 
 backend
 2- result is shown on the tableView
 3- user select a row and click a button or double-click to see the detail 
 view.
 
 Now, although I've set nextKeyView for all textFields, I just cant set 
 focus on the NSTextField that I want to be first responder... It's always the 
 topmost field that get the focus first. I tried to put [window 
 makeFirstResponder:myFirstResponderField] everywhere I could think of without 
 success. Since when the window appear on screen none of the views are 
 present, I cant set the initialFirstResponder on the detail view, which is 
 probably why my fancy key view loop is ignored.
 
 The only thing that works is using a button on the detail view which calls 
 makeFirstResponder:myFirstResponderField on the window. Obviously, this is 
 not an ideal solution...
 
 I'm probably missing something obvious and feel free to call me an idiot for 
 overlooking this :-)
 
 Thanks and Cheers,
 
 Andre Masse
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/andre.masse%40videotron.ca
 
 This email sent to andre.ma...@videotron.ca

___

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

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

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

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


How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
In a document-based app my custom view draws some thousand paths in drawRect: 
with a good performance. Now I'd like to offer a slow-motion animation, so 
the user can actually watch the paths being drawn (not each single one, but e. 
g. in steps of 100 paths per sec).

I though of several approaches and all of them seem to be infeasible:

1. Sleeping the drawing loop in drawRect: (or make the runLoop wait for some 
time) and use [... flushGraphics]: Freezes the GUI, as the app is 
single-threaded
2. Moving the drawing in a 2nd thread and then pause this one: AFAIK is drawing 
in a second thread not allowed in Cocoa
3. Limit the drawing loop to an increasing high bound, and setup a timer to 
fire [self setNeedsDisplay:YES] periodically: Causes the first x paths being 
redrawn at each animation step, resulting in a bad performance
4. Same approach, but skipping the first x paths in the next animation step: 
Corrupted display, e. g. while resizing in an animation

I'm racking my brains over this, any suggestions?

Mattes   ___

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

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

Help/Unsubscribe/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 clickable link in NSTableView

2011-06-19 Thread Houdah - ML Pierre Bernard
Hi!

Here is the solution I got from DTS:

http://dl.dropbox.com/u/2381634/DTS/TableViewLinks-updated.zip

At a later WWDC they introduced a more evolved version of the same code:

http://developer.apple.com/library/mac/#samplecode/CocoaTipsAndTricks/Introduction/Intro.html

Best,
Pierre Bernard
Houdah Software s.à r.l.


On Jun 19, 2011, at 1:08 PM, Rick C. wrote:

 Hello,
 
 I currently have a NSTableView which displays a list of files and normally 
 the table view is not clickable or selectable.  In this list of files I 
 actually display the file path as a subtitle to the file name.  What I would 
 like to do is to turn that file path into a clickable link that when clicked 
 would do the equivalent of Reveal in Finder.  Ideally the file path in my 
 table view would look the way it does currently but when the mouse hovers 
 over it then the cursor would change to a hand indicating it's a link.  I'm 
 assuming I would have to turn the file path into an NSURL but could someone 
 point me in the right direction how to make all of this happen?  Thanks!
 
 rc___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/pierre.bernard%40lists.houdah.com
 
 This email sent to pierre.bern...@lists.houdah.com

- - -
Houdah Software s. à r. l.
http://www.houdah.com

HoudahGeo: One-stop photo geocoding
HoudahSpot: Powerful Spotlight frontend




___

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

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

Help/Unsubscribe/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 redraw a view in slow-motion

2011-06-19 Thread Ken Tozier
Have you tried CALayer/CAAnimation? They have a lot of power and are 
specifically designed for animation. If for some reason, you don't want to go 
that route, the following is a bit hokey, but it might work

Add a subsetRange property to your view class

Create a setSubsetRange:(NSRange) inRange method so KVO will work

Add yourself as an observer to this subsetRange property
 [self addObserver: self forKeyPath: @subsetRange options: 
NSKeyValueObservingOptionNew context: NULL];

Add an observeValueForKeyPath

- (void)observeValueForKeyPath:(NSString *) inKeyPath 
ofObject:(id) inObject 
change:(NSDictionary *) inChange 
context:(void *) inContext
{
if ([inKeyPath isEqualToString: @subsetRange])
{
// figure out how many lines you still have to draw here
if (stillHaveLinesToDraw == YES)
[self setNeedsDisplay: YES];
}
}

Then in your draw method
-(void) drawRect:(NSRect) inRect
{
// draw the set of lines specified in the subsetRange property
   
// calculate the next range and use your setter method
[self setSubsetRange: newRange];
}

As I said, pretty hokey, but it might do the trick. You should really check out 
CALayer and friends though it seems to be pretty slick. (Still pretty much a 
newbie, to CALayer, myself, but I like it so far)


On Jun 19, 2011, at 8:46 AM, Matthias Arndt wrote:

 In a document-based app my custom view draws some thousand paths in drawRect: 
 with a good performance. Now I'd like to offer a slow-motion animation, so 
 the user can actually watch the paths being drawn (not each single one, but 
 e. g. in steps of 100 paths per sec).
 
 I though of several approaches and all of them seem to be infeasible:
 
 1. Sleeping the drawing loop in drawRect: (or make the runLoop wait for some 
 time) and use [... flushGraphics]: Freezes the GUI, as the app is 
 single-threaded
 2. Moving the drawing in a 2nd thread and then pause this one: AFAIK is 
 drawing in a second thread not allowed in Cocoa
 3. Limit the drawing loop to an increasing high bound, and setup a timer to 
 fire [self setNeedsDisplay:YES] periodically: Causes the first x paths being 
 redrawn at each animation step, resulting in a bad performance
 4. Same approach, but skipping the first x paths in the next animation step: 
 Corrupted display, e. g. while resizing in an animation
 
 I'm racking my brains over this, any suggestions?
 
 Mattes   ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/kentozier%40comcast.net
 
 This email sent to kentoz...@comcast.net

___

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

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

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

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


Non-rectangular image of NSView for dragging

2011-06-19 Thread Martin Hewitson
Dear list,

I have a view which contains a set of subviews. This control is a little like a 
collection view. I have drag-n-drop implemented but I'm having some trouble 
getting a decent image for dragging. The problem is that the subviews are not 
rectangular but have rounded corners. So far I'm using NSBitmapImageRep's 
-initWithFocusedViewRect to grab a screen-shot of the correct part of the 
screen. Unfortunately I can only specify the portion of the screen to grab 
using an NSRect. This results in the background of the main view being included 
in the dragging image. This looks kind of ugly. What I'd really like is to do 
the same but specify a bezier path instead. I was wondering if there is a 
better way to generate a drag image which properly reflects what the subview 
actually draws.

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


Re: How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
Hi Ken,

Am 19.06.2011 um 15:40 schrieb Ken Tozier:

 - (void)observeValueForKeyPath:(NSString *) inKeyPath 
   ofObject:(id) inObject 
   change:(NSDictionary *) inChange 
   context:(void *) inContext
 {
 if ([inKeyPath isEqualToString: @subsetRange])
 {
 // figure out how many lines you still have to draw here
 if (stillHaveLinesToDraw == YES)
 {
 sleep(some number of ticks);
 [self setNeedsDisplay: YES];
 }
 }
 }

Thanks for this speedy reply! Using a KVO observer is a new approach I haven't 
considered, yet. But the main difference to my first idea is the usage of 
repetitive invocations of drawRect: instead a loop inside the method itself. 
To make this a slow-motion, you mentioned a sleep(...) (wasn't included in 
the mailing list reply), which will freeze the GUI, won't it?

CAAnimation sounds promising, unfortunately I haven't used it before, and 
animating several paths doesn't seem to be covered with basic animations ... 
I'd look deeper into the references, but currently I'm afraid it's beyond my 
capabilities.

Matthias___

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

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

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

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


Re: Synthesised properties and additional actions

2011-06-19 Thread Eeyore
Here is a trick I saw somewhere else that might do what you need. On the other 
hand, i'm still learning cocoa myself so it may have drawbacks that I'm unaware 
of.

Create a private property (like internal_foo below) to handle memory. Then have 
a public property to do the other stuff. So users of the class access the 
property with foo and you get synthesized memory management with internal_foo.

Sent from my iPad

On Jun 18, 2011, at 10:12 PM, Graham Cox graham@bigpond.com wrote:

 If I synthesize a property, is it possible to also directly invoke some other 
 code when that property is set (other than the usual KVO)? That is, I need to 
 do something like:
 
 
 
 @synthesize internal_foo;
 
 
 - (void)setFoo:(id) newFoo
 {
  self.internal_foo = newFoo;
 
 [self doSomethingElseAsWell];
 }
 
-(id) foo
{
return self.internal_foo;
}
 
 Is this kind of thing possible? It looks to me as if the self.foo = line will 
 incur an infinite loop. But if the property is synthesized, to what would I 
 assign the new value?
 
 --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/eeyore%40monsterworks.com
 
 This email sent to eey...@monsterworks.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


This code is leaking...

2011-06-19 Thread Tony Cate

- (NSImage *)illustration
{
if ( illustrationData != nil ){
NSImage* thisImage = [NSImage new];
NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] 
initWithData:illustrationData];
NSPICTImageRep* pictImageRep = [[NSPICTImageRep alloc] 
initWithData:illustrationData];


if ( bitmapImageRep != nil ){
NSLog(@bitmapImageRep retainCount, [bitmapImageRep 
retainCount]);

[thisImage addRepresentation:bitmapImageRep];
NSLog(@bitmapImageRep retainCount, [bitmapImageRep 
retainCount]);

[bitmapImageRep release];
NSLog(@bitmapImageRep retainCount, [bitmapImageRep 
retainCount]);

}
if ( pictImageRep != nil ){
[thisImage addRepresentation:pictImageRep];
[pictImageRep release];
}
return thisImage;
}
return nil;
}

The logs look like this:

2011-06-19 09:42:49.817 MyTestApp[92772:903] thisBitmapImageRep 
retainCount: 2
2011-06-19 09:42:49.820 MyTestApp[92772:903] thisBitmapImageRep 
retainCount: 3
2011-06-19 09:42:49.822 MyTestApp[92772:903] thisBitmapImageRep 
retainCount: 2


bitmapImageRep is leaking. Why is the retain count 2 after the 
initWithData:? Should I file a bug?


Tony



___

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

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

Help/Unsubscribe/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 redraw a view in slow-motion

2011-06-19 Thread Ken Tozier
If you keep the animation short (say 1.5 to 2 seconds) the freezes might not be 
too irksome to the user, but eliminating them altogether would require adding 
NSOperationQueues and NSInvocationOperations to the mix and this is even too 
hokey for me :)

With CALayers, you could create 10 different layers each with a different 
subset of lines right in your setFrame method (or whichever methods cause the 
drawRect to trigger) Then with those animation frames in hand you could set up 
an animator to composite a new layer at some appropriate interval. As I said, 
I'm very new to CALayers myself, so I don't know exactly how to do this, but 
the complexity (and uglyness) of the roll-your-own solution makes CALayer look 
like an attractive option.

- 
On Jun 19, 2011, at 9:57 AM, Matthias Arndt wrote:

 Hi Ken,
 
 Am 19.06.2011 um 15:40 schrieb Ken Tozier:
 
 - (void)observeValueForKeyPath:(NSString *) inKeyPath 
  ofObject:(id) inObject 
  change:(NSDictionary *) inChange 
  context:(void *) inContext
 {
 if ([inKeyPath isEqualToString: @subsetRange])
 {
 // figure out how many lines you still have to draw here
 if (stillHaveLinesToDraw == YES)
 {
 sleep(some number of ticks);
 [self setNeedsDisplay: YES];
 }
 }
 }
 
 Thanks for this speedy reply! Using a KVO observer is a new approach I 
 haven't considered, yet. But the main difference to my first idea is the 
 usage of repetitive invocations of drawRect: instead a loop inside the 
 method itself. To make this a slow-motion, you mentioned a sleep(...) 
 (wasn't included in the mailing list reply), which will freeze the GUI, won't 
 it?
 
 CAAnimation sounds promising, unfortunately I haven't used it before, and 
 animating several paths doesn't seem to be covered with basic animations ... 
 I'd look deeper into the references, but currently I'm afraid it's beyond my 
 capabilities.
 
 Matthias

___

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

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

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

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


Re: This code is leaking...

2011-06-19 Thread Mike Abdullah
NEVER test for memory leaks using -retainCount. ALWAYS use the supplied tools 
instead.

On 19 Jun 2011, at 15:29, Tony Cate wrote:

 - (NSImage *)illustration
 {
if ( illustrationData != nil ){
NSImage* thisImage = [NSImage new];
You never (auto)release this image, so it's getting leaked

NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] 
 initWithData:illustrationData];
NSPICTImageRep* pictImageRep = [[NSPICTImageRep alloc] 
 initWithData:illustrationData];
 
if ( bitmapImageRep != nil ){
[thisImage addRepresentation:bitmapImageRep];
[bitmapImageRep release];
}
if ( pictImageRep != nil ){
[thisImage addRepresentation:pictImageRep];
[pictImageRep release];
}
You are correctly managing memory for the image reps. The image itself is your 
problem.

return thisImage;
}
return nil;
 }
 
 The logs look like this:
 
 2011-06-19 09:42:49.817 MyTestApp[92772:903] thisBitmapImageRep retainCount: 2
 2011-06-19 09:42:49.820 MyTestApp[92772:903] thisBitmapImageRep retainCount: 3
 2011-06-19 09:42:49.822 MyTestApp[92772:903] thisBitmapImageRep retainCount: 2
 
 bitmapImageRep is leaking. Why is the retain count 2 after the initWithData:? 
 Should I file a bug?
 
 Tony
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

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

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

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

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


Re: Non-rectangular image of NSView for dragging

2011-06-19 Thread Sivakumar Kandappan
I assume you are using the  draw rect function. The following is my
opinion and my way of doing
When the user selects the objects; create path from the non rectangular
image with respect to any frame of reference like frame or bounds of the
shape.
You can use path to clip the region by using mask or create a CGImage with
that.
When the user moves calculate how much is your frame of reference is moved
from the original location and update the CGImage or the mask location.

Cheers
Sivakumar 

On 6/19/11 9:59 AM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:

Non-rectangular image of NSView for dragging


___

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

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

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

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


Automatically mirroring folders

2011-06-19 Thread Leonardo
Problem: I have to automatically mirror 2 folders, /A and /B, such a way
they contains the same files and folders.

- So I FSEventStreamCreate with kFSEventStreamEventIdSinceNow,
kFSEventStreamCreateFlagWatchRoot and a 2 seconds latency time.

- I get a notification: there is a new file to copy from /A to /B. I copy
the file, but I quickly get a new notification that there is a new file in
B. Well, this notification is useless to me. I copied that file. Therefore I
don't need to copy it again.

- So, before I copy the file, I thought, I stop and invalidate the stream,
then I copy the file, then I turn the stream on again. But here I get 2
problems:

1) At the end of the copyFile, I turn the stream on again, and the Finder, a
couple of seconds later (but it could even be shorter or longer) updates the
/B/.DS_Store file so I get a new notification. How to force the Finder to
update the .DS_Store file immediately after the copy? Or should I use a
longer latency time? How long?

2) During the period of time the stream is off, if some new files arrive
within the folder /A, I lose the notification to copy it.

How to workaround that?


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


Re: making a clickable link in NSTableView

2011-06-19 Thread Lee Ann Rucker
Look at TableViewLinks/NSAttributedStringAdditions.m in the sample code.

- Original Message -
From: Rick C. rickcort...@gmail.com
To: Cocoa Development cocoa-dev@lists.apple.com
Sent: Sunday, June 19, 2011 4:08:11 AM
Subject: making a clickable link in NSTableView

Hello,

I currently have a NSTableView which displays a list of files and normally the 
table view is not clickable or selectable.  In this list of files I actually 
display the file path as a subtitle to the file name.  What I would like to do 
is to turn that file path into a clickable link that when clicked would do the 
equivalent of Reveal in Finder.  Ideally the file path in my table view would 
look the way it does currently but when the mouse hovers over it then the 
cursor would change to a hand indicating it's a link.  I'm assuming I would 
have to turn the file path into an NSURL but could someone point me in the 
right direction how to make all of this happen?  Thanks!

rc___

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

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

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

This email sent to lruc...@vmware.com
___

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

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

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

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


Re: How to Management Bytes?

2011-06-19 Thread Fritz Anderson
On 19 Jun 2011, at 10:28 AM, Bing Li wrote:

 I got another problem in the following method. A byte array is used to save
 data transmitted from a remote node and the size is different for each
 message. I think I need to release the byte array after it is used. However,
 the system got crashed if the line, free(receivedBytes), was added. So I
 made a copy for the receivedMessage. But it still crashed.

free() is for memory allocated in the heap by the malloc() family of functions. 
It is an error to apply it to memory on the stack, as in the case of your 
receivedBytes. That memory will be returned to the system when receivedBytes 
goes out of scope. It will be illegal to use that array after that.

This is an extremely elementary fact of the C programming language. If you 
don't know it, you can't program in C. I believe you have already been advised 
to stop whatever you are doing, and read an introductory-level book on C. Do 
that. If you don't, you will be wasting your time, and ours.

— 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: How to Management Bytes?

2011-06-19 Thread Scott Ribe
On Jun 19, 2011, at 9:28 AM, Bing Li wrote:

 One more issue is that there was no memory leaking even if I didn't add the
 line, free(receivedBytes). Why?

Because it's stack-allocated, not allocated with any version of malloc. I 
pointed out the same mistake in my first email to you, yet here you are about a 
week later having re-introduced the error. Read an introductory book on C. Now. 
Before you waste any more of your time.

What is the purpose of subLoopPool? There is now nothing in its scope that will 
cause any objective-C objects to be created, much less autoreleased.

And that copy thing you tried... Seriously? Allocating a a string you own, then 
copying ( leaking) it, then autoreleasing the copy???

You're just thrashing here, going back and forth between the same set of 
mistakes with no understanding of what's going on. AS YOU WERE TOLD MULTIPLE 
TIMES BY MULTIPLE PEOPLE, you had the memory management correct in this 
function, and were leaking the receivedMessage string elsewhere in your code. 
Yet here you are days later, still thrashing around with random weird pointless 
buggy changes to this function.

I had intended not to respond to any more of these messages, but I decided to 
try one more time. I am now done. I will not try to help you again until you 
ask a question that demonstrates that you have listened to what you've been 
told about where your bug is, and have done your homework by getting some 
fundamental understanding of the language you're trying to use.

(And by the way, you are probably nowhere near having a stable program. Based 
on what you've shown us so far, you should be prepared to be debugging for a 
while.)

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

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

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

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

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


How to Management Bytes?

2011-06-19 Thread Bing Li
Dear all,

First, I appreciate so much for your replies in the past days. Those replies
help me a lot when implementing my system.

I got another problem in the following method. A byte array is used to save
data transmitted from a remote node and the size is different for each
message. I think I need to release the byte array after it is used. However,
the system got crashed if the line, free(receivedBytes), was added. So I
made a copy for the receivedMessage. But it still crashed.

One more issue is that there was no memory leaking even if I didn't add the
line, free(receivedBytes). Why?

Thanks so much for your help!

Best regards,
Bing

…...
NSInteger messageSize = [sizeString intValue];
char receivedBytes[messageSize];
while (currentByteIndex  messageSize)
{
NSAutoreleasePool *subLoopPool =
[[NSAutoreleasePool alloc] init];
numberBytesReceived = recv(clientSocket,
buffer, messageSize - currentByteIndex, 0);
if (numberBytesReceived  0)
{
for (int i = 0; i 
numberBytesReceived; i ++)
{

 receivedBytes[currentByteIndex + i] = buffer[i];
}
currentByteIndex +=
numberBytesReceived;
}
else
{
[subLoopPool drain];
return;
}
[subLoopPool drain];
}
//  NSString *receivedMessage = NSString alloc]
initWithBytes:receivedBytes length:currentByteIndex
encoding:NSUTF8StringEncoding] copy] autorelease];
NSString *receivedMessage = [[[NSString alloc]
initWithBytes:receivedBytes length:currentByteIndex
encoding:NSUTF8StringEncoding] autorelease];
[self NotifyMessageReceived:receivedMessage];
free(receivedBytes);
…...
___

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

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

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

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


Re: CATransactions having no effect in CALayer draw delegate

2011-06-19 Thread Kyle Sluder
On Sun, Jun 19, 2011 at 12:38 AM, Ken Tozier kentoz...@comcast.net wrote:
 HI

 I'm writing a subclass of CALayer and what I'm seeing is that regardless of 
 whether I wrap CG drawing commands in a CATransaction, or not, it still 
 animates. One of the properties of the subclass is a suppressAnimations 
 BOOL which, if set, is used in the draw method to dispatch the incoming layer 
 and context to a  suppressed or normal draw method. Here's the my 
 drawInContext method:

You're mixing conceptual layers here.

CG drawing isn't animated at all. The animation happens at the Core
Animation layer. When CA asks your layer to -drawInContext: that's an
atomic operation from CA's perspective. The thing getting animated is
whatever that context was attached to.

 I tried the suggestion by David Duncan here 
 (http://www.cocoabuilder.com/archive/cocoa/279886-calayer-with-no-animation.html)
  and overrode

It sounds like you didn't understand what he was saying.

--Kyle Sluder
___

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

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

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

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


Re: Non-rectangular image of NSView for dragging

2011-06-19 Thread Kyle Sluder
On Sun, Jun 19, 2011 at 6:46 AM, Martin Hewitson
martin.hewit...@aei.mpg.de wrote:
 I have a view which contains a set of subviews. This control is a little like 
 a collection view. I have drag-n-drop implemented but I'm having some trouble 
 getting a decent image for dragging. The problem is that the subviews are not 
 rectangular but have rounded corners. So far I'm using NSBitmapImageRep's 
 -initWithFocusedViewRect to grab a screen-shot of the correct part of the 
 screen. Unfortunately I can only specify the portion of the screen to grab 
 using an NSRect. This results in the background of the main view being 
 included in the dragging image. This looks kind of ugly. What I'd really like 
 is to do the same but specify a bezier path instead. I was wondering if there 
 is a better way to generate a drag image which properly reflects what the 
 subview actually draws.

Create a bitmap context and call -drawRect: recursively on your view
hierarchy, setting up the graphics state and CTM appropriately as you
go.

You may want to factor out your drawing code from -drawRect: so that
you can call it separately. That would be handy if you need to draw
subtle differences between the in-view representation and the drag
image.

--Kyle Sluder
___

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

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

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

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


Re: Automatically mirroring folders

2011-06-19 Thread Scott Ribe
On Jun 19, 2011, at 10:48 AM, Leonardo wrote:

 2) During the period of time the stream is off, if some new files arrive
 within the folder /A, I lose the notification to copy it.

I think you have to leave the event streams active all the time, keep track of 
your own actions, and filter out those events that you should ignore.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

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

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

Help/Unsubscribe/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 Management Bytes?

2011-06-19 Thread Bing Li
Dear Scott and Fritz,

Actually, my system made a lot of progresses according to your replies. I
really don't have enough experiences on C. So I need to improve.

I appreciate so much for your help!

Best regards,
Bing

On Mon, Jun 20, 2011 at 12:13 AM, Scott Ribe scott_r...@elevated-dev.comwrote:

 On Jun 19, 2011, at 9:28 AM, Bing Li wrote:

  One more issue is that there was no memory leaking even if I didn't add
 the
  line, free(receivedBytes). Why?

 Because it's stack-allocated, not allocated with any version of malloc. I
 pointed out the same mistake in my first email to you, yet here you are
 about a week later having re-introduced the error. Read an introductory book
 on C. Now. Before you waste any more of your time.

 What is the purpose of subLoopPool? There is now nothing in its scope that
 will cause any objective-C objects to be created, much less autoreleased.

 And that copy thing you tried... Seriously? Allocating a a string you own,
 then copying ( leaking) it, then autoreleasing the copy???

 You're just thrashing here, going back and forth between the same set of
 mistakes with no understanding of what's going on. AS YOU WERE TOLD MULTIPLE
 TIMES BY MULTIPLE PEOPLE, you had the memory management correct in this
 function, and were leaking the receivedMessage string elsewhere in your
 code. Yet here you are days later, still thrashing around with random weird
 pointless buggy changes to this function.

 I had intended not to respond to any more of these messages, but I decided
 to try one more time. I am now done. I will not try to help you again until
 you ask a question that demonstrates that you have listened to what you've
 been told about where your bug is, and have done your homework by getting
 some fundamental understanding of the language you're trying to use.

 (And by the way, you are probably nowhere near having a stable program.
 Based on what you've shown us so far, you should be prepared to be debugging
 for a while.)

 --
 Scott Ribe
 scott_r...@elevated-dev.com
 http://www.elevated-dev.com/
 (303) 722-0567 voice





___

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

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

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

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


Re: Non-rectangular image of NSView for dragging

2011-06-19 Thread Martin Hewitson
I got an off-list reply suggesting clipping the final image with a bezier path. 
So I used NSBezierPath's addClip with the same path used in drawRect: for 
clipping my final image. Works perfectly.

Thanks to all for the suggestions!

Martin

On 19, Jun, 2011, at 07:06 PM, Kyle Sluder wrote:

 On Sun, Jun 19, 2011 at 6:46 AM, Martin Hewitson
 martin.hewit...@aei.mpg.de wrote:
 I have a view which contains a set of subviews. This control is a little 
 like a collection view. I have drag-n-drop implemented but I'm having some 
 trouble getting a decent image for dragging. The problem is that the 
 subviews are not rectangular but have rounded corners. So far I'm using 
 NSBitmapImageRep's -initWithFocusedViewRect to grab a screen-shot of the 
 correct part of the screen. Unfortunately I can only specify the portion of 
 the screen to grab using an NSRect. This results in the background of the 
 main view being included in the dragging image. This looks kind of ugly. 
 What I'd really like is to do the same but specify a bezier path instead. I 
 was wondering if there is a better way to generate a drag image which 
 properly reflects what the subview actually draws.
 
 Create a bitmap context and call -drawRect: recursively on your view
 hierarchy, setting up the graphics state and CTM appropriately as you
 go.
 
 You may want to factor out your drawing code from -drawRect: so that
 you can call it separately. That would be handy if you need to draw
 subtle differences between the in-view representation and the drag
 image.
 
 --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


Re: audiounit instrument with cocoa view

2011-06-19 Thread Stephen Blinkhorn


On 18 Jun 2011, at 17:09, ben kamen wrote:

ok, so it seems like my problem is actually in getting it to load  
the bundle in the first place.  what am i missing?


the bundle identifier in the plist is set to : com.olympia-noise- 
co.RO_CocoaViewFactory




and in the main cpp file i have this, which prints the bundle  
didn't load error :


Are you copying the view bundle into the main plugin bundle? In the  
'Targets' section in the original cocoa templates you should see a  
'Copy Files' build phase inside your main plugin bundle. To add this  
to your project use the cog/wheel drop down menu and then:


Add  New Build Phase  New Copy Files Build Phase

Make sure the destination is set to 'Resources' and then drag and drop  
your CocoaView.bundle (from 'Products') into this build phase.


Hope that helps,
Stephen





OSStatusRainbow_Oscillator::GetProperty(
AudioUnitPropertyID inID,
   
AudioUnitScope 		inScope,
   
AudioUnitElement 	inElement,
  void * 
outData )

{
if (inScope == kAudioUnitScope_Global)
{
switch (inID)
{
case kAudioUnitProperty_CocoaUI:
{
// Look for a resource in the main bundle by 
name and type.
CFBundleRef bundle =  
CFBundleGetBundleWithIdentifier( CFSTR(com.olympia-noise- 
co.RO_CocoaViewFactory) );


if (bundle == NULL) {
printf(bundle didn't load);
return fnfErr;

}

___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (coreaudio-...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/coreaudio-api/stephen%40audiospillage.com

This email sent to step...@audiospillage.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: Synthesised properties and additional actions

2011-06-19 Thread Matt Neuburg
On Sun, 19 Jun 2011 15:12:31 +1000, Graham Cox graham@bigpond.com said:
If I synthesize a property, is it possible to also directly invoke some other 
code when that property is set (other than the usual KVO)? That is, I need to 
do something like:


@synthesize foo;


- (void)   setFoo:(id) newFoo
{
  self.foo = newFoo;

 [self doSomethingElseAsWell];
}


Is this kind of thing possible? It looks to me as if the self.foo = line will 
incur an infinite loop. But if the property is synthesized, to what would I 
assign the new value?

I provide a good (I think) technique for doing this in my book (p. 275, example 
12-5 Overriding synthesized accessors). You can also download sample code 
here:

https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p275b_overrideSynthesizedAccessors

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

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

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

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

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


Re: CATransactions having no effect in CALayer draw delegate

2011-06-19 Thread Ken Tozier
On Jun 19, 2011, at 1:03 PM, Kyle Sluder wrote:

 You're mixing conceptual layers here.
 
 CG drawing isn't animated at all. The animation happens at the Core
 Animation layer. When CA asks your layer to -drawInContext: that's an
 atomic operation from CA's perspective. The thing getting animated is
 whatever that context was attached to.

Not sure I'm following that. Ultimately, the context for all drawing is the 
graphics port of the window, but the docs go to great lengths describing all 
the ways you can perform extremely granular operations on individual layers and 
sublayers. The thing doing the drawing is a subclass of CALayer. What did you 
mean by The thing getting animated is whatever that context was attached to?

 
 I tried the suggestion by David Duncan here 
 (http://www.cocoabuilder.com/archive/cocoa/279886-calayer-with-no-animation.html)
  and overrode
 
 It sounds like you didn't understand what he was saying.

After trying and failing with the action override, I went back and read the 
docs (http://tinyurl.com/CALayerActionForKey) and it sure seems like returning 
nil is the correct thing to do. I understand that actionForKey call comes 
after I do my drawing, but something else is calling that and is ignoring the 
nil return, because the stuff I draw in drawInContext is happily animating 
all sorts of things (like transitions between square and rounded corners on the 
path and the size of the image)

What is the correct understanding of what he was saying?

Under the section Overriding the Duration of Implied Animations, here 
(http://tinyurl.com/OverridingImplicitAnimations) it shows the use of 
transactions that are basically what I'm doing in my drawInContextSuppressed 
method. Since I'm not actually setting a predefined property of the layer, I'm 
unclear on where to actually put this transaction...


___

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

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

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

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


Re: Synthesised properties and additional actions

2011-06-19 Thread Dave DeLong

On Jun 19, 2011, at 11:01 AM, Matt Neuburg wrote:

 I provide a good (I think) technique for doing this in my book (p. 275, 
 example 12-5 Overriding synthesized accessors). You can also download 
 sample code here:
 
 https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p275b_overrideSynthesizedAccessors

Ha, that's quite clever.  I like it.  :)

Dave
___

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

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

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

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


Re: Writing extremely large RTF or .doc files

2011-06-19 Thread Dave DeLong
Thanks for the suggestions, everyone.  I ended up generating HTML files, and 
they seem to be working fine.

Cheers,

Dave

On Jun 18, 2011, at 8:06 AM, Douglas Davidson wrote:

 I might point out that NSAttributedString has a facility for writing out HTML 
 that has options flexible enough to do things like suppressing the head etc 
 for writing out HTML fragments. 
 
 As others point out, HTML is better suited to this sort of thing than many 
 other formats. NSAttributedString can also read it back in later, or if 
 needed /usr/bin/textutil can convert to other formats. 
 
 Douglas Davidson
___

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

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

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

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


Re: audiounit instrument with cocoa view

2011-06-19 Thread Stephen Blinkhorn

Sorry, seems I sent this to the wrong list.


On 19 Jun 2011, at 11:54, Stephen Blinkhorn wrote:



On 18 Jun 2011, at 17:09, ben kamen wrote:

ok, so it seems like my problem is actually in getting it to load  
the bundle in the first place.  what am i missing?


the bundle identifier in the plist is set to : com.olympia-noise- 
co.RO_CocoaViewFactory




and in the main cpp file i have this, which prints the bundle  
didn't load error :


Are you copying the view bundle into the main plugin bundle? In the  
'Targets' section in the original cocoa templates you should see a  
'Copy Files' build phase inside your main plugin bundle. To add this  
to your project use the cog/wheel drop down menu and then:


Add  New Build Phase  New Copy Files Build Phase

Make sure the destination is set to 'Resources' and then drag and  
drop your CocoaView.bundle (from 'Products') into this build phase.


Hope that helps,
Stephen





OSStatusRainbow_Oscillator::GetProperty(
AudioUnitPropertyID inID,
  
AudioUnitScope 		inScope,
  
AudioUnitElement 	inElement,
 void * 
outData )

{
if (inScope == kAudioUnitScope_Global)
{
switch (inID)
{
case kAudioUnitProperty_CocoaUI:
{
// Look for a resource in the main bundle by 
name and type.
CFBundleRef bundle =  
CFBundleGetBundleWithIdentifier( CFSTR(com.olympia-noise- 
co.RO_CocoaViewFactory) );


if (bundle == NULL) {
   printf(bundle didn't load);
   return fnfErr;

   }

___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (coreaudio-...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/coreaudio-api/stephen%40audiospillage.com

This email sent to step...@audiospillage.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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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: Writing extremely large RTF or .doc files

2011-06-19 Thread Mike Abdullah
BTW we have code for streamed generation of HTML files here: 
https://github.com/karelia/KSHTMLWriter

On 19 Jun 2011, at 19:03, Dave DeLong wrote:

 Thanks for the suggestions, everyone.  I ended up generating HTML files, and 
 they seem to be working fine.
 
 Cheers,
 
 Dave
 
 On Jun 18, 2011, at 8:06 AM, Douglas Davidson wrote:
 
 I might point out that NSAttributedString has a facility for writing out 
 HTML that has options flexible enough to do things like suppressing the head 
 etc for writing out HTML fragments. 
 
 As others point out, HTML is better suited to this sort of thing than many 
 other formats. NSAttributedString can also read it back in later, or if 
 needed /usr/bin/textutil can convert to other formats. 
 
 Douglas Davidson
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

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

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

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

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


Re: Release a NSWindowController after the window is closed

2011-06-19 Thread Marc Respass
Hi Brian,

The technique that I have been using for a long time is to alloc/init the 
window controller, make the window controller the delegate of the window, and 
invoke [self autorelease] in windowWillClose:. It's essentially the same thing 
you are doing with less code.

The thing that I love about this technique is that my window is now completely 
independent. If it's a window used as a sheet, I may have many different 
objects using it. Simply closing the window cleans up everything.

As others have pointed out, this technique is incompatible with ARC. There are 
two ways around that. I would like to know what others think about them. One 
solution is to create a static NSMutableSet in the window controller that holds 
all instances of that window controller. In -init, you can do 
[windowControllerSet__ addObject:self]; and in windowWillClose: you invoke 
[windowControllerSet__ removeObject:self];. Of course windowControllerSet__ is 
static so it lives for the life of the app.

Another solution would be that every object that creates an instance of your 
window controller (though it probably works for any instance of any window 
controller) also holds an array of those window controllers and it registers to 
receive the windowWillClose: notification so it can remove it.

As I say above, I like the independence of the window controller being up to 
clean up after itself. It's also a lot less code. 

Hope this helps
Marc

 Hello.
 
 I'm building a Cocoa application and have a question about using
 window controllers. The idea is that when the user selects New from
 the File menu, an instance of MyWindowController which is a subclass
 of NSWindowController is created and a new window from MyWindow.xib is
 displayed.
 
 I'm handling the action in the application delegate. From what I have
 seen after searching around something like the following could be
 done. Once the window is displayed I don't have any reason to store a
 pointer to the window controller anymore and since I allocated it I
 also have it autoreleased before displaying the window.
 
 MyWindowController alloc] init] autorelease] showWindow:self];
 
 Since the window is released soon afterwards the window will briefly
 display on the screen and then go away. I'm using a solution where I
 retain the window controller in the -showWindow: method and let it
 release itself once it gets a windowWillClose notification.
 
 - (IBAction)showWindow:(id)sender
 {
 void (^windowWillCloseHandler)(NSNotification *) = ^(NSNotification 
 *note) {
 [[NSNotificationCenter defaultCenter] removeObserver:self
 name:NSWindowWillCloseNotification object:self.window];
 [self release];
 };
 
 [self retain];
 [[NSNotificationCenter defaultCenter]
 addObserverForName:NSWindowWillCloseNotification object:self.window
 queue:nil usingBlock:windowWillCloseHandler];
 [super showWindow:sender];
 }
 
 Is there a better way to do this? I have searched the documentation
 and have not found anything specific on which practices to use. It
 sounds like something very basic which it should cover so maybe I'm
 just searching with the wrong terms.
___

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

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

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

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


Re: Tab Bar iPad App With Table View

2011-06-19 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 6/19/11 10:59 AM, Julie Seif wrote:
 Conrad,
 
 Could you please tell me more about your idea with a
 UINavigationController hosing a UITableView
 
 Thanks.
 julie.

(Putting back on list.)

As I stated previously you will really want to pick up an intro book if
this is all foreign to you; I, at least, will not have the time to do a
full tutorial on how to implement what you are asking.

That said, in broad brush strokes what you will probably want to do is:

1) Add a UITabBarController to your app and set it as the main view.

2) Add a UINavigationController (this is what you see in iTunes, Mail,
etc. - anywhere where there is the characteristic back button at the
top left) to your app and drag it into the tab bar, causing a tab to get
assigned to it that is managed by the UINavigationController.

3) Add a UITableViewController to your app and set it to be the root
view controller of the UINavigationController.

4) Hook up the delegate and data source for the UITableViewController so
that: a) your menu items get displayed, and; b) when a menu item is
tapped, the appropriate new view controller is pushed onto the
UINavigationController's controller stack.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3+VLEACgkQaOlrz5+0JdVngwCaA6cCs6TUgPboRhaJ9uF+bNor
nOMAn0u/GNiwfDOcaS16sOsGSGLNCqY0
=pQSg
-END PGP 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: CATransactions having no effect in CALayer draw delegate

2011-06-19 Thread Kyle Sluder
On Sun, Jun 19, 2011 at 11:01 AM, Ken Tozier kentoz...@comcast.net wrote:
 On Jun 19, 2011, at 1:03 PM, Kyle Sluder wrote:

 You're mixing conceptual layers here.

 CG drawing isn't animated at all. The animation happens at the Core
 Animation layer. When CA asks your layer to -drawInContext: that's an
 atomic operation from CA's perspective. The thing getting animated is
 whatever that context was attached to.

 Not sure I'm following that. Ultimately, the context for all drawing is the 
 graphics port of the window, but the docs go to great lengths describing all 
 the ways you can perform extremely granular operations on individual layers 
 and sublayers. The thing doing the drawing is a subclass of CALayer. What did 
 you mean by The thing getting animated is whatever that context was attached 
 to?

Core Animation's view of the world ends when it hands you a CGContext
and says fill this with bits. It can't animate the contents of a
CGContext because a CGContext really is just an opaque bit receiver
and associated drawing state. Even though Core Animation attached the
context to a bitmap (or bitmap provider) before handing it to you, the
context and the backing store that you're actually drawing into are a
black box.

All the animations happen at a higher conceptual level. Layers are
rotated, translated, scaled, and faded. In the case of an implicit
crossfade because of changing a layer's contents property, what CA is
actually doing is animating two images that it has previously asked
you to fill by asking the layer to -drawInContext: twice: once into
the old backing store, and once into the new backing store.

 After trying and failing with the action override, I went back and read the 
 docs (http://tinyurl.com/CALayerActionForKey) and it sure seems like 
 returning nil is the correct thing to do. I understand that actionForKey 
 call comes after I do my drawing, but something else is calling that and is 
 ignoring the nil return, because the stuff I draw in drawInContext is 
 happily animating all sorts of things (like transitions between square and 
 rounded corners on the path and the size of the image)

As I described above, none of this animation is actually happening
because of any drawing you're doing in -drawInContext:. Maybe you're
seeing a crossfade?


 What is the correct understanding of what he was saying?

On a second read, you probably did understand what he was saying about
overriding -actionForKey:. I only really see a misconception about
-drawInContext:.


 Under the section Overriding the Duration of Implied Animations, here 
 (http://tinyurl.com/OverridingImplicitAnimations) it shows the use of 
 transactions that are basically what I'm doing in my drawInContextSuppressed 
 method. Since I'm not actually setting a predefined property of the layer, 
 I'm unclear on where to actually put this transaction...

You're setting the contents property of the layer. So returning nil
from -actionForKey: should do the trick. I just found this post by
Matt Neuburg that might explain why you're having trouble:
http://www.cocoabuilder.com/archive/cocoa/293161-calayer-instant-content-update.html

Basically, the sentinel value that tells Core Animation to stop
looking for an action to apply to a property change is NOT nil, as
implied by the documentation and David Duncan's post. Rather, it is
NSNull. nil means I don't have an answer for you; consult someone
else, which can be the layer _or_ the default set of implicit
actions! Rather, try returning [NSNull null] from your -actionForKey:
override.

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


Progress Indicators Spin vs Bar

2011-06-19 Thread James Merkel
I am trying to do an indeterminate progress indicator in a small  
NSPanel window similar to that shown in Figure 15-57 of the  
OSXHIGuidelines. The NSPanel and NSProgresssIndicator are in a nib  
file and I'm pretty sure the IB connections are correct. If I use a  
spin progress indicator, I can start the animation. If I switch to a  
bar progress indicator, I can't start the animation. (Looking at the  
archives, this seems opposite from what other people have experienced  
- they had problems with the spin progress indicator). The code is  
pretty simple. I have a ProgressController class defined as follows  
in .h and .m files:


@interface ProgressController : NSWindowController {
IBOutlet NSProgressIndicator *progressIndicator;
}
-(void)startProgressAnimation;
@end


#import ProgressController.h

@implementation ProgressController

-(id)init{
self = [super initWithWindowNibName:@ProgressWindow];
[self setWindowFrameAutosaveName:@ProgWindow];

return self;
}

-(void)windowDidLoad{

}

-(void)startProgressAnimation{
NSLog(@progressIndicator should start);
[progressIndicator startAnimation:nil];
}

@end

Then use the progress  indicator as follows;

ProgressController * progressController = nil;  
progressController =[[ProgressController alloc] init];
NSLog(@Progress window: %@\n, [progressController window]);
[progressController startProgressAnimation];
[progressController showWindow:self];

(Long processing)

[progressController close];
[progressController release];

So this works with the spinner but not the bar. Seems strange because  
I thought the two progress indicators would work the same.


Thanks for any help.

Jim Merkel

___

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

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

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

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


Re: Progress Indicators Spin vs Bar

2011-06-19 Thread Kyle Sluder
On Sun, Jun 19, 2011 at 1:14 PM, James Merkel jmerk...@mac.com wrote:
 Then use the progress  indicator as follows;

        ProgressController * progressController = nil;
        progressController =[[ProgressController alloc] init];
        NSLog(@Progress window: %@\n, [progressController window]);
        [progressController startProgressAnimation];
        [progressController showWindow:self];

        (Long processing)

        [progressController close];
        [progressController release];


Sounds like you're stalling the main thread. This is bad.

Put up the window, do your long task on a background thread. Call back
to the main thread when processing is complete. If possible,
periodically inform the user of your progress by calling back to the
main thread to update the contents of the progress panel.

--Kyle Sluder
___

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

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

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

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


Re: Progress Indicators Spin vs Bar

2011-06-19 Thread Quincey Morris
On Jun 19, 2011, at 13:14, James Merkel wrote:

   ProgressController * progressController = nil;  
   progressController =[[ProgressController alloc] init];
   NSLog(@Progress window: %@\n, [progressController window]);
   [progressController startProgressAnimation];
   [progressController showWindow:self];
 
   (Long processing)
 
   [progressController close];
   [progressController release];
 
 So this works with the spinner but not the bar. Seems strange because I 
 thought the two progress indicators would work the same.

They don't. The spinning indicator animates itself, but the bar animation 
depends on run loop iterations to drive the animation. If Long processing 
means a loop, you're not going back to the run loop. In those circumstances you 
must arrange for events to be processed (run the run loop or dequeue events in 
a modal event loop).

Note that you probably want to do that anyway, because you probably want to 
have a Cancel button on a long-running operation.

___

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

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

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

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


Re: Progress Indicators Spin vs Bar

2011-06-19 Thread James Merkel


On Jun 19, 2011, at 1:27 PM, Quincey Morris wrote:


On Jun 19, 2011, at 13:14, James Merkel wrote:


ProgressController * progressController = nil;  
progressController =[[ProgressController alloc] init];
NSLog(@Progress window: %@\n, [progressController window]);
[progressController startProgressAnimation];
[progressController showWindow:self];

(Long processing)

[progressController close];
[progressController release];

So this works with the spinner but not the bar. Seems strange  
because I thought the two progress indicators would work the same.


They don't. The spinning indicator animates itself, but the bar  
animation depends on run loop iterations to drive the animation. If  
Long processing means a loop, you're not going back to the run  
loop. In those circumstances you must arrange for events to be  
processed (run the run loop or dequeue events in a modal event loop).


Note that you probably want to do that anyway, because you probably  
want to have a Cancel button on a long-running operation.




Ok thanks -- I didn't realize there was a difference in the way the  
two progress indicators worked.

___

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

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

Help/Unsubscribe/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 redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
Am 19.06.2011 um 19:05 schrieb cocoa-dev-requ...@lists.apple.com:

 If you keep the animation short (say 1.5 to 2 seconds) the freezes might not 
 be too irksome to the user [...] CALayer look like an attractive option.

Even with only 0.01 seconds sleep after drawing each path the UI froze 
completely: It seems the loop iteration didn't allow any mouse or key events to 
come through. CALayer will give me something to think about the next weeks 
(completely new to me), my current approach uses an NSTimer to redraw the paths 
with an increasing upper limit: Surprisingly with a sufficient performance (if 
the graphic don't become too complex ... some improvements are still needed).

Thanks for your support!

Mattes ___

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

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

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

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


Re: Synthesised properties and additional actions

2011-06-19 Thread Tony Romano
Of course they are not designed for atomic operations, you have to add all
the critical sections to make it so. If you argue that you don't need the
multi threaded robustness, then you could argue the value hooking the
setter diminishes the benefit of using the synthesis feature since you are
writing the setter anyways.

Tony Romano

On 6/19/11 11:02 AM, Dave DeLong davedel...@me.com wrote:



On Jun 19, 2011, at 11:01 AM, Matt Neuburg wrote:

 I provide a good (I think) technique for doing this in my book (p. 275,
example 12-5 Overriding synthesized accessors). You can also download
sample code here:
 
 
https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p
275b_overrideSynthesizedAccessors

Ha, that's quite clever.  I like it.  :)

Dave
___

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

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

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

This email sent to tony...@hotmail.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: CATransactions having no effect in CALayer draw delegate

2011-06-19 Thread Ken Tozier

On Jun 19, 2011, at 3:57 PM, Kyle Sluder wrote:

 Core Animation's view of the world ends when it hands you a CGContext
 and says fill this with bits. It can't animate the contents of a
 CGContext because a CGContext really is just an opaque bit receiver
 and associated drawing state. Even though Core Animation attached the
 context to a bitmap (or bitmap provider) before handing it to you, the
 context and the backing store that you're actually drawing into are a
 black box.
 
 All the animations happen at a higher conceptual level. Layers are
 rotated, translated, scaled, and faded. In the case of an implicit
 crossfade because of changing a layer's contents property, what CA is
 actually doing is animating two images that it has previously asked
 you to fill by asking the layer to -drawInContext: twice: once into
 the old backing store, and once into the new backing store.

Nice and clear. Thanks
 
 As I described above, none of this animation is actually happening
 because of any drawing you're doing in -drawInContext:. Maybe you're
 seeing a crossfade?

I'm seeing a clear evolution from a square corner box to a round corner box and 
the obvious movement of an image clipped to my generated path. It only takes 
about 1/2 to 1 second, but looks really silly. Basically the whole point of 
creating my custom CALayer was to allow for custom layer bezels (defined by 
CGPathRefs) that optionally crop the layer contents to the path, not just round 
corner boxes.
 
 You're setting the contents property of the layer. So returning nil
 from -actionForKey: should do the trick. I just found this post by
 Matt Neuburg that might explain why you're having trouble:
 http://www.cocoabuilder.com/archive/cocoa/293161-calayer-instant-content-update.html
 
 Basically, the sentinel value that tells Core Animation to stop
 looking for an action to apply to a property change is NOT nil, as
 implied by the documentation and David Duncan's post. Rather, it is
 NSNull. nil means I don't have an answer for you; consult someone
 else, which can be the layer _or_ the default set of implicit
 actions! Rather, try returning [NSNull null] from your -actionForKey:
 override.

I read the link and tried both of the following:

- (id) actionForKey:(NSString *) inKey
{
if ([inKey isEqualToString: @contents])
return [NSNull null];

return [super actionForKey: inKey];
}

Produced the error: 
 -[NSNull runActionForKey:object:arguments:]: unrecognized selector sent to 
instance 0x7fff701d5fa0

While doing this in my subclass's init method didn't appear to do anything. 
Class behaved exactly the same as before

self.actions = [NSDictionary dictionaryWithObject:[NSNull null] 
forKey:@contents];

Thanks again for the reply it cleared some things up. At this point though, 
it's probably a good time to put CALayers aside, at least for now. The 
inability to simply set the shape of the layer and turn off the blasted 
animations, when needed, is a deal breaker for me. Not sure why Apple made it 
so squirrely, but really, the entire point of my subclass was to make it 
possible to do something like  the following.

CGPathRef   bezelPath   = some arbitrary path

layer.bezelAnimationStop;
layer.bezelPath = bezelPath;
layer.bezelAnimationStart;

I saw mention of something called CAShapeLayer in the 10.6 release notes. 
Maybe I'll give that a shot when my patience returns.

Thanks again

-Ken



___

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

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

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

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


Re: This code is leaking...

2011-06-19 Thread Jens Alfke

On Jun 19, 2011, at 7:29 AM, Tony Cate wrote:

 bitmapImageRep is leaking.

Actually it looks like thisImage is what’s leaking (and the imageReps leak too 
because they’re retained by it.) You initialize thisImage from a +new call 
(which is shorthand for alloc+init), but you don’t autorelease it before 
returning it.

 Why is the retain count 2 after the initWithData:? Should I file a bug?

Probably because during its initialization process something retained it and 
then autoreleased it. That shouldn’t matter to you, it’s an implementation 
detail. If you want to figure out where leaks come from, use the ‘leaks’ tool 
or Instruments.

—Jens

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: Automatically mirroring folders

2011-06-19 Thread Greg Guerin

Leonardo wrote:

2) During the period of time the stream is off, if some new files  
arrive

within the folder /A, I lose the notification to copy it.

How to workaround that?



Make a directory adjacent to /A and /B to use as a staging area for  
copying.  Only copy into the staging area.


http://en.wikipedia.org/wiki/Staging_area

When the copying of a file is complete, get its inode number.  Then  
rename the copy from the staging area into the actual target folder.   
After the copying is complete, and the rename is ready to occur,  
ignore all events that have the file's inode number.


  -- GG

___

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

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

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

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


Re: Release a NSWindowController after the window is closed

2011-06-19 Thread Roland King
How about adding an instance variable to your window controller subclass which 
keeps a strong reference to itself. Also register as your own delegate, and nil 
the strong reference in your windowWillClose: (or perhaps windowDidClose:)

Effectively you now have your delegate (yourself) retaining the thing to which 
it is a delegate, which isn't unusual. 

On 20-Jun-2011, at 3:35 AM, Marc Respass wrote:

 Hi Brian,
 
 The technique that I have been using for a long time is to alloc/init the 
 window controller, make the window controller the delegate of the window, and 
 invoke [self autorelease] in windowWillClose:. It's essentially the same 
 thing you are doing with less code.
 
 The thing that I love about this technique is that my window is now 
 completely independent. If it's a window used as a sheet, I may have many 
 different objects using it. Simply closing the window cleans up everything.
 
 As others have pointed out, this technique is incompatible with ARC. There 
 are two ways around that. I would like to know what others think about them. 
 One solution is to create a static NSMutableSet in the window controller that 
 holds all instances of that window controller. In -init, you can do 
 [windowControllerSet__ addObject:self]; and in windowWillClose: you invoke 
 [windowControllerSet__ removeObject:self];. Of course windowControllerSet__ 
 is static so it lives for the life of the app.
 
 Another solution would be that every object that creates an instance of your 
 window controller (though it probably works for any instance of any window 
 controller) also holds an array of those window controllers and it registers 
 to receive the windowWillClose: notification so it can remove it.
 
 As I say above, I like the independence of the window controller being up to 
 clean up after itself. It's also a lot less code. 
 
 Hope this helps
 Marc
 
 Hello.
 
 I'm building a Cocoa application and have a question about using
 window controllers. The idea is that when the user selects New from
 the File menu, an instance of MyWindowController which is a subclass
 of NSWindowController is created and a new window from MyWindow.xib is
 displayed.
 
 I'm handling the action in the application delegate. From what I have
 seen after searching around something like the following could be
 done. Once the window is displayed I don't have any reason to store a
 pointer to the window controller anymore and since I allocated it I
 also have it autoreleased before displaying the window.
 
 MyWindowController alloc] init] autorelease] showWindow:self];
 
 Since the window is released soon afterwards the window will briefly
 display on the screen and then go away. I'm using a solution where I
 retain the window controller in the -showWindow: method and let it
 release itself once it gets a windowWillClose notification.
 
 - (IBAction)showWindow:(id)sender
 {
void (^windowWillCloseHandler)(NSNotification *) = ^(NSNotification 
 *note) {
[[NSNotificationCenter defaultCenter] removeObserver:self
 name:NSWindowWillCloseNotification object:self.window];
[self release];
};
 
[self retain];
[[NSNotificationCenter defaultCenter]
 addObserverForName:NSWindowWillCloseNotification object:self.window
 queue:nil usingBlock:windowWillCloseHandler];
[super showWindow:sender];
 }
 
 Is there a better way to do this? I have searched the documentation
 and have not found anything specific on which practices to use. It
 sounds like something very basic which it should cover so maybe I'm
 just searching with the wrong terms.
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 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: How to redraw a view in slow-motion

2011-06-19 Thread Graham Cox

On 19/06/2011, at 10:46 PM, Matthias Arndt wrote:

 In a document-based app my custom view draws some thousand paths in drawRect: 
 with a good performance. Now I'd like to offer a slow-motion animation, so 
 the user can actually watch the paths being drawn (not each single one, but 
 e. g. in steps of 100 paths per sec).
 
 I though of several approaches and all of them seem to be infeasible:
 
 1. Sleeping the drawing loop in drawRect: (or make the runLoop wait for some 
 time) and use [... flushGraphics]: Freezes the GUI, as the app is 
 single-threaded
 2. Moving the drawing in a 2nd thread and then pause this one: AFAIK is 
 drawing in a second thread not allowed in Cocoa
 3. Limit the drawing loop to an increasing high bound, and setup a timer to 
 fire [self setNeedsDisplay:YES] periodically: Causes the first x paths being 
 redrawn at each animation step, resulting in a bad performance
 4. Same approach, but skipping the first x paths in the next animation step: 
 Corrupted display, e. g. while resizing in an animation
 
 I'm racking my brains over this, any suggestions?


Ken's thoughts regarding Core Animation are good ones. I've started doing some 
stuff with it only recently and have found it really good for this sort of 
thing. But I also found you need to plan your design with it in mind - it's not 
so easy to retro-fit to an existing design.

Some general comments:

1. Don't do drawing in a thread.
2. Don't put any unnecessary delays in -drawRect:
3. Don't even think about using threads for this.

Your (4) is looking like the best approach - use a timer to schedule a periodic 
update of the view, and during that update, draw only some portion of the 
content on top of what you've drawn already. That leaves the issue of view 
resizing, which you'll need to take into account. You can get notified when the 
view is resizing, and modify your update schedule to ensure that it does what 
you want - typically, it will need to flag that the background needs to be 
erased and that the objects need to be redrawn from the beginning.

So let's say you have a total number of objects needing to be drawn. You can 
also select that a smaller range of them be drawn each time. As Ken suggested, 
using NSRange is a good way to track this. So, this should give you a rough 
idea (typed into mail, untested):

@interface DelayView : NSView
{
NSRange _animationRange;// range of objects to be drawn 
at each animation frame
BOOL_needsErase;// set to YES to erase 
the view's background, must be inited to YES
}

@end

#define  OBJECTS_TO_BE_DRAWN_PER_FRAME  10  // number of objects 
drawn each frame

@implementation DelayView


- (void)drawRect:(NSRect) updateRect
{
if( _needsErase )
{
[[self backgroundColor] set];
NSRectFill( updateRect );
_needsErase = NO;
}

NSUInteger n;

for( n = _animationRange.location; n  NSMaxRange( _animationRange ); ++n )
[self drawObjectAtIndex:n];
}


- (void)timerCallback:(NSTimer*) timer
{
_animationRange.location += OBJECTS_TO_BE_DRAWN_PER_FRAME;

if( NSMaxRange( _animationRange )  [self countOfObjects])
   {
// warning: be careful about signed and unsigned arithmetic here
NSInteger len =  [self countOfObjectsToBeDrawn] - 
_animationRange.location;

if( len  0 )
 _animationRange.length = len;
else
 _animationRange.length = 0;

// after this subset has been drawn, all objects will have been drawn 
and there's no more to do for now
}

if( _animationRange.length  0 )
[self setNeedsDisplay:YES];
}


- (void)setFrame:(NSRect) frame
{
[super setFrame:frame];

_animationRange.location = 0;
_animationRange.length = OBJECTS_TO_BE_DRAWN_PER_FRAME; // or maybe all 
objects?
_needsErase = YES;

[self setNeedsDisplay:YES];
}



To redraw the objects from the beginning, you need to do what -setFrame: does - 
reset the range of objects to be animated and flag the erase, which clears the 
background. Then, the timer (scheduled elsewhere, not shown here), calls the 
timer callback which schedules a new chunk of objects to be drawn and so on, 
but without erasing. When all objects have been drawn, no further animation is 
performed. By setting the _animationRange.length to the total number of 
objects, and .location to 0, you can draw everything in one go without 
animation, so the same mechanism can be used for both the animated and 
non-animated case.

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

Bindings don't work with cut and paste

2011-06-19 Thread Chris Idou


I have a NSTextView's value bound to an object. I do not have Continuous 
update turned on. The binding works when I type into the field and exit the 
field. However if I *paste* text into the field, then exit the field, the 
binding set: method is never called.

What am I missing?
___

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

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

Help/Unsubscribe/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 clickable link in NSTableView

2011-06-19 Thread Rick C.
Great thanks all for pointing me in the right direction.  I'll post back if I 
have any further questions...


On Jun 20, 2011, at 12:55 AM, Lee Ann Rucker wrote:

 Look at TableViewLinks/NSAttributedStringAdditions.m in the sample code.
 
 - Original Message -
 From: Rick C. rickcort...@gmail.com
 To: Cocoa Development cocoa-dev@lists.apple.com
 Sent: Sunday, June 19, 2011 4:08:11 AM
 Subject: making a clickable link in NSTableView
 
 Hello,
 
 I currently have a NSTableView which displays a list of files and normally 
 the table view is not clickable or selectable.  In this list of files I 
 actually display the file path as a subtitle to the file name.  What I would 
 like to do is to turn that file path into a clickable link that when clicked 
 would do the equivalent of Reveal in Finder.  Ideally the file path in my 
 table view would look the way it does currently but when the mouse hovers 
 over it then the cursor would change to a hand indicating it's a link.  I'm 
 assuming I would have to turn the file path into an NSURL but could someone 
 point me in the right direction how to make all of this happen?  Thanks!
 
 rc___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com
 
 This email sent to lruc...@vmware.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


Loop between observers with KVO from UIScrollView

2011-06-19 Thread Tales Pinheiro de Andrade
Hello,

I've the following situation: I have 3 UIScrollViews in an app. The first is 
like a table (centerTable). The second a row (firstRow) and the last a column 
(firstColumn). The column must scroll only in vertical, the row only in 
horizontal and the table in any direction. And the movement must be 
synchronized between then. So, for example, if I scroll the table, the row and 
the column scrolls with the same offset.

Using KVO, I added the row and the column as observers of the contentOffset 
from table:

[centerTable addObserver:firstColumn 
forKeyPath:@contentOffsetoptions:NSKeyValueObservingOptionNew context:NULL];
[centerTable addObserver:firstRow 
forKeyPath:@contentOffsetoptions:NSKeyValueObservingOptionNew context:NULL];

And added in classes from row/column the method:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary*)change context:(void *)context {
if ([keyPath isEqualToString:@contentOffset]) {
CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
newContentOffset.y = self.contentOffset.y;
self.contentOffset = newContentOffset;
}
}

With this is almost OK, and the row/cloumn moves acordingly as table scrolls. 
But after I add the table as observer of contentOffset from row/column with:
Isso está funcionando belezinha. Mas ao adicionar a tabela como observadora da 
propriedade contentOffset da linha/coluna:

[firstColumn addObserver:centerTable 
forKeyPath:@contentOffsetoptions:NSKeyValueObservingOptionNew context:NULL];
[firstRow  addObserver:centerTable 
forKeyPath:@contentOffsetoptions:NSKeyValueObservingOptionNew context:NULL];

and implement observeValueForKeyPath:ofObject:change:context: in table class, 
whenever I try to scroll any of the UIScrollView, the program abort. I think 
that I made a loop, and when I update one of the contenOffset, the other views 
receive the message, update it self contentOffset and send the message for the 
others...

Has someone a sugestion of how to solve this?

Thank you

Tales Pinheiro___

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

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

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

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


Re: Bindings don't work with cut and paste

2011-06-19 Thread Scott Anguish
are you binding to an object controller? or just an object?

use an object controller if not.


On Jun 19, 2011, at 8:33 PM, Chris Idou wrote:

 
 
 I have a NSTextView's value bound to an object. I do not have Continuous 
 update turned on. The binding works when I type into the field and exit the 
 field. However if I *paste* text into the field, then exit the field, the 
 binding set: method is never called.
 
 What am I missing?



___

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

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

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

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


Weird behavior of -URLByAppendingPathComponent:

2011-06-19 Thread Jens Alfke
Something seems wrong with -[NSURL URLByAppendingPathComponent:] --

(gdb) po baseURL
http://127.0.0.1:5984/
(gdb) po [baseURL URLByAppendingPathComponent: @foo]
http://127.0.0.1:5984/foo
(gdb) po [baseURL URLByAppendingPathComponent: @foo/]
http://127.0.0.1:5984/foo//

Why the doubled slash at the end, in the third result? There should only be 
one. I’m not sure if doubled slashes are actually illegal in URL paths, but 
they’re certainly weird, and I’m pretty sure they’d confuse a lot of websites. 
I’m guessing this is a CF bug.

[This is on OS X 10.6.7.]

And yes, I know about +URLWithString:relativeToURL: … but that method doesn’t 
do the same thing. It only appends the string if the original URL ends with a 
“/“, otherwise it replaces the last path component. (Which is correct behavior 
for interpreting relative paths, just not what I want.)

—Jens

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: Weird behavior of -URLByAppendingPathComponent:

2011-06-19 Thread Tony Romano
I can repro that as well, and I'd say it's a bug.  I also tried this as
well:


Using:  NSURL *baseURL = [NSURL URLWithString:@http://129.0.0.1/;];

(gdb) po [baseURL URLByAppendingPathComponent: @/foo]
http://129.0.0.1//foo



according to the discussion for URLAppendingPathComponent:

If the original URL does not end with a forward slash and pathComponent
does not begin with a forward slash, a forward slash is inserted between
the two parts of the returned URL, unless the original URL is the empty
string.

It puts the slash in.


Tony Romano



On 6/19/11 9:14 PM, Jens Alfke j...@mooseyard.com wrote:

Something seems wrong with -[NSURL URLByAppendingPathComponent:] --

(gdb) po baseURL
http://127.0.0.1:5984/
(gdb) po [baseURL URLByAppendingPathComponent: @foo]
http://127.0.0.1:5984/foo
(gdb) po [baseURL URLByAppendingPathComponent: @foo/]
http://127.0.0.1:5984/foo//

Why the doubled slash at the end, in the third result? There should only
be one. I¹m not sure if doubled slashes are actually illegal in URL
paths, but they¹re certainly weird, and I¹m pretty sure they¹d confuse a
lot of websites. I¹m guessing this is a CF bug.

[This is on OS X 10.6.7.]

And yes, I know about +URLWithString:relativeToURL: Š but that method
doesn¹t do the same thing. It only appends the string if the original URL
ends with a ³/³, otherwise it replaces the last path component. (Which is
correct behavior for interpreting relative paths, just not what I want.)

‹Jens___

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

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

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

This email sent to tony...@hotmail.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: Loop between observers with KVO from UIScrollView

2011-06-19 Thread Quincey Morris
On Jun 19, 2011, at 11:59, Tales Pinheiro de Andrade wrote:

if ([keyPath isEqualToString:@contentOffset]) {
CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
newContentOffset.y = self.contentOffset.y;
self.contentOffset = newContentOffset;
}

It may be as simple as changing the above pattern to this pattern:

if ([keyPath isEqualToString:@contentOffset]) {
CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
newContentOffset.y = self.contentOffset.y;
if (!CGPointEqualToPoint (self.contentOffset, newContentOffset))
self.contentOffset = newContentOffset;
}


But note:

1. You should really check the object (at least its class) as well as the 
keyPath.

2. You should really use a context parameter that's unique for your 
observations, and call super if the context isn't what you expect.


___

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

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

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

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