Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Quincey Morris
On Jun 15, 2011, at 11:40, Brian Norh wrote:

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

I'm not sure why you're uncomfortable with your solution, at least 
uncomfortable enough to be checking for a "better" way. However, I'll offer the 
following (subjective) comments:

-- There's perhaps a very slight code smell associated with an object that 
retains itself. But in a case like this where it's very clear what's going on I 
don't think it's anything to worry about.

-- The code as written isn't compatible with GC or ARC. (In one, the 'retain' 
won't keep the window controller alive, and in the other it's illegal.) An 
alternate is to have the application delegate maintain an array of window 
controllers, a solution that's compatible with all memory management models. 
It's a trivial amount of extra code.

-- This usage case, multiple independent windows, is a little bit unusual in 
Cocoa applications. Usually it's a single window controller for the main 
window, or multiple window controllers associated with NSDocument instances. 
Note that a NSDocument instance maintains an array of window controllers for 
you, and the NSDocumentController singleton maintains an array of documents.

I mention the NSDocument case because there is some useful functionality there 
(in terms of the window title, the title bar icon, the Window menu, 
disambiguation of clashing document names, etc) that it's tedious to re-create, 
if it's appropriate to your application. It wouldn't necessarily be a silly 
idea to use the NSDocument model anyway, even if there are no actual document 
files, if there's any convergence between the NSDocument model and your 
application design.


___

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

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

Help/Unsubscribe/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-18 Thread Joar Wingfors

On 17 jun 2011, at 23.08, Ken Tozier wrote:

> There's nothing particularly kludgy about using HTML to create styled text 
> documents. The entire internet is based on it.


Kind of depends on where this document would be used though. On the Internet? 
Amazing. On the desktop? Weird!


> Once the html file is created, you can save it as RTF and any residual 
> kludgyness goes away.


That loops back to the original question though, does it not? Ie., if this 
document is really large, how would he do this HTML+CSS -> RTF conversion?


That said...


On 17 jun 2011, at 21.43, Dave DeLong wrote:

> I surely can't be the first person to want to do  this, so I ask: what have I 
> missed?  How can I generate extremely large rich-text files without having to 
> build the entire file in memory before writing it out?


Perhaps your requirements for RTF formatting are simple enough that you can 
create the document "manually", not relying on the capabilities provided by 
Cocoa / NSAttributedString? And in that case simply append to the document as 
you traverse your db. I've never looked at the RTF spec., so I've no idea how 
feasible that would be...


j o a r


___

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

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

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

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


Re: pagingEnabled on NSScrollView?

2011-06-18 Thread Quincey Morris
On Jun 17, 2011, at 04:04, Leonardo wrote:

> within the scrollToPageNum: I programmatically scroll the clipView to the
> X point = 100.
>[mDocView scrollPoint:newPoint];
>[self reflectScrolledClipView:mClipView];
>[self display];
> 
> Now I can see the page well positioned at X = 100
> Also, if I check with
>NSLog(@"scrollToPage %@", NSStringFromPoint([mClipView bounds].origin));
> everything looks ok. I get X = 100;
> 
> Now If a drag again on the trackpad, the clipView moves suddenly to the X=50
> then I can drag the page. Wrong! When setHasHorizontalScroller:YES the error
> doesn't occur.
> 
> What do I miss?

I don't know, but there are some strange things in the above code.

Why are you calling 'reflectScrolledClipView:'? It shouldn't be necessary.

Why are you calling 'display'? That seems wrong -- you should be calling 
'setNeedsDisplay:' instead. Or, more likely, not calling either of them.

Also, it looks like you're trying to do this without monitoring the clip view 
bounds- and frame-changed notifications. That's likely a problem because you're 
not entirely in control of the behavior of the clip view. Its relationship with 
the document view can change at any time, so your code isn't really working 
with full information. What you *tell* it to do isn't necessarily what it does, 
so it's better if you monitor what it actually did.

Note that if the horizontal scroll bar is enabled and is set to auto-hide, 
there may be multiple bounds/frame changes in the clip view after a single 
scroll ends.

Also note that your code may or may not be compatible with the NSClipView 
option "copiesOnScroll".

___

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

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

Help/Unsubscribe/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-18 Thread Jean-Christophe Helary

On Jun 18, 2011, at 4:15 PM, Joar Wingfors wrote:

>> I surely can't be the first person to want to do  this, so I ask: what have 
>> I missed?  How can I generate extremely large rich-text files without having 
>> to build the entire file in memory before writing it out?
> 
> 
> Perhaps your requirements for RTF formatting are simple enough that you can 
> create the document "manually", not relying on the capabilities provided by 
> Cocoa / NSAttributedString? And in that case simply append to the document as 
> you traverse your db. I've never looked at the RTF spec., so I've no idea how 
> feasible that would be...

Unless the documents involve a lot of non ascii texts, creating RTF "by hand" 
is pretty trivial. I'm using Oreilly's RTF Pocket Guive for reference for all 
the RTF formatting I need. And I think the author has a site where you can get 
the samples and see what kind of RTF coding is required.

Jean-Christophe Helary

fun: http://mac4translators.blogspot.com
work: http://www.doublet.jp (ja/en > fr)
tweets: http://twitter.com/brandelune

___

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

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

Help/Unsubscribe/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-18 Thread Ken Tozier

On Jun 18, 2011, at 3:15 AM, Joar Wingfors wrote:

> That loops back to the original question though, does it not? Ie., if this 
> document is really large, how would he do this HTML+CSS -> RTF conversion?
> 
> 

HTML documents are directly openable in Word. No conversion necessary. Write 
all the DB text in chunks to a file. Open it with Word, Text Edtit, whatever, 
Done. It's really no more difficult than that. Once it's open, it's no more 
bizarre to save it as a Word or RTF file than it is to open a Word file and 
save it as RTF. Same end point different starting points is all.

I'm certainly not the last word on this stuff, but having worked with formatted 
text, professionally, for 25 years, I can definitely say that HTML + CSS is 
rather elegant compared to Word, RTF, Quark etc as far as text formatting goes. 
It can't get much better than simple user definable style sheets which you 
apply to text with just a tag, and your data isn't locked away in some 
byzantine proprietary format. HTML blows Word away for ease of reuse and blows 
RTF away for readability. The only weirdness involved in formatting text with 
HTML is that perhaps you've never thought to do it. 

Personally, I wish Word format and RTF had died in the mid 90's. It would have 
made life much easier for programmers and users alike if HTML + CSS was the 
text formatting standard

/rant___

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

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

Help/Unsubscribe/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-18 Thread Peter Hudson
I'm not sure quite how big you data is - but I write big data sets to  
file by writing all the data into an NSTextView  - and then get the  
RTF data from the view.


There is also quite a lot of scope for combining separate RTF files.   
You can see how to do this by renaming your RTF file with a  .m   
extension and have a look at it in xCode.
Each file has a header section and a data section.  I have often taken  
one complete file and then added data from other files by stripping  
off the headers and popping it in the right place.


Peter
___

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

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

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

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


Drawing focus rings

2011-06-18 Thread Peter Hudson
I need to draw a focus ring ( or something that looks like a focus  
ring ) around a group of rows in an NSTableView.


Drawing a rectangle with NSBezierPath  works fine - how do I make it  
look like a focus ring ?


Peter
___

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

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

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

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


Re: NSString accessing characters

2011-06-18 Thread Ken Thomases
On Jun 17, 2011, at 5:35 AM, Andreas Grosam wrote:

> Thank you Ken, for your valuable tips,

You're welcome.

> On Jun 17, 2011, at 10:40 AM, Ken Thomases wrote:
> 
>> After that, maybe use CFStringInitInlineBuffer() and 
>> CFStringGetCharacterFromInlineBuffer(), although that doesn't fit with your 
>> iterator interface.  You could wrap an iterator around them easily, though.

> I don't understand the purpose of the "inline buffer" facility fully, though. 
> Is accessing a NSString's content through an inline buffer faster than 
> accessing the content of a raw pointer whose content has a known encoding?

No.  The inline buffer would be slower than either of the Get...Ptr functions.  
However, it is an optimized way of doing a conversion, as would be required 
when the Get...Ptr functions return NULL.  It converts in chunks and preserves 
state between chunks so that conversion of the next chunk can resume without 
recomputing state.  Also, it uses a fixed-size stack buffer, avoiding heap 
allocation.

Regards,
Ken

___

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

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

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

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


Re: Writing extremely large RTF or .doc files

2011-06-18 Thread Douglas Davidson
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

On Jun 17, 2011, at 10:49 PM, Dave DeLong  wrote:

> Fair enough. This is certainly a great alternative to stripping out the 
> document level attributes, but I'd still prefer the format to be as "native" 
> as possible. Using HTML like this feels a bit kludgey. 
> 
> Dave
> 
> Sent from my iPhone
> 
> On Jun 17, 2011, at 10:45 PM, Ken Tozier  wrote:
> 
>> 
>> On Jun 18, 2011, at 1:18 AM, Dave DeLong wrote:
>> 
>>> It needs to be editable after the fact.
>>> 
>>> Dave
>>> 
>> 
>> It is. If you open such a file in Word, it just looks like styled text. You 
>> can edit it and save it as html or RTF. Whichever you prefer. Try saving the 
>> following to a plain text file, open it in Word, and voila! Editable, styled 
>> text file.
>> 
>> 
>>   
>>   
>>   Word edit test
>>   
>>   
>>   .chunkHeader
>>   {
>>   font-family: Lucida Grande, Gill Sans, Arial, Helvetica, 
>> Geneva, Swiss, SunSans-Regular;
>>   font-size: 14px;
>>   font-weight: bold;
>>   }
>> 
>>   .chunkBody
>>   {
>>   font-family: Lucida Grande, Gill Sans, Arial, Helvetica, 
>> Geneva, Swiss, SunSans-Regular;
>>   font-size: 12px;
>>   font-weight: normal;
>>   }
>>
>>   
>>   
>>   Header 1
>>   Lorem ipsum dolor sit amet, consectetuer 
>> adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore 
>> magna aliquam erat volutpat.
>>   Header 2
>>   Duis autem vel eum iriure dolor in hendrerit in 
>> vulputate velit esse molestie consequat.
>>   
>> 
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
>> 
>> This email sent to davedel...@me.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/ddavidso%40apple.com
> 
> This email sent to ddavi...@apple.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: Temporarily enabling layer backing for NSView

2011-06-18 Thread Houdah - ML Pierre Bernard
Try calling -display after -setWantsLayer:

The view needs to be drawn once into the layer before being able to animate.

Another way of achieving the desired result is to draw the initial and target 
view into images and then animate the swapping of image views.

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

On Jun 18, 2011, at 6:33 AM, Indragie Karunaratne wrote:

> Super late reply here, but I just tried that and it still doesn't work. It 
> seems to work every now and then randomly but other times it doesn't work at 
> all. Sounds like some sort of timing issue.
> 
> On 2011-05-18, at 1:04 AM, Josh Abernathy wrote:
> 
>> Try doing the animation one runloop after calling -setWantsLayer:, kinda 
>> like this (typed in Mail):
>> 
>> - (void)doAnimation {
>>   [parentView setWantsLayer:YES];
>>   [self performSelector:@selector(noSeriouslyDoTheAnimation) withObject:nil 
>> afterDelay:0];
>> }
>> 
>> - (void) noSeriouslyDoTheAnimation {
>>   CATransition *transition = [CATransition animation];
>>   transition.type = kCATransitionPush;
>>   transition.subtype = kCATransitionFromLeft;
>>   transition.timingFunction = [CAMediaTimingFunction 
>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>>   [CATransaction begin];
>>   [CATransaction setCompletionBlock:^(void) {
>>  [parentView setWantsLayer:NO];
>>   }];
>>   [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>> forKey:@"subviews"]];
>>   [[parentView animator] replaceSubview:firstView with:secondView];
>>   [CATransaction commit];
>> }
>> 
>> 
>> On May 17, 2011, at 7:59 PM, Indragie Karunaratne wrote:
>> 
>>> Hi all,
>>> 
>>> I'm trying to use CATransition in my app to provide an animated slide 
>>> transition when swapping views. I don't want to permanently layer back my 
>>> views because they cause various glitches (no subpixel antialiasing, resize 
>>> issues when backed with a CATiledLayer, etc.) To get around this, I want to 
>>> temporarily layer back my view, run the animation, and then disable layer 
>>> backing after the animation completes. This is my code thus far:
>>> 
>>> CATransition *transition = [CATransition animation];
>>> transition.type = kCATransitionPush;
>>> transition.subtype = kCATransitionFromLeft;
>>> transition.timingFunction = [CAMediaTimingFunction 
>>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>>> [parentView setWantsLayer:YES];
>>> [CATransaction begin];
>>> [CATransaction setCompletionBlock:^(void) {
>>>  [parentView setWantsLayer:NO];
>>> }];
>>> [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>>> forKey:@"subviews"]];
>>> [[parentView animator] replaceSubview:firstView with:secondView];
>>> [CATransaction commit];
>>> 
>>> With this code, the animation doesn't run (the views just get swapped 
>>> without animation but the completion block is still called). The problem 
>>> seems to be the fact that I'm calling -setWantsLayer: immediately before 
>>> the animation begins. If I call this method in -awakeForNib, the animation 
>>> will run. I'm thinking that this might be some sort of runloop issue, but I 
>>> have no idea what I can do to work around this. I've tried moving my 
>>> -setWantsLayer: call to various places within the animation method but this 
>>> has no effect.
>>> 
>>> Any help is greatly appreciated.
>>> Thanks,
>>> Indragie
>>> 
>>> http://indragie.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/joshaber%40gmail.com
>>> 
>>> This email sent to josha...@gmail.com
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/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: layoutSubviews doesn't always work (iOS 4.3 on iPad Simulator)

2011-06-18 Thread Matt Neuburg
On Sun, 12 Jun 2011 14:30:42 +1000, Brian Bruinewoud  said:
>Hi All,
>
>I have an app that consists of a scroll view subclass which contains a single 
>subview. In the scroll view subclass I override layoutSubviews based on Apple 
>sample code (see below). The intention of layoutSubviews is to centre the 
>subview in the scrollview when the subview is smaller than the scrollview's 
>display area.
>
>There are three circumstances where the layoutSubviews is called but in one of 
>them the visual results are incorrect.

Funny you should mention this, since I was just experimenting with the same 
issue. What I ended up doing is setting the contentOffset explicitly after the 
zoomScale changes. 

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

m.

--
matt neuburg, phd = m...@tidbits.com, 
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: Writing extremely large RTF or .doc files

2011-06-18 Thread Charles Srstka
On Jun 17, 2011, at 11:43 PM, Dave DeLong wrote:

> Hey List,
> 
> I'm writing a little app for myself to take a database full of text and 
> format it into either a Word Document or an RTF document (either one is fine 
> for my purposes).  I've got it working for small datasets, but I'm running in 
> to performance issues when trying to generate files larger than a couple of 
> megabytes.
> 
> Ideally, I'd like to create my thousands and thousands of 
> NSAttributedStrings, convert them to NSData objects, and stream them out to 
> disk.  Unfortunately, the APIs in AppKit require me to build a single 
> NSAttributedString and convert it into an NSData all at once; no streaming is 
> possible.  For my purposes, this is impractical because of the memory 
> implications of keeping tens of thousands of NSAttributedStrings alive for 
> the duration of the generation process.
> 
> The only thought I had to work around this was to generate my RTF data and 
> strip out the document-level attributes before streaming it out to disk.  
> Barring a superior solution, I'll end up doing this.
> 
> I surely can't be the first person to want to do  this, so I ask: what have I 
> missed?  How can I generate extremely large rich-text files without having to 
> build the entire file in memory before writing it out?

Have you considered breaking this file up into a series of smaller files 
instead? If the flie is sufficiently large that it is impractical to hold it 
all in memory while writing it, you may just end up causing problems for 
applications that load the entire file into memory while *reading* it (as, I 
believe, TextEdit does).

Charles___

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

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

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

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


Re: So... we can't use UIWebView (with a delegate) on a page that's pushed onto a UINavigationController stack?

2011-06-18 Thread Matt Neuburg
>"Important: Before releasing an instance of UIWebView for which you
>have set a delegate, you must first set the UIWebView delegate
>property to nil before disposing of the UIWebView instance. This can
>be done, for example, in the dealloc method where you dispose of the
>UIWebView."
>
>The delegate for the UIWebView is set up in the XIB file; it's pretty
>hokey to have to intervene in code to then disassociate the view from
>its delegate.  Also, there is no "dealloc method where you dispose of
>the UIWebView", because that's done automatically when the view is
>popped off the navigation stack.

What I do is start with a UIViewController subclass that creates the UIWebView 
in viewDidLoad and disposes of it in dealloc, setting the delegate to nil 
first, just as suggested in the docs. It's not clear to me why creating the 
UIWebView in the nib would make any difference. m.

--
matt neuburg, phd = m...@tidbits.com, 
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: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Wed, Jun 15, 2011 at 11:40 AM, Brian Norh  wrote:
> 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.

This general pattern will fail under ARC (yay, we can talk about that
now). Since you're not storing the object into a strong reference, it
will be immediately deallocated. And it's reasonable to think that in
the future you might want to message the window controller from your
app delegate. So why not keep an instance variable in your app
delegate that points to the window controller, or perhaps to an array
of such window controllers. In your window controller's
-windowWillClose implementation, your window controller can call back
to the app delegate, telling it that it's going away.

It's essentially the same delegate/owner pattern you see all over the
place in Cocoa, except the window controller doesn't need a weak
pointer to the app delegate because it cal always get at it by calling
[NSApp delegate].

>
> 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];
> }

NSWindow automatically signs its delegate up for
NSWindowWillCloseNotification. In 99.99% of cases, you're going to
want your window controller to also be your window's delegate. So you
shouldn't have to do this yourself.

Even if you were to do this yourself, -windowDidLoad would be a more
appropriate place than -showWindow: to set up this observer.

--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: Drawing focus rings

2011-06-18 Thread Lee Ann Rucker
>From the sample code in ClockControl.m :

 // If we have focus, draw a focus ring around the entire cellFrame (inset it a 
little so it looks nice).
if ([self showsFirstResponder]) {
// showsFirstResponder is set for us by the NSControl that is drawing us.
NSRect focusRingFrame = clockRect;
focusRingFrame.size.height -= 2.0;
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame,4,4)] fill];
[NSGraphicsContext restoreGraphicsState];
}

- Original Message -
From: "Peter Hudson" 
To: cocoa-dev@lists.apple.com
Sent: Saturday, June 18, 2011 3:32:49 AM
Subject: Drawing focus rings

I need to draw a focus ring ( or something that looks like a focus  
ring ) around a group of rows in an NSTableView.

Drawing a rectangle with NSBezierPath  works fine - how do I make it  
look like a focus ring ?

Peter
___

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

Please do not post admin requests or moderator comments to the list.
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: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Sat, Jun 18, 2011 at 10:09 AM, Kyle Sluder  wrote:
> It's essentially the same delegate/owner pattern you see all over the
> place in Cocoa, except the window controller doesn't need a weak
> pointer to the app delegate because it cal always get at it by calling
> [NSApp delegate].

Actually, I just realized that it's not quite the same as
delegate/owner, for one important reason: in this scenario, the
"delegate object" (the window controller) is nilling out its own
strong reference from the "owner object" (the app delegate). That
means the window controller is likely to be deallocated right in the
middle of -windowWillClose.

One solution under non-ARC would be to call [self retain] and [self
autorelease] from inside -windowWillClose. We take that approach in a
few places, but it smells worse than your original solution. I also
have no idea how you would mimic that pattern under ARC. "__strong id
holdMe = self"?

Another option would be to delay-perform the release of your window
controller. That feels hackish.

NSDocument certainly needs to handle this scenario somehow. According
to the -[NSDocument addWindowController:] documentation, "To remove a
window controller from the list of active controllers, send it the
NSWindowController message close." That implies that
NSWindowController is in charge of removing itself from the document's
list of window controllers. My instinct is that they do the [self
retain] / [self autorelease] dance.

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


Retrieve NSTable DataSource from AppController

2011-06-18 Thread Kevin Muldoon
Basic stuff, I'm sure, but I'm stumped after several hours of googling...

I have an NSTable which receives its dataSource from MyTableController.m. 
However, my AppController.m needs the data MyTableController.m holds. Since 
AppController.m hasn't explicitly instantiated MyTableController 
(MyTableController being an NSObject within IB with appropriate delegates and 
such) how does AppController.m access MyTableController.m data? Thanks for the 
help.

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDataSource.html#//apple_ref/doc/uid/2117-BBCBHIJJ

Kevin Muldoon
e: caoimgh...@gmail.com

___

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

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

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

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


Re: Drawing focus rings

2011-06-18 Thread Tony Romano
You will need this as well.

- (BOOL) resignFirstResponder
{
 ...
 // Invalidate the area around the focus ring
 [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
 ...
}


Tony Romano



On 6/18/11 10:19 AM, "Lee Ann Rucker"  wrote:

>>From the sample code in ClockControl.m :
>
> // If we have focus, draw a focus ring around the entire cellFrame
>(inset it a little so it looks nice).
>if ([self showsFirstResponder]) {
>// showsFirstResponder is set for us by the NSControl that is drawing
>us.
>NSRect focusRingFrame = clockRect;
>focusRingFrame.size.height -= 2.0;
>[NSGraphicsContext saveGraphicsState];
>NSSetFocusRingStyle(NSFocusRingOnly);
>[[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame,4,4)]
>fill];
>[NSGraphicsContext restoreGraphicsState];
>}
>
>- Original Message -
>From: "Peter Hudson" 
>To: cocoa-dev@lists.apple.com
>Sent: Saturday, June 18, 2011 3:32:49 AM
>Subject: Drawing focus rings
>
>I need to draw a focus ring ( or something that looks like a focus
>ring ) around a group of rows in an NSTableView.
>
>Drawing a rectangle with NSBezierPath  works fine - how do I make it
>look like a focus ring ?
>
>Peter
>___
>
>Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>Please do not post admin requests or moderator comments to the list.
>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/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: Retrieve NSTable DataSource from AppController

2011-06-18 Thread Quincey Morris
On Jun 18, 2011, at 10:43, Kevin Muldoon wrote:

> I have an NSTable which receives its dataSource from MyTableController.m. 
> However, my AppController.m needs the data MyTableController.m holds. Since 
> AppController.m hasn't explicitly instantiated MyTableController 
> (MyTableController being an NSObject within IB with appropriate delegates and 
> such) how does AppController.m access MyTableController.m data?

Well, you're torturing the MVC paradigm, and it's fighting back.

A data source is a delegate-style object, but it's not really intended to 
"contain" the data. The data source extends the behavior of a controller 
object; the data should be in a data model. It's certainly *permissible* to 
merge the two, but that's for the case where the controller is the only thing 
that needs the data -- which isn't this case.

As a generic problem, though, it's not that hard. If object A creates object B 
which creates object C, and object A needs to access object C, then clearly B 
must have a public interface that returns a pointer to C. In other words, 
object B should have a property whose value is a pointer to C.

But based on your description, don't use this solution in this case. Create an 
actual data model.___

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

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

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

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


Re: Branch: Drawing noise in Cocoa (preferably fast)

2011-06-18 Thread Seth Willits
On Jun 17, 2011, at 7:29 PM, Ken Tozier wrote:

> Keying off Stephen's idea of drawing noise quickly, I came up with a solution 
> that I can use for my own purposes. It seems like splitting up large image 
> manipulations for execution on different processor cores could be a good 
> introduction to GCD and blocks. I read the intro to GCD docs but am still a 
> little in the dark about the whole topic. For example, say I'm using the 
> following method to generate 10,000 x 10,000 or 50,000 x 50,000 pixel images, 
> how would I go about "blockifying" it for GCD? 


Use dispatch_apply to replace main loop. Use the iteration parameter to the 
block to determine which chunk of memory you should be writing to. The block 
does the noise generation of pixels starting at basePtr + (totalPixels / 
iterations) * iteration.

dispatch_apply(size_t iterations, dispatch_queue_t queue, void 
(^block)(size_t));


--
Seth Willits



___

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

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

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

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


Re: Retrieve NSTable DataSource from AppController

2011-06-18 Thread Greg Guerin

Kevin Muldoon wrote:

I have an NSTable which receives its dataSource from  
MyTableController.m. However, my AppController.m needs the data  
MyTableController.m holds. Since AppController.m hasn't explicitly  
instantiated MyTableController (MyTableController being an NSObject  
within IB with appropriate delegates and such) how does  
AppController.m access MyTableController.m data? Thanks for the help.



How many MyTableController instances will there be at once?

If it's one, then you can use a Singleton pattern rooted in  
AppController.  Simply make AppController own and manage the data  
source object (i.e. the Model for the table's View).  AppController  
is already a singleton (presumably), so giving it the responsibility  
for other application-wide singletons isn't crazy.  MyTableController  
then calls on the single AppController instance to obtain the data  
source object.


If there are multiple MyTableController instances at once, then you  
can have them register themselves with the single AppController when  
they are opened, and also unregister when closed.  AppController  
maintains a collection of these, and depending on which table data  
source it wants, uses some mechanism to identify the corresponding  
MyTableController.  An example mechanism might be sequence number (1,  
2, 3), name, etc. stored as keys in a dictionary, where the value is  
the MyTableController instance.


You can use the register/unregister approach if there's a single  
MyTableController, too, but it's more complex, and there's no need  
when a perfectly good Singleton relationship will work.


  -- 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: Temporarily enabling layer backing for NSView

2011-06-18 Thread Indragie Karunaratne
Calling -display fixed the problem, works perfectly. Thanks!

On 2011-06-18, at 9:25 AM, Houdah - ML Pierre Bernard wrote:

> Try calling -display after -setWantsLayer:
> 
> The view needs to be drawn once into the layer before being able to animate.
> 
> Another way of achieving the desired result is to draw the initial and target 
> view into images and then animate the swapping of image views.
> 
> Best,
> Pierre Bernard
> Houdah Software s.à r.l.
> 
> On Jun 18, 2011, at 6:33 AM, Indragie Karunaratne wrote:
> 
>> Super late reply here, but I just tried that and it still doesn't work. It 
>> seems to work every now and then randomly but other times it doesn't work at 
>> all. Sounds like some sort of timing issue.
>> 
>> On 2011-05-18, at 1:04 AM, Josh Abernathy wrote:
>> 
>>> Try doing the animation one runloop after calling -setWantsLayer:, kinda 
>>> like this (typed in Mail):
>>> 
>>> - (void)doAnimation {
>>>  [parentView setWantsLayer:YES];
>>>  [self performSelector:@selector(noSeriouslyDoTheAnimation) withObject:nil 
>>> afterDelay:0];
>>> }
>>> 
>>> - (void) noSeriouslyDoTheAnimation {
>>>  CATransition *transition = [CATransition animation];
>>>  transition.type = kCATransitionPush;
>>>  transition.subtype = kCATransitionFromLeft;
>>>  transition.timingFunction = [CAMediaTimingFunction 
>>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>>>  [CATransaction begin];
>>>  [CATransaction setCompletionBlock:^(void) {
>>> [parentView setWantsLayer:NO];
>>>  }];
>>>  [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>>> forKey:@"subviews"]];
>>>  [[parentView animator] replaceSubview:firstView with:secondView];
>>>  [CATransaction commit];
>>> }
>>> 
>>> 
>>> On May 17, 2011, at 7:59 PM, Indragie Karunaratne wrote:
>>> 
 Hi all,
 
 I'm trying to use CATransition in my app to provide an animated slide 
 transition when swapping views. I don't want to permanently layer back my 
 views because they cause various glitches (no subpixel antialiasing, 
 resize issues when backed with a CATiledLayer, etc.) To get around this, I 
 want to temporarily layer back my view, run the animation, and then 
 disable layer backing after the animation completes. This is my code thus 
 far:
 
 CATransition *transition = [CATransition animation];
 transition.type = kCATransitionPush;
 transition.subtype = kCATransitionFromLeft;
 transition.timingFunction = [CAMediaTimingFunction 
 functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
 [parentView setWantsLayer:YES];
 [CATransaction begin];
 [CATransaction setCompletionBlock:^(void) {
 [parentView setWantsLayer:NO];
 }];
 [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
 forKey:@"subviews"]];
 [[parentView animator] replaceSubview:firstView with:secondView];
 [CATransaction commit];
 
 With this code, the animation doesn't run (the views just get swapped 
 without animation but the completion block is still called). The problem 
 seems to be the fact that I'm calling -setWantsLayer: immediately before 
 the animation begins. If I call this method in -awakeForNib, the animation 
 will run. I'm thinking that this might be some sort of runloop issue, but 
 I have no idea what I can do to work around this. I've tried moving my 
 -setWantsLayer: call to various places within the animation method but 
 this has no effect.
 
 Any help is greatly appreciated.
 Thanks,
 Indragie
 
 http://indragie.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/joshaber%40gmail.com
 
 This email sent to josha...@gmail.com
>>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/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%40

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Matt Neuburg

On Jun 18, 2011, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Date: Sat, 18 Jun 2011 10:09:13 -0700
> From: Kyle Sluder 
> Subject: Re: Release a NSWindowController after the window is closed

> This general pattern will fail under ARC (yay, we can talk about that
> now). 

Why are we able to do that? m.
___

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

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

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

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


Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Greg Guerin

Matt Neuburg wrote:


Why are we able to do that? m.



Because ARC is public knowledge:

http://clang.llvm.org/docs/AutomaticReferenceCounting.html

  -- 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: Tab Bar iPad App With Table View (Please help, been trying all day)

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

On 6/17/11 6:11 PM, Julie Seif wrote:
> Hi,
> 
> I want to create a Tab Bar based iPad App. I would like it so that you tap
> on one of the tab bar buttons and a Table View comes up in the view area for
> that button as a Navigation Menu, you would tap the table cell to get to
> whatever media/etc is attached to that cell in the table. (Imagine the Apple
> Inc. iPhone Music app, the way the tab bar and the table is set up for that)
> 
> How would I go about doing this? (Note: I'm an absolute newbie)

Welcome to the iOS world!

> I do not have any idea how to produce a tab bar application that does this.
> Any help would be appreciated, I've been trying all day.

First off, when posting to the list it is good practice (and will yield
better responses) to specify what you have tried.  Except for fairly
esoteric questions that will pull in specialized knowledge from one or
more list members, you are unlikely to get a helpful answer if you just
ask "how do I do this?"

That said, could you clarify what aspect of this is challenging?  As I
see it, there are two essential components to what you are trying:
creating a UITableView (likely via a UITableViewController or as part of
a UINavigationController) that will serve as the menu, and inserting it
into a UITabBarController.

If you are totally new to this I recommend getting an intro book and
doing some of the example projects to start; I learned from Jeff
LaMarche's original iPhone text, but frequent list contributor Matt
Neuburg also has a new book out from O'Reilly that seems to be getting
good press (and I'm sure he'd appreciate the sale).

If you have specific questions, please post them.

Good luck!

- -- 
Conrad Shultz

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

iD8DBQFN/RZmaOlrz5+0JdURAsZWAJ9H1qhD1kX35U4RZfUM4NkQc4bKNACeNk0v
Vk7S/ZemH3oFoY8hn1naY7c=
=2KOA
-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: Release a NSWindowController after the window is closed

2011-06-18 Thread Evadne Wu
For http://clang.llvm.org/docs/AutomaticReferenceCounting.html isn’t under any 
NDA.  We should indeed be able to talk about that. :)

-ev

On Jun 19, 2011, at 03:27, Matt Neuburg wrote:

> 
> On Jun 18, 2011, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
>> Date: Sat, 18 Jun 2011 10:09:13 -0700
>> From: Kyle Sluder 
>> Subject: Re: Release a NSWindowController after the window is closed
> 
>> This general pattern will fail under ARC (yay, we can talk about that
>> now). 
> 
> Why are we able to do that? m.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/ev%40monoceroi.com
> 
> This email sent to e...@monoceroi.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: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Jun 18, 2011, at 12:27 PM, Matt Neuburg  wrote:

> 
> On Jun 18, 2011, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
>> Date: Sat, 18 Jun 2011 10:09:13 -0700
>> From: Kyle Sluder 
>> Subject: Re: Release a NSWindowController after the window is closed
> 
>> This general pattern will fail under ARC (yay, we can talk about that
>> now). 
> 
> Why are we able to do that? m.

The spec has been published on llvm.org: 
http://clang.llvm.org/docs/AutomaticReferenceCounting.html

--Kyle Sluder___

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

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

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

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


Re: layoutSubviews doesn't always work (iOS 4.3 on iPad Simulator)

2011-06-18 Thread Brian Bruinewoud
Matt,

Thanks for your response.

Actually, that didn't work for me but it did lead me to find a solution.

In my case, the scroll view's contentSize wasn't being updated correctly.
To fix it I wrote the following (translated to your names) in layoutSubviews:

sv.contentSize = v.bounds.size;

As to why its not being update correctly, I don't know. But this did fix two 
other issues I was having (and, assuming the issue is in your code too) you 
should be having- namely, when I zoomed big, the scroll view sometimes wouldn't 
let me scroll to the portions of the content that were off screen.

Could you check in your code to see if its the same issue - at least that will 
suggest some kind of bug in the frameworks/documentation rather than my code :)

Thanks,
Brian.

On 19/06/2011, at 02:05 , Matt Neuburg wrote:

> On Sun, 12 Jun 2011 14:30:42 +1000, Brian Bruinewoud  
> said:
>> Hi All,
>> 
>> I have an app that consists of a scroll view subclass which contains a 
>> single subview. In the scroll view subclass I override layoutSubviews based 
>> on Apple sample code (see below). The intention of layoutSubviews is to 
>> centre the subview in the scrollview when the subview is smaller than the 
>> scrollview's display area.
>> 
>> There are three circumstances where the layoutSubviews is called but in one 
>> of them the visual results are incorrect.
> 
> Funny you should mention this, since I was just experimenting with the same 
> issue. What I ended up doing is setting the contentOffset explicitly after 
> the zoomScale changes. 
> 
> https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p492zoomCentered
> 
> m.
> 
> --
> matt neuburg, phd = m...@tidbits.com, 
> 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: layoutSubviews doesn't always work (iOS 4.3 on iPad Simulator)

2011-06-18 Thread Matt Neuburg

On Jun 18, 2011, at 6:50 PM, Brian Bruinewoud wrote:

> Actually, that didn't work for me but it did lead me to find a solution.

Cool!

> 
> In my case, the scroll view's contentSize wasn't being updated correctly.
> To fix it I wrote the following (translated to your names) in layoutSubviews:
> 
>   sv.contentSize = v.bounds.size;


Hmm. Not sure why that should be necessary. The contentSize should not *need* 
any updating; you should set it once at the outset, and then when you zoom, the 
zoomable view is transformed and everything just follows as a matter of course. 
The scroll view compensates in accordance with the transform, automatically. I 
don't quite get why you're needing to do this.

> 
> As to why its not being update correctly, I don't know. But this did fix two 
> other issues I was having (and, assuming the issue is in your code too) you 
> should be having- namely, when I zoomed big, the scroll view sometimes 
> wouldn't let me scroll to the portions of the content that were off screen.
> Could you check in your code to see if its the same issue

Well, no, clearly not. If you download and run the project I pointed you to, 
you'll see there's no problem about scrolling to the offscreen portions of the 
image when it's zoomed large. m.



> 
> On 19/06/2011, at 02:05 , Matt Neuburg wrote:
> 
>> On Sun, 12 Jun 2011 14:30:42 +1000, Brian Bruinewoud  
>> said:
>>> Hi All,
>>> 
>>> I have an app that consists of a scroll view subclass which contains a 
>>> single subview. In the scroll view subclass I override layoutSubviews based 
>>> on Apple sample code (see below). The intention of layoutSubviews is to 
>>> centre the subview in the scrollview when the subview is smaller than the 
>>> scrollview's display area.
>>> 
>>> There are three circumstances where the layoutSubviews is called but in one 
>>> of them the visual results are incorrect.
>> 
>> Funny you should mention this, since I was just experimenting with the same 
>> issue. What I ended up doing is setting the contentOffset explicitly after 
>> the zoomScale changes. 
>> 
>> https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p492zoomCentered
>> 
>> m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: layoutSubviews doesn't always work (iOS 4.3 on iPad Simulator)

2011-06-18 Thread Brian Bruinewoud
Hi Matt,

My code is based on Apple's sample "ZoomingPDFViewer" which actually replaces 
the content view after each zoom so that the contents can be drawn crisply 
rather than blurily scaled. So, this would be an issue in their code, then, but 
they only have pinching for rescaling, not zoom-to gestures. Or, perhaps, I 
copied the code incompletely - I'll re-check. Either way, it seems from your 
comment that I should then be able to move the code snippet below to the 
location where the view is replaced.

Further, I'm no longer sure that I need to do the view swapping that Apple's 
code did - I could probably get away with resizing the original view directly. 
I'll try that later.

As for scrolling when zoomed large - this issue only happened occasionally but 
it seems to be gone now.

Anyway, now that we're both happy, I wonder why you need the setContentOffset 
code while I (it seems so far) do not.

Regards,
Brian.

On 19/06/2011, at 13:24 , Matt Neuburg wrote:

> 
> On Jun 18, 2011, at 6:50 PM, Brian Bruinewoud wrote:
> 
>> Actually, that didn't work for me but it did lead me to find a solution.
> 
> Cool!
> 
>> 
>> In my case, the scroll view's contentSize wasn't being updated correctly.
>> To fix it I wrote the following (translated to your names) in layoutSubviews:
>> 
>>  sv.contentSize = v.bounds.size;
> 
> 
> Hmm. Not sure why that should be necessary. The contentSize should not *need* 
> any updating; you should set it once at the outset, and then when you zoom, 
> the zoomable view is transformed and everything just follows as a matter of 
> course. The scroll view compensates in accordance with the transform, 
> automatically. I don't quite get why you're needing to do this.
> 
>> 
>> As to why its not being update correctly, I don't know. But this did fix two 
>> other issues I was having (and, assuming the issue is in your code too) you 
>> should be having- namely, when I zoomed big, the scroll view sometimes 
>> wouldn't let me scroll to the portions of the content that were off screen.
>> Could you check in your code to see if its the same issue
> 
> Well, no, clearly not. If you download and run the project I pointed you to, 
> you'll see there's no problem about scrolling to the offscreen portions of 
> the image when it's zoomed large. m.
> 
> 
> 
>> 
>> On 19/06/2011, at 02:05 , Matt Neuburg wrote:
>> 
>>> On Sun, 12 Jun 2011 14:30:42 +1000, Brian Bruinewoud  
>>> said:
 Hi All,
 
 I have an app that consists of a scroll view subclass which contains a 
 single subview. In the scroll view subclass I override layoutSubviews 
 based on Apple sample code (see below). The intention of layoutSubviews is 
 to centre the subview in the scrollview when the subview is smaller than 
 the scrollview's display area.
 
 There are three circumstances where the layoutSubviews is called but in 
 one of them the visual results are incorrect.
>>> 
>>> Funny you should mention this, since I was just experimenting with the same 
>>> issue. What I ended up doing is setting the contentOffset explicitly after 
>>> the zoomScale changes. 
>>> 
>>> https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p492zoomCentered
>>> 
>>> m.
> 
> --
> matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
> pantes anthropoi tou eidenai oregontai phusei
> Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
> Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
> RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
> TidBITS, Mac news and reviews since 1990, http://www.tidbits.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


Synthesised properties and additional actions

2011-06-18 Thread Graham Cox
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?

--Graham


___

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

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

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

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


Re: Synthesised properties and additional actions

2011-06-18 Thread Dave DeLong
The instance variable is synthesized as well and has the same name as the 
property, so you should use that:

-(void)setFoo:(id)newFoo {
  if (foo != newFoo) {
[foo release];
foo = [newFoo retain];
[self doSomethingElseAsWell];
  }
}

Dave

On Jun 18, 2011, at 10:12 PM, Graham Cox 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 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?
> 
> --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/davedelong%40me.com
> 
> This email sent to davedel...@me.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-18 Thread Kyle Sluder
On Sat, Jun 18, 2011 at 10:16 PM, Dave DeLong  wrote:
> The instance variable is synthesized as well and has the same name as the 
> property, so you should use that:
>
> -(void)setFoo:(id)newFoo {
>  if (foo != newFoo) {
>    [foo release];
>    foo = [newFoo retain];
>    [self doSomethingElseAsWell];
>  }
> }

Note that if you override the setter for an atomic property, you must
also override the getter, and you are responsible for enforcing the
atomicity of the property. The compiler only recently added a check
for this.

--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: Synthesised properties and additional actions

2011-06-18 Thread Graham Cox
Thanks, I understand.

Seems to me if you are going to do this the advantages of @synthesize are 
virtually nil.

--Graham




On 19/06/2011, at 3:39 PM, Kyle Sluder wrote:

> On Sat, Jun 18, 2011 at 10:16 PM, Dave DeLong  wrote:
>> The instance variable is synthesized as well and has the same name as the 
>> property, so you should use that:
>> 
>> -(void)setFoo:(id)newFoo {
>>  if (foo != newFoo) {
>>[foo release];
>>foo = [newFoo retain];
>>[self doSomethingElseAsWell];
>>  }
>> }
> 
> Note that if you override the setter for an atomic property, you must
> also override the getter, and you are responsible for enforcing the
> atomicity of the property. The compiler only recently added a check
> for this.
> 
> --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: Synthesised properties and additional actions

2011-06-18 Thread Dave DeLong
For the most part, yes.  You may keep it around if your property is readwrite 
and you don't want to write the setter yourself as well.  :)

Dave

On Jun 18, 2011, at 10:43 PM, Graham Cox wrote:

> Thanks, I understand.
> 
> Seems to me if you are going to do this the advantages of @synthesize are 
> virtually nil.
> 
> --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