Re: NSUserInterfaceItemIdentification -identifier vs -tag

2013-10-09 Thread jonat...@mugginsoft.com

On 9 Oct 2013, at 05:32, Keary Suska  wrote:

> On Oct 8, 2013, at 3:25 PM, Lee Ann Rucker wrote:
> 
>> 
>> On Oct 8, 2013, at 1:59 PM, jonat...@mugginsoft.com wrote:
 

 
>>> -tag and -identifier both have the advantage of being accessible from 
>>> within IB.
>>> 
>>> J
>> 
>> Any simple object can be assigned to a variable in IB, just set them in User 
>> Defined Runtime Attributes in the 3rd tab.
> 
Thanks. I had forgotten about that.
representedObject can be set this way to a plist type on NSCell instances.

It would be possible to define an NSObject category property, say 
-myObjectName, backed by objc_setAssociatedObject and set that as a runtime 
attribute.
Likely overkill. 
> 
> I would also add that tags and identifiers are "dumb" values--that is they 
> have no intrinsic significance and can be used any way you like (IMHO). I 
> think identifiers are better than tags as they lend themselves to be more 
> human-manageable and have a level of uniqueness enforced Unlike tags,
The readability and uniqueness of -identifier are attractive. -identifier is 
never(? - so far) nil so user code that utilises it should be able to deal with 
the auto generated values such as "_NS.154".

> however, there isn't a way (yet, that I know of) to reference a view by its 
> identifier.
NSView implements NSUserInterfaceItemIdentification and this property can be 
set in Xcode 5 for a custom view.

NSMenuItem also implements NSUserInterfaceItemIdentification but Xcode 5 
doesn't provide direct access to this property.
This would mean a different approach for menu and toolbar actions.

It looks as if plain old -tag might win out after all.

J
___

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

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

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

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

Re: NSUserInterfaceItemIdentification -identifier vs -tag

2013-10-09 Thread dangerwillrobinsondanger
I lean toward tags as you can keep the speed of switch-case statements and use 
the macro NS_ENUM to define them out as human readable in code and to get code 
completion. 

String comparisons would be slightly slower. 

I think of the identifier as being more useful in caveman debugging. 

Sent from my iPhone

> On 2013/10/09, at 5:59, "jonat...@mugginsoft.com"  
> wrote:
> 
>> On 8 Oct 2013, at 21:54, Lee Ann Rucker  wrote:
>> 
>> 
>>> On Oct 8, 2013, at 1:47 PM, jonat...@mugginsoft.com wrote:
>>> 
>>> The NSControl -tag property can be used to identify an action sender.
>>> 
>>> Can the NSUserInterfaceItemIdentification protocol property -identifier be 
>>> safely used for the same purpose?
>> 
>> I don't know, but I'd prefer representedObject for something like that - 
>> it'll only be used by your code, so you don't have any restrictions to worry 
>> about.
> -tag and -identifier both have the advantage of being accessible from within 
> IB.
> 
> J
> 
> 
> 
> ___
> 
> .

___

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

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

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

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

Re: Infinite Scroll View?

2013-10-09 Thread Dave
Hi,

Got it working! The problem was partly due to tiredness and partly due to a 
misunderstanding about when layoutSubviews gets called.

If you look at the Street Scroller sample, you'll see that it has its content 
"in-built", in fact it generate new content on the fly. The problem I had was 
that the content (images in this case) needed to be loaded externally from a 
URL or from a file. Once I figured out how to get the process going it was ok 
and I did it without having to add code to the delegate which is always a good 
thing.

Thanks a lot to everyone that helped.

All the Best
Dave

On 9 Oct 2013, at 00:07, Damian Carrillo  wrote:

> Hi Dave,
> 
> What about if you have some repetition of the images? Say the following is a 
> container UIView that has all of your UIImageViews stacked horizontally and 
> the width of the following view is far smaller than that of the UIScrollView 
> it's contained in. The gray areas are duplicated image views, and the the 
> white area is the "true" set of images.
> 
> 
> Say that in the previous image, the leftmost person is the first logical 
> image in your set of data. In your viewDidLoad, you could set the 
> contentOffset to the position of the first Person (ie. the leftmost white 
> edge) with something like:
> 
> - (void)viewDidLoad
> {
> CGFloat someXPos = CGRectGetWidth([pictures frame]) + 
> CGRectGetWidth([reticle frame]);
> [scrollView setContentOffset:someXPos];
> }
> 
> Then, once the user breaches the threshold value that has duplicates (the 
> gray areas), you call the following:
> 
> - (void)scrollViewDidScroll:(UIScrollView *)scrollView
> {
> [scrollView setContentOffset:someXPos animated:NO];
> }
> 
> The intent is that the scroll view snaps the container UIView back to a 
> position that contains no duplicates. The view has duplicates to account for 
> the period of time between sampling of scroll events. Note that this 
> suggestion is assuming that the images are fairly small, so that loading them 
> all doesn't cause too much memory pressure (which is what I understood from 
> earlier messages).
> 
> Damian
> 
> On Oct 8, 2013, at 4:53 PM, Dave  wrote:
> 
>> Hi,
>> 
>> Yes, I took a look, but it's not what I want to do. I have a number of 
>> variable width images, not fixed width and all the examples I've seen use 
>> pagingEnabled and have a fixed width.
>> 
>> Also the Street Scroller sample, just creates a label view on demand, which, 
>> again isn't what I want. I have (say) 20 variable width images, so I want it 
>> to scroll from image 1 to 20 and then back to 1. The samples doesn't do 
>> anything like this.
>> 
>> Thanks anyway,
>> All the Best
>> 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Keeping Scroll Views in Sync

2013-10-09 Thread Dave
Hi,

I've got a number of scroll views (A, B and C) I'm trying to keep in sync with 
each other, e.g. if the user scrolls A then I want B and C to scroll in sync 
with it. I've got this working by adding code in the scrollViewDidScroll method 
that passes the contentOffset onto the other two scroll views.

This works ok, but it is judders a bit and flickers when scrolling quickly.

This is the code:

- (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
{
if (theScrollView.tag == kScrollViewA)
{
self.scrollViewB.contentOffset = theScrollView.contentOffset;
self.scrollViewC.contentOffset = theScrollView.contentOffset;
}

else if (theScrollView.tag == kScrollViewB)
{
self.scrollViewA.contentOffset = theScrollView.contentOffset;
self.scrollViewC.contentOffset = theScrollView.contentOffset;
}
else if (theScrollView.tag == kScrollViewC)
{
self.scrollViewA.contentOffset = theScrollView.contentOffset;
self.scrollViewB.contentOffset = theScrollView.contentOffset;
}
}

I've tried a few things, but nothing seem to make a difference.

Any ideas anyone?

Thanks a lot
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Keeping Scroll Views in Sync

2013-10-09 Thread Tamas Nagy
Hi,

in one of my apps I'm doing this too, but without any problems. I'm using 
scrollToPoint: method instead.

[[NSNotificationCenter defaultCenter] addObserver:self
 
selector:@selector(viewScrolled:)
 
name:NSViewBoundsDidChangeNotification
   object:[[self 
timelineViewScrollView] contentView]];

…


-(void)viewScrolled:(NSNotification *)notification {


if ([[notification object] isEqualTo:[[self timelineViewScrollView] 
contentView]]) {


[[[self trackHelperViewScrollView] contentView] 
scrollToPoint:NSMakePoint([[[self trackHelperViewScrollView] contentView] 
bounds].origin.x, [[[self timelineViewScrollView] contentView] 
bounds].origin.y)];

[[[self markerViewScrollView] contentView] 
scrollToPoint:NSMakePoint([[[self timelineViewScrollView] contentView] 
bounds].origin.x, [[[self markerViewScrollView] contentView] bounds].origin.y)];


} else

.
.
.
.

Cheers,
Tamas

On Oct 9, 2013, at 3:44 PM, Dave  wrote:

> Hi,
> 
> I've got a number of scroll views (A, B and C) I'm trying to keep in sync 
> with each other, e.g. if the user scrolls A then I want B and C to scroll in 
> sync with it. I've got this working by adding code in the scrollViewDidScroll 
> method that passes the contentOffset onto the other two scroll views.
> 
> This works ok, but it is judders a bit and flickers when scrolling quickly.
> 
> This is the code:
> 
> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
> {
> if (theScrollView.tag == kScrollViewA)
>   {
>   self.scrollViewB.contentOffset = theScrollView.contentOffset;
>   self.scrollViewC.contentOffset = theScrollView.contentOffset;
>   }
> 
> else if (theScrollView.tag == kScrollViewB)
>   {
>   self.scrollViewA.contentOffset = theScrollView.contentOffset;
>   self.scrollViewC.contentOffset = theScrollView.contentOffset;
>   }
> else if (theScrollView.tag == kScrollViewC)
>   {
>   self.scrollViewA.contentOffset = theScrollView.contentOffset;
>   self.scrollViewB.contentOffset = theScrollView.contentOffset;
>   }
> }
> 
> I've tried a few things, but nothing seem to make a difference.
> 
> Any ideas anyone?
> 
> Thanks a lot
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/tamas.lov.nagy%40gmail.com
> 
> This email sent to tamas.lov.n...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Keeping Scroll Views in Sync

2013-10-09 Thread Damian Carrillo
Dave,

Try the following: 

- (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
{
if (theScrollView.tag == kScrollViewA)
{
[self.scrollViewB setContentOffset:theScrollView.contentOffset 
animated:NO];
[self.scrollViewC setContentOffset:theScrollView.contentOffset 
animated:NO];
}
else if (theScrollView.tag == kScrollViewB)
{
[self.scrollViewA setContentOffset:theScrollView.contentOffset 
animated:NO];
[self.scrollViewC setContentOffset:theScrollView.contentOffset 
animated:NO];
}
else if (theScrollView.tag == kScrollViewC)
{
[self.scrollViewA setContentOffset:theScrollView.contentOffset 
animated:NO];
[self.scrollViewB setContentOffset:theScrollView.contentOffset 
animated:NO];
}
}

It may help.

Damian

On Oct 9, 2013, at 8:44 AM, Dave  wrote:

> Hi,
> 
> I've got a number of scroll views (A, B and C) I'm trying to keep in sync 
> with each other, e.g. if the user scrolls A then I want B and C to scroll in 
> sync with it. I've got this working by adding code in the scrollViewDidScroll 
> method that passes the contentOffset onto the other two scroll views.
> 
> This works ok, but it is judders a bit and flickers when scrolling quickly.
> 
> This is the code:
> 
> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
> {
> if (theScrollView.tag == kScrollViewA)
>   {
>   self.scrollViewB.contentOffset = theScrollView.contentOffset;
>   self.scrollViewC.contentOffset = theScrollView.contentOffset;
>   }
> 
> else if (theScrollView.tag == kScrollViewB)
>   {
>   self.scrollViewA.contentOffset = theScrollView.contentOffset;
>   self.scrollViewC.contentOffset = theScrollView.contentOffset;
>   }
> else if (theScrollView.tag == kScrollViewC)
>   {
>   self.scrollViewA.contentOffset = theScrollView.contentOffset;
>   self.scrollViewB.contentOffset = theScrollView.contentOffset;
>   }
> }
> 
> I've tried a few things, but nothing seem to make a difference.
> 
> Any ideas anyone?
> 
> Thanks a lot
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/damiancarrillo%40me.com
> 
> This email sent to damiancarri...@me.com



signature.asc
Description: Message signed with OpenPGP using GPGMail
___

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

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

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

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

Cocoaheads 92630 tonight, Wed. Oct 9 at 7pm

2013-10-09 Thread Scott Ellsworth
CocoaHeads Lake Forest will be meeting on the second Wednesday of the
month.  We will be meeting at the Orange County Public Library (El Toro)
community room, 24672 Raymond Way, Lake Forest, CA 92630.

We will be talking about Peter's ISO 8601 Date Formatter, recently updated,
and appledoc, which generates good looking documentation from
Markdown-enriched comments in header files.

Please join us from 7pm to 9pm on Wednesday
Bring laptops, code, discussion topics, etc.
As always, details can be found on the cocoaheads web site at
www.cocoaheads.org

(note: cross-post cleared with moderators previously.)
___

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

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

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

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

Re: Responder chain query

2013-10-09 Thread Seth Willits
On Oct 8, 2013, at 12:33 PM, jonat...@mugginsoft.com wrote:

>> Yup. Been doing it for years. There was some code written by Cathy Shive and 
>> Jonathan Dann to help with that called XSViewController. Don't know where 
>> the original source is now, but basically it managed a tree of view 
>> controllers by adding a parent-child relationship between view controllers, 
>> with the tree attached to the XSWindowController. VCs could easily be 
>> attached and removed from the tree and it would reconnect the responder 
>> chain correctly.
> I think this might be a version of what you are  referring to:
> https://github.com/catshive/KTUIKit/blob/master/Framework/Controllers/KTViewController.m

Hmm. The XS version is simpler. Not sure why there's some other stuff going on 
in there.


> My implementation is simpler, using a couple of category methods on NSWindow 
> to patch in my view controllers.
> However the tree implementation might be useful in future.

It's useful when you have a deep hierarchy. For instance I have the window's 
top level VC, a subVC for each tab in the window, 6 subVCs of that, each of 
those may have several subVC and on and on. When different views are shown and 
hidden, the parent VC simply calls an addChild/removeChild and it's hooked up 
in the right spot. It's not significantly different, but it is convenient.

gl,

--
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Keeping Scroll Views in Sync

2013-10-09 Thread Dave
Hi,

I should have said, this is for iOS and it doesn't look like UIScrollView has 
the scrollToPoint method defined.

There is also something about using notifications for this in a Mac Reference:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/SynchroScroll.html

But I'm not sure if this is recommended for iOS?

Thanks a lot
Dave

On 9 Oct 2013, at 14:52, Tamas Nagy  wrote:

> Hi,
> 
> in one of my apps I'm doing this too, but without any problems. I'm using 
> scrollToPoint: method instead.
> 
> [[NSNotificationCenter defaultCenter] addObserver:self
>  
> selector:@selector(viewScrolled:)
>  
> name:NSViewBoundsDidChangeNotification
>object:[[self 
> timelineViewScrollView] contentView]];
> 
> …
> 
> 
> -(void)viewScrolled:(NSNotification *)notification {
> 
> 
> if ([[notification object] isEqualTo:[[self timelineViewScrollView] 
> contentView]]) {
> 
> 
> [[[self trackHelperViewScrollView] contentView] 
> scrollToPoint:NSMakePoint([[[self trackHelperViewScrollView] contentView] 
> bounds].origin.x, [[[self timelineViewScrollView] contentView] 
> bounds].origin.y)];
> 
> [[[self markerViewScrollView] contentView] 
> scrollToPoint:NSMakePoint([[[self timelineViewScrollView] contentView] 
> bounds].origin.x, [[[self markerViewScrollView] contentView] 
> bounds].origin.y)];
> 
> 
> } else
> 
> .
> .
> .
> .
> 
> Cheers,
> Tamas
> 
> On Oct 9, 2013, at 3:44 PM, Dave  wrote:
> 
>> Hi,
>> 
>> I've got a number of scroll views (A, B and C) I'm trying to keep in sync 
>> with each other, e.g. if the user scrolls A then I want B and C to scroll in 
>> sync with it. I've got this working by adding code in the 
>> scrollViewDidScroll method that passes the contentOffset onto the other two 
>> scroll views.
>> 
>> This works ok, but it is judders a bit and flickers when scrolling quickly.
>> 
>> This is the code:
>> 
>> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
>> {
>> if (theScrollView.tag == kScrollViewA)
>>  {
>>  self.scrollViewB.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewC.contentOffset = theScrollView.contentOffset;
>>  }
>> 
>> else if (theScrollView.tag == kScrollViewB)
>>  {
>>  self.scrollViewA.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewC.contentOffset = theScrollView.contentOffset;
>>  }
>> else if (theScrollView.tag == kScrollViewC)
>>  {
>>  self.scrollViewA.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewB.contentOffset = theScrollView.contentOffset;
>>  }
>> }
>> 
>> I've tried a few things, but nothing seem to make a difference.
>> 
>> Any ideas anyone?
>> 
>> Thanks a lot
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/tamas.lov.nagy%40gmail.com
>> 
>> This email sent to tamas.lov.n...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Keeping Scroll Views in Sync

2013-10-09 Thread Dave
Hi,

This works really well, but of course there is no inertia/deceleration which 
feels a bit strange and I'm willing to bet marketing won't like it!

I'm still playing about trying to get it to work. When you couple this with the 
Infinite Scroll View I've been working on, you get some very interesting 
results!!

Thanks a lot
Dave

On 9 Oct 2013, at 16:29, Damian Carrillo  wrote:

> Dave,
> 
> Try the following: 
> 
> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
> {
> if (theScrollView.tag == kScrollViewA)
>   {
>   [self.scrollViewB setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   [self.scrollViewC setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   }
> else if (theScrollView.tag == kScrollViewB)
>   {
>   [self.scrollViewA setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   [self.scrollViewC setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   }
> else if (theScrollView.tag == kScrollViewC)
>   {
>   [self.scrollViewA setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   [self.scrollViewB setContentOffset:theScrollView.contentOffset 
> animated:NO];
>   }
> }
> 
> It may help.
> 
> Damian
> 
> On Oct 9, 2013, at 8:44 AM, Dave  wrote:
> 
>> Hi,
>> 
>> I've got a number of scroll views (A, B and C) I'm trying to keep in sync 
>> with each other, e.g. if the user scrolls A then I want B and C to scroll in 
>> sync with it. I've got this working by adding code in the 
>> scrollViewDidScroll method that passes the contentOffset onto the other two 
>> scroll views.
>> 
>> This works ok, but it is judders a bit and flickers when scrolling quickly.
>> 
>> This is the code:
>> 
>> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
>> {
>> if (theScrollView.tag == kScrollViewA)
>>  {
>>  self.scrollViewB.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewC.contentOffset = theScrollView.contentOffset;
>>  }
>> 
>> else if (theScrollView.tag == kScrollViewB)
>>  {
>>  self.scrollViewA.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewC.contentOffset = theScrollView.contentOffset;
>>  }
>> else if (theScrollView.tag == kScrollViewC)
>>  {
>>  self.scrollViewA.contentOffset = theScrollView.contentOffset;
>>  self.scrollViewB.contentOffset = theScrollView.contentOffset;
>>  }
>> }
>> 
>> I've tried a few things, but nothing seem to make a difference.
>> 
>> Any ideas anyone?
>> 
>> Thanks a lot
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/damiancarrillo%40me.com
>> 
>> This email sent to damiancarri...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

NSDocument read from file, force save to different file

2013-10-09 Thread Trygve Inda
Version 1 of my app only saved it's (single container) data in
~/Library/Application Support/

Version 2 is document-based. I need to be able to load the data from the old
App Support location (which is in a different format as well). This part is
easy with a case within my readFromFileWrapper.

Once the data is rebuilt into a version-2 structure, I want the document to
open but to be disassociated with the old file in App Support so that the
user is forced to choose a new save location when it comes time to save.

How can I do this?



___

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

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

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

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

Re: NSDocument read from file, force save to different file

2013-10-09 Thread Kyle Sluder
On Wed, Oct 9, 2013, at 08:22 PM, Trygve Inda wrote:
> How can I do this?

NSDocument *untitledDoc = [[NSDocumentController
sharedDocumentController] makeDocumentForURL:nil
withContentsOfURL:oldDocURL ofType:myUTI error:&err];
if (untitledDoc) {
  [untitledDoc makeWindowControllers];
  [untitledDoc showWindows];
}

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Crash in datasource method when closing document

2013-10-09 Thread Shane Stanley
I have a document-based app, and it saves as a package. The document's window 
contains an outline view, where the user can drag items from the Finder or 
create new folders, and these will be saved to the package. I'm creating file 
wrappers of the items, stored in a property of the document. That's all working 
OK.

The problem I'm having is that if I open a file, then add an item, say a 
folder, then click the close button and choose Revert Changes, I (nearly 
always) get an exception thrown on the outline view's datasource method 
-outlineView:objectValueForTableColumn:byItem:. It doesn't happen if the 
outline view is hidden. I'm using ARC.

Any thoughts on where to start?


-- 
Shane Stanley 
'AppleScriptObjC Explored' 


___

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

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

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

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Kyle Sluder
> On Oct 9, 2013, at 10:06 PM, Shane Stanley  wrote:
> 
> The problem I'm having is that if I open a file, then add an item, say a 
> folder, then click the close button and choose Revert Changes, I (nearly 
> always) get an exception thrown on the outline view's datasource method 
> -outlineView:objectValueForTableColumn:byItem:. It doesn't happen if the 
> outline view is hidden. I'm using ARC.

A great place to start would be to actually look at and post what the exception 
says…

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Jerry Krinock

On 2013 Oct 09, at 22:06, Shane Stanley  wrote:

> click the close button and choose Revert Changes, I (nearly always) get an 
> exception thrown on the outline view's datasource method 
> -outlineView:objectValueForTableColumn:byItem:

Issues like this often crop up as soon as you try to make an app which his more 
complicated than Apple Sample Code :))

> I'm using ARC.

ARC doesn't help for KVO observers, notification observers, delegates, manual 
bindings, or data sources.  These must still be managed manually.

* * *

Here is some typical code "tear down" code.  This is for a tabbed window.  Note 
the outline view's delegate and data source being set to nil.

* In window controller implementation

- (void)windowWillClose:(NSNotification *)aNotification {
// The world WILL end.  Pull out all of the 
// power cords ASAP.

// Pull cords which are OK to pull more than once
…

if (!m_tornDown) {
   // m_tornDown = YES ;
   …

   // Pull cords which must be pulled only once
   …   
   [viewController1 tearDown]
   [viewController2 tearDown]
   …
}
}


* Typical -tearDown in view controller (tab) implementation

- (void)tearDown {
// To fix crash if Split view tries to update as window is closing.
// http://lists.apple.com/archives/cocoa-dev/2012/Aug/msg00638.html
[splitView setDelegate:nil] ;

ContentDataSource* contentDataSource = [contentOutlineView dataSource] ;
[contentDataSource setDocument:nil] ;
 
// Messaging table views' delegates and data sources after they are
// gone causes indeterminate crashes.
[contentOutlineView setDelegate:nil] ;
[contentOutlineView setDataSource:nil] ;

// Must unbind the things that we bound manually, or bad things happen
// as the window closes, for example, Core Data Burps
// like this:
// "The NSManagedObject with ID:0x16f7f2f0
//   has been invalidated."
[(StarkTableColumn*)[contentOutlineView 
tableColumnWithIdentifier:@"userDefinedC0"] unbindValue] ;
[(StarkTableColumn*)[contentOutlineView 
tableColumnWithIdentifier:@"userDefinedC1"] unbindValue]  ;
// And these other views have been seen to get valueForKey:
// and/or setValue:forKey: messages after they have been
// deallocated, causing crashes.
[detailView unbind:@"enaabled"] ;
[detailView unbind:@"tooltip"] ;
[detailView unbind:@"value"] ;
[detailView unbind:@"tokenizingCharacter"] ;
[detailView unbind:@"value"] ;
[contentOutlineView unbind:@"selectedStarkiTags"] ;

[[MAKVONotificationCenter defaultCenter] removeObserver:self] ;
[[NSNotificationCenter defaultCenter] removeObserver:self] ;
}



___

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

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

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

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Shane Stanley
On 10 Oct 2013, at 5:09 PM, Kyle Sluder  wrote:

> A great place to start would be to actually look at and post what the 
> exception says…

Yep. EXC_BAD_ACCESS (code=EXC_I386_GPFLT). It's happening on:

- (id)outlineView:(NSOutlineView *)outlineView 
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item

When I put the cursor over item, it shows a value of 0x0.

Curiously, if I add more than one item to the outline view, the problem seems 
to go away (I use "seems" advisedly, of course).

-- 
Shane Stanley 
'AppleScriptObjC Explored' 


___

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

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

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

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Shane Stanley

On 10 Oct 2013, at 5:10 PM, Jerry Krinock  wrote:

> Issues like this often crop up as soon as you try to make an app which his 
> more complicated than Apple Sample Code :))

Yep. The curious thing is I've been working on this for some time, and it's 
only just cropped up. Now it might be that I never did a revert with one folder 
like this before, but it might be something else that's changed. My first 
instinct, though, is that it's at my end.
> 
>> I'm using ARC.
> 
> ARC doesn't help for KVO observers, notification observers, delegates, manual 
> bindings, or data sources. These must still be managed manually.

Understood. I mention it to save someone asking, though.
> 
> Here is some typical code "tear down" code.  This is for a tabbed window.  
> Note the outline view's delegate and data source being set to nil.
> 
> * In window controller implementation
> 
> - (void)windowWillClose:(NSNotification *)aNotification {

One of the first things I tried was putting a breakpoint on -windowWillClose: 
The thing is, it doesn't get that far -- the breakpoint is never hit. That's 
partly why I'm unsure of where to look next.

-- 
Shane Stanley 
'AppleScriptObjC Explored' 


___

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

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

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

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Jerry Krinock

On 2013 Oct 09, at 23:33, Shane Stanley  wrote:

> One of the first things I tried was putting a breakpoint on -windowWillClose: 
> The thing is, it doesn't get that far -- the breakpoint is never hit.

In order to receive -windowWillClose:, the object implementing it must be the 
delegate of the window which is closing.


___

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

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

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

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

Re: Crash in datasource method when closing document

2013-10-09 Thread Shane Stanley

On 10 Oct 2013, at 5:39 PM, Jerry Krinock  wrote:

> In order to receive -windowWillClose:, the object implementing it must be the 
> delegate of the window which is closing.

Yes, I already had -windowWillClose: implemented in my window controller (and 
-windowShouldClose:), and it gets called fine normally. But the crash I'm 
seeing is happening before it gets to that point. Maybe this will help:

2799 Thread_5984086   DispatchQueue_1: com.apple.main-thread  (serial)
+ 2799 start  (in libdyld.dylib) + 1  [0x7fff873e35fd]
+   2799 main  (in ASObjC Explorer) + 34  [0x11d72]  main.m:13
+ 2799 NSApplicationMain  (in AppKit) + 940  [0x7fff89ca9803]
+   2799 -[NSApplication run]  (in AppKit) + 553  [0x7fff89cbe9cc]
+ 2799 -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]  (in AppKit) + 122  
[0x7fff89cca8db]
+   2799 _DPSNextEvent  (in AppKit) + 1434  [0x7fff89ccb28e]
+ 2799 _BlockUntilNextEventMatchingListInModeWithFilter  (in 
HIToolbox) + 65  [0x7fff863a8abc]
+   2799 ReceiveNextEventCommon  (in HIToolbox) + 173  
[0x7fff863a8b85]
+ 2799 RunCurrentEventLoopInMode  (in HIToolbox) + 226  
[0x7fff863a8f0d]
+   2799 CFRunLoopRunSpecific  (in CoreFoundation) + 309  
[0x7fff897e8275]
+ 2799 __CFRunLoopRun  (in CoreFoundation) + 776  
[0x7fff897e87b8]
+   2799 __CFRunLoopDoObservers  (in CoreFoundation) + 
391  [0x7fff897f7017]
+ 2799 
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__  (in 
CoreFoundation) + 23  [0x7fff897f70a7]
+   2799 __83-[NSWindow 
_postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke1331
  (in AppKit) + 46  [0x7fff8a43bcd1]
+ 2799 
_handleWindowNeedsDisplayOrLayoutOrUpdateConstraints  (in AppKit) + 884  
[0x7fff89e6789e]
+   2799 -[NSView displayIfNeeded]  (in AppKit) 
+ 1680  [0x7fff89e0263a]
+ 2799 -[NSView 
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]  (in 
AppKit) + 2828  [0x7fff89e23209]
+   2799 -[NSThemeFrame 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 314  [0x7fff89e26201]
+ 2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+   2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+ 2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+   2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+ 2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+   2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+ 2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+   2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 6151  [0x7fff89e27f0e]
+ 2799 -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  (in AppKit) + 841  [0x7fff89e26a50]
+   2799 -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:]  (in AppKit) + 2787  
[0x7fff89e28fea]
+ 2799 -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:]  (in AppKit) + 1799  
[0x7fff89e28c0e]
+   2799 -[NSView 
_drawRect:clip:]  (in AppKit) + 3748  [0x7fff89e2a399]
+ 2799 
-[NSTableView drawRect:]  (in AppKit) + 1484  [0x7fff89e514c2]
+   2799 
-[NSOutlineView drawRowIndexes:clipRect:]  (in AppKit) + 113  [0x7fff89fe2455]
+