Re: View-based outline view problem

2014-07-10 Thread Quincey Morris
On Jul 10, 2014, at 23:34 , Ken Thomases  wrote:

> Have you connected the delegate outlet of your text view (field?)?

This was my first thought, too, but:

1. The delegate method ‘control:textShouldBeginEditing:’ seems like it’s called 
too late. Presumably the selection change needs to be done when the text field 
gets first responder status, not when the text is actually changed.

2. It’s not obvious to me how the text field gets first responder status. In 
the TableViewPlayground sample code, it does, without any apparent support, so 
I assume this is something built into NSOutlineView -> NSTableViewCell -> 
textField outlet (when you press Return). I don’t know how you’d customize that 
if you have a non-standard table cell view. In particular, I don’t see how 
you’d know *when* this was happening.

I guess you could solve it with a NSTextField subclass that overrides becoming 
first responder. Or is there a more direct solution, do you think?

___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Ken Thomases
On Jul 11, 2014, at 12:54 AM, Shane Stanley  wrote:

> I'm still not quite out of the woods. In my cell-based outline view, when the 
> user selects an item and hits return to edit it, I change the selection so 
> that only the file name before the extension was selected. I do that with 
> text view delegate methods in my outline view subclass, but that doesn't work 
> with the view-based version. Is there some simple alternative?

Have you connected the delegate outlet of your text view (field?)?

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

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

Re: View-based outline view problem

2014-07-10 Thread Shane Stanley
I'm still not quite out of the woods. In my cell-based outline view, when the 
user selects an item and hits return to edit it, I change the selection so that 
only the file name before the extension was selected. I do that with text view 
delegate methods in my outline view subclass, but that doesn't work with the 
view-based version. Is there some simple alternative?

-- 
Shane Stanley 



___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Shane Stanley
On 11 Jul 2014, at 1:56 am, Quincey Morris 
 wrote:

> You are doing something basic incorrectly. That NSOutlineView delegate method 
> is called ‘outlineView:viewForTableColumn:item:’.

Sigh. Thank you for restoring my faith in my own stupidity...

-- 
Shane Stanley 



___

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

Please do not post 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: Converting database to Core Data

2014-07-10 Thread Keary Suska
On Jul 10, 2014, at 2:00 PM, William Squires wrote:

>  I'm trying to convert the following. I have two tables in a database, 
> "TransactionEntry", and "ReasonCode". A "TransactionEntry" record is just a 
> posting from a POS (Point-of-Sale) terminal, and has these fields (of 
> interest):
> 
> Table (TransactionEntry)
>  ID As Int32
>  PrimaryReasonCode As Int32   // both of these link to .ID
>  SecondaryReasonCode As Int32
>  ...
> 
> and a "ReasonCode" record is used when a certain types of transactions occur, 
> such as POSItemReturned, POSItemVoided, POSCommError, and a few others.
> 
> Table (ReasonCode)
>  ID As Int32
>  Description As Varchar(50)
>  ReasonCode As Int16 // just an enum
>  ...
> 
>  All would be good and well if the TransactionEntry table had only one 
> reference (.PrimaryReasonCode) to the ReasonCode table, but some transactions 
> (such as a voided item) require the manager to fill in both the primary and 
> secondary reason codes. I can create the entities, and replace the Int32 
> record numbers/IDs with a relationship.
>  I create the relationship in entity "TransactionEntry" and set it to 
> "ReasonCode", leaving the inverse relationship to "none" for now. I then 
> create an inverse relationship in entity "ReasonCode" to refer back to 
> "TransactionEntry". Now I can create the inverse relationships in both 
> directions. 1:1 for TransactionEntry -> ReasonCode, and 1:many for ReasonCode 
> -> TransactionEntry. All okay so far.
>  Primary ReasonCode records (entities) are re-used to save memory, and the 
> .Description fields are pre-set to values such as, "return item", "wrong key 
> hit", "cc reader not working", etc... Secondary ReasonCode entities are 
> (usually) created on-demand from the POS terminal when the manager logs in. A 
> few are re-used, but mostly new entities are created. The problem now comes 
> when I try to create the same relationships from TransactionEntry entities to 
> ReasonCode entities for the secondary reason code records (entities), since 
> it won't let me make both inverse relationships 1:many from ReasonCode back 
> to TransactionEntry.
>  Is this a limitation of CoreData? Or is there a way around this? Can I 
> ignore Xcode's warnings about not having inverse relationships, and simply 
> set the inverse relationships from the TransactionEntry entity(ies) to the 
> ReasonCode Entity to "none", and simply get rid of the inverse relationships 
> in the ReasonCode entity?

It's a limitation of Core Data. The solution is to use an intermediary entity, 
similar to a many-to-many relationship implementation. I would highly recommend 
this, as one-way relationships are fragile and prone to error.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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

Please do not post 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: Cocoa-dev Digest, Vol 11, Issue 374

2014-07-10 Thread João Varela
I am also moving all my cell-based NSOutlineView¹s and NSTableView¹s to
the corresponding view-based versions. There is a good reason for it. It
has been officially declared by Apple that cell-based NSOutlineView¹s and
NSTableView's are deprecated. So start moving your code to the newest
technologies sooner rather than later. If you don¹t now you may be out of
luck in the future. For what I could see it is not very complicated.
Actually, some of things become simpler.

HTH

João Varela

>On 10 Jul 2014, at 5:25 pm, Shane Stanley 
>wrote:
>
>>I'm trying to convert a cell-based outline view to view-based.
>
>
>Is there some good reason to change to view-based, or are you doing it
>just because it seems to be the "modern" thing? I'd say, if it ain't
>broke...
>
>I've recently gone through a large rewrite of a section of our app to use
>a view-based rather than a cell-based table, because it gives us a better
>user interface, but otherwise, given the pain and usual undocumentedness
>of it (as is usual for a new Cocoa feature), I would not have bothered
>just for fun.





___

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

Please do not post 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: Issue with -[NSOutlineView autosaveExpandedItems]

2014-07-10 Thread Ken Thomases
On Jul 10, 2014, at 3:20 PM, Bill Cheeseman  wrote:

> How can I make an outline view reinstate the expanded and collapsed state of 
> its rows across application launches?
> 
> Building in Xcode 5.1.1 under OS X 10.9.4 Mavericks, I select the outline 
> view nib file's Autosave checkbox for Autosave Expanded Items, which is 
> equivalent to calling -setAutosaveExpandedItems:YES. 
> 
> I also implement the outline view data source method 
> -outlineView:persistentObjectForItem: by returning -[NSKeyedArchiver 
> archivedDataWithRootObject:item] and the data source method 
> -outlineView:itemForPersistentObject: by returning -[NSKeyedUnarchiver 
> unarchiveObjectWithData:object]. Doing this is the only sense I can make of 
> the very cryptic reference document instructions, and this solution is echoed 
> in some of the mailing list discussions I found.
> 
> It works, up to a point. When I launch the application, NSLog calls tell me 
> that it does call -outlineView:itemForPersistentObject: at launch on the 
> archived objects for every row that I left expanded when I previously quit. I 
> see the correct archived data items in my user defaults preferences file, so 
> I know the application properly called -outlineView:persistentObjectForItem: 
> when I previously quit. The archived data items unarchive correctly to the 
> outline view items that were left expanded when I previously quit.
> 
> However, the indicated rows are not expanded at launch. Instead, all rows are 
> collapsed at launch.
> 
> Has anybody made this work? How?

Are the items that result from unarchiving the persistent object the same items 
as your data source returns via -outlineView:child:ofItem:?  I believe they 
have to be the same by pointer identity, not just equal as by -isEqual:.

Rather than archiving the item itself, you should perhaps archive uniquely 
identifying attributes of the item so that you can find the corresponding item 
among the new model and return that.

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

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

UISplitViewController - Wrong detail view sizing

2014-07-10 Thread Tino Rachui
I’m maintaining a universal iOS App whose development has started on iOS 6. I’m 
about the renew the UI for iOS 7. Now I’ve got a weird problem with the iPad 
part of the app. This part follows the „normal“ Master-Detail view pattern 
using a UISplitViewController. The UI is configured in a storyboard. The 
UISplitViewController is the root view controller as requested by Apples docs. 
Here comes the weird part: When the detail view controller is embedded in a 
UINavigationController the navigation controller will be sized incorrectly by 
the UISplitViewController and so the whole interface looks broken. It appears 
as if the navigation controller remains in portrait orientation even if the 
device orientation is landscape. In portrait orientation the detail view 
controller is looking fine though.  
If I avoid embedding the detail view controller in a navigation controller and 
connect it directly as detail view controller with the UISplitViewController 
everything is working perfectly in both orientations. 
I tried to reproduce the problem in a simple sample App based on the 
Master-Detail project template provided by Apple without luck. There it works 
even with a detail view controller embedded in a navigation controller. No 
matter what I’ve tried so far (looking for categories interfering, rotation 
settings, method swizzling etc. pp.) I couldn’t find the cause for this 
problem. As I’m running out of options (if possible I’d rather avoid rolling my 
container view controller) I respectfully ask if anybody on this list has a 
solution to this problem or further ideas on how to track down the problem.

Thanks in advance
Tino



___

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

Please do not post 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

Issue with -[NSOutlineView autosaveExpandedItems]

2014-07-10 Thread Bill Cheeseman
This question has been asked several times over the last few years, but I 
haven't found a useful answer in all the discussions.

How can I make an outline view reinstate the expanded and collapsed state of 
its rows across application launches?

Building in Xcode 5.1.1 under OS X 10.9.4 Mavericks, I select the outline view 
nib file's Autosave checkbox for Autosave Expanded Items, which is equivalent 
to calling -setAutosaveExpandedItems:YES. 

I also implement the outline view data source method 
-outlineView:persistentObjectForItem: by returning -[NSKeyedArchiver 
archivedDataWithRootObject:item] and the data source method 
-outlineView:itemForPersistentObject: by returning -[NSKeyedUnarchiver 
unarchiveObjectWithData:object]. Doing this is the only sense I can make of the 
very cryptic reference document instructions, and this solution is echoed in 
some of the mailing list discussions I found.

It works, up to a point. When I launch the application, NSLog calls tell me 
that it does call -outlineView:itemForPersistentObject: at launch on the 
archived objects for every row that I left expanded when I previously quit. I 
see the correct archived data items in my user defaults preferences file, so I 
know the application properly called -outlineView:persistentObjectForItem: when 
I previously quit. The archived data items unarchive correctly to the outline 
view items that were left expanded when I previously quit.

However, the indicated rows are not expanded at launch. Instead, all rows are 
collapsed at launch.

Has anybody made this work? How?

-- 

Bill Cheeseman - b...@cheeseman.name

___

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

Please do not post 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: Converting SenTesting framework tests to XCTests

2014-07-10 Thread Chris Hanson
On Jul 10, 2014, at 12:31 PM, William Squires  wrote:
> 
> I'm trying to convert some code that used the old(er) SenTesting framework. 
> Now I want to use the XCTest stuff. I have the following line:
> 
> STAssertEquals(, , NULL); //  is just a int-type variable or 
> constant
> 
> I figure the closest is:
> 
> XCTAssertEquals, but what does the NULL in the above line do? The 3rd 
> argument for XCTAssertEquals is (I believe) (NSString *), in which case a 
> "nil" should work, but Xcode complains. For now, I just have:
> 
> XCTAssertEquals(, , @"");
> 
> but this seems ugly.

Actually, the correct line when using the OCUnit framework should be:

  STAssertEquals(, , @"");

The final required parameter for OCUnit’s macros is a format string, you may 
have just been getting lucky passing nil or NULL instead of an empty string. (I 
don’t remember offhand what the OCUnit assertion macros look like.)

The XCTest framework doesn’t have this requirement; the format string for the 
assertions is entirely optional. That means you can just write

  XCTAssertEquals(, );

if you don’t want to include any extra information about what the failure means 
or that might help you diagnose it at a glance.

Also, you should not need to perform this conversion by hand. Xcode has a 
conversion tool that will do this work for you, it’s available via the “Edit ▸ 
Refactor ▸ Convert to XCTest…” menu item.

  -- Chris
___

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

Please do not post 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

Converting database to Core Data

2014-07-10 Thread William Squires
  I'm trying to convert the following. I have two tables in a database, 
"TransactionEntry", and "ReasonCode". A "TransactionEntry" record is just a 
posting from a POS (Point-of-Sale) terminal, and has these fields (of interest):

Table (TransactionEntry)
  ID As Int32
  PrimaryReasonCode As Int32   // both of these link to .ID
  SecondaryReasonCode As Int32
  ...

and a "ReasonCode" record is used when a certain types of transactions occur, 
such as POSItemReturned, POSItemVoided, POSCommError, and a few others.

Table (ReasonCode)
  ID As Int32
  Description As Varchar(50)
  ReasonCode As Int16 // just an enum
  ...

  All would be good and well if the TransactionEntry table had only one 
reference (.PrimaryReasonCode) to the ReasonCode table, but some transactions 
(such as a voided item) require the manager to fill in both the primary and 
secondary reason codes. I can create the entities, and replace the Int32 record 
numbers/IDs with a relationship.
  I create the relationship in entity "TransactionEntry" and set it to 
"ReasonCode", leaving the inverse relationship to "none" for now. I then create 
an inverse relationship in entity "ReasonCode" to refer back to 
"TransactionEntry". Now I can create the inverse relationships in both 
directions. 1:1 for TransactionEntry -> ReasonCode, and 1:many for ReasonCode 
-> TransactionEntry. All okay so far.
  Primary ReasonCode records (entities) are re-used to save memory, and the 
.Description fields are pre-set to values such as, "return item", "wrong key 
hit", "cc reader not working", etc... Secondary ReasonCode entities are 
(usually) created on-demand from the POS terminal when the manager logs in. A 
few are re-used, but mostly new entities are created. The problem now comes 
when I try to create the same relationships from TransactionEntry entities to 
ReasonCode entities for the secondary reason code records (entities), since it 
won't let me make both inverse relationships 1:many from ReasonCode back to 
TransactionEntry.
  Is this a limitation of CoreData? Or is there a way around this? Can I ignore 
Xcode's warnings about not having inverse relationships, and simply set the 
inverse relationships from the TransactionEntry entity(ies) to the ReasonCode 
Entity to "none", and simply get rid of the inverse relationships in the 
ReasonCode entity?
  Please help! :)



___

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

Please do not post 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

Converting SenTesting framework tests to XCTests

2014-07-10 Thread William Squires
I'm trying to convert some code that used the old(er) SenTesting framework. Now 
I want to use the XCTest stuff. I have the following line:

STAssertEquals(, , NULL); //  is just a int-type variable or 
constant

I figure the closest is:

XCTAssertEquals, but what does the NULL in the above line do? The 3rd argument 
for XCTAssertEquals is (I believe) (NSString *), in which case a "nil" should 
work, but Xcode complains. For now, I just have:

XCTAssertEquals(, , @"");

but this seems ugly.


___

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

Please do not post 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

Problem getting events when adding Subviews

2014-07-10 Thread Dave
I forgot to say, this is for iOS7 iPad only.


Hi,

I have a View Controller that Build “Banner” Views in code and then adds them 
to a viewControllers View Hierarchy. There can be 0, 1 or 2 banners displayed 
at any time under program control.

I decided to use a Parent View Controller to manage the Banners and add Child 
View Controllers to this Parent. This all works fine as far as being displayed 
is concerned. It also works fine if just one “Banner” is visible at a time, 
however if both are being displayed then events are only sent to one of the two 
banners — the last one (in the View Hierarchy) that is added.

Events to the last Banner get through ok and events for the child view 
controller get through ok too, but not for the first “Banner” that was enabled, 
e.g.

e.g.

[myBanner1 enable];
[myBanner2 enable];  — only events for myBanner2 get through to the action 
handler.

or

[myBanner2 enable];
[myBanner1 enable];  — only events for myBanner1 get through to the action 
handler.

Please see a dump of the View Controller’s View Hierarchy below. I’ve also 
tried removing the "Banner Container View” and just adding the two banner 
view’s to View Controller’s .view property but the same thing happens.

Any one have an idea of what I am doing wrong?

Thanks a lot
Dave

ViewController.view - Loaded from NIB via initWithNibName: bundle
SubViews of Base View: 0xba4e130 - class: UIView Tag:   Frame: 
0.00,0.00,768.00,1024.00 


View Loaded from NIB via initWithNibName: bundle:
SubViews of View: 0xba4e190 - class: UILabel Tag:  Frame: 
48.00,26.00,362.00,21.00


Banner Container View Added by Code.
SubViews of View: 0xba41f30 - class: UIView Tag: 1000 Frame: 
0.00,0.00,1024.00,768.00

 Banner1 - Added by Code. 
 SubViews of View: 0xbb5cd70 - class: LTWBannerView Tag: 1001 Frame: 
0.00,0.00,1024.00,768.00
   SubViews of View: 0xbb66d00 - class: UIView Tag: 0 Frame: 
0.00,20.00,1024.00,100.00

 Banner1 Item - Added By Code. An Action is added to the UIButton Object.
 SubViews of View: 0xba34820 - class: LTWBannerItemView Tag: 0 Frame: 
0.00,0.00,1024.00,100.00
   SubViews of View: 0xbb80d80 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,1024.00,100.00
   SubViews of View: 0xbb8d020 - class: UIButton Tag: 2 Frame: 
0.00,0.00,1024.00,100.00
 SubViews of View: 0xbb7c560 - class: UIButtonLabel Tag: 0 Frame: 
440.00,11.00,144.00,77.00

 Banner2 - Added by Code. An Action is added to the UIButton Object.
 SubViews of View: 0xbb672d0 - class: LTWBannerView Tag: 1002 Frame: 
0.00,0.00,1024.00,768.00
   SubViews of View: 0xbb60cb0 - class: UIView Tag: 0 Frame: 
0.00,608.00,1024.00,160.00
 SubViews of View: 0xbb93910 - class: LTWBannerItemView Tag: 0 Frame: 
0.00,0.00,256.00,160.00
   SubViews of View: 0xbb8df30 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
   SubViews of View: 0xbb8e980 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
 SubViews of View: 0xbb8dfb0 - class: UIButtonLabel Tag: 0 Frame: 
43.00,41.00,170.00,77.00

 SubViews of View: 0xbb89870 - class: LTWBannerItemView Tag: 0 Frame: 
256.00,0.00,256.00,160.00
   SubViews of View: 0xbb898e0 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
   SubViews of View: 0xbb92370 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
 SubViews of View: 0xbb6c860 - class: UIButtonLabel Tag: 0 Frame: 
50.00,41.00,156.00,77.00

 SubViews of View: 0xbb8ff30 - class: LTWBannerItemView Tag: 0 Frame: 
512.00,0.00,256.00,160.00
   SubViews of View: 0xbb8bb00 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
   SubViews of View: 0xbb8bbb0 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
 SubViews of View: 0xbb8bcd0 - class: UIButtonLabel Tag: 0 Frame: 
29.00,41.00,197.00,77.00

 SubViews of View: 0xbb87190 - class: LTWBannerItemView Tag: 0 Frame: 
768.00,0.00,256.00,160.00
   SubViews of View: 0xbb87230 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
   SubViews of View: 0xbb872e0 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
 SubViews of View: 0xbb87420 - class: UIButtonLabel Tag: 0 Frame: 
13.00,41.00,230.00,77.00

Child View Controller Loaded from NIB and added by Code using the 
addChildViewController method.
SubViews of View: 0xb741780 - class: UIView Tag:  Frame: 
0.00,100.00,1024.00,508.00
 SubViews of View: 0xb738fd0 - class: UILabel Tag:  Frame: 
174.00,100.00,97.00,21.00
 SubViews of View: 0xb7370b0 - 

Problem getting events when adding Subviews

2014-07-10 Thread Dave
Hi,

I have a View Controller that Build “Banner” Views in code and then adds them 
to a viewControllers View Hierarchy. There can be 0, 1 or 2 banners displayed 
at any time under program control.

I decided to use a Parent View Controller to manage the Banners and add Child 
View Controllers to this Parent. This all works fine as far as being displayed 
is concerned. It also works fine if just one “Banner” is visible at a time, 
however if both are being displayed then events are only sent to one of the two 
banners — the last one (in the View Hierarchy) that is added.

Events to the last Banner get through ok and events for the child view 
controller get through ok too, but not for the first “Banner” that was enabled, 
e.g.

e.g.

[myBanner1 enable];
[myBanner2 enable];  — only events for myBanner2 get through to the action 
handler.

or

[myBanner2 enable];
[myBanner1 enable];  — only events for myBanner1 get through to the action 
handler.

Please see a dump of the View Controller’s View Hierarchy below. I’ve also 
tried removing the "Banner Container View” and just adding the two banner 
view’s to View Controller’s .view property but the same thing happens.

Any one have an idea of what I am doing wrong?

Thanks a lot
Dave

ViewController.view - Loaded from NIB via initWithNibName: bundle
SubViews of Base View: 0xba4e130 - class: UIView Tag:   Frame: 
0.00,0.00,768.00,1024.00 


View Loaded from NIB via initWithNibName: bundle:
SubViews of View: 0xba4e190 - class: UILabel Tag:  Frame: 
48.00,26.00,362.00,21.00


Banner Container View Added by Code.
SubViews of View: 0xba41f30 - class: UIView Tag: 1000 Frame: 
0.00,0.00,1024.00,768.00

  Banner1 - Added by Code. 
  SubViews of View: 0xbb5cd70 - class: LTWBannerView Tag: 1001 Frame: 
0.00,0.00,1024.00,768.00
SubViews of View: 0xbb66d00 - class: UIView Tag: 0 Frame: 
0.00,20.00,1024.00,100.00

  Banner1 Item - Added By Code, and action is 
  SubViews of View: 0xba34820 - class: LTWBannerItemView Tag: 0 Frame: 
0.00,0.00,1024.00,100.00
SubViews of View: 0xbb80d80 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,1024.00,100.00
SubViews of View: 0xbb8d020 - class: UIButton Tag: 2 Frame: 
0.00,0.00,1024.00,100.00
  SubViews of View: 0xbb7c560 - class: UIButtonLabel Tag: 0 Frame: 
440.00,11.00,144.00,77.00
  
  Banner2 - Added by Code. An Action is added to the UIButton Object.
  SubViews of View: 0xbb672d0 - class: LTWBannerView Tag: 1002 Frame: 
0.00,0.00,1024.00,768.00
SubViews of View: 0xbb60cb0 - class: UIView Tag: 0 Frame: 
0.00,608.00,1024.00,160.00
  SubViews of View: 0xbb93910 - class: LTWBannerItemView Tag: 0 Frame: 
0.00,0.00,256.00,160.00
SubViews of View: 0xbb8df30 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
SubViews of View: 0xbb8e980 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
  SubViews of View: 0xbb8dfb0 - class: UIButtonLabel Tag: 0 Frame: 
43.00,41.00,170.00,77.00

  SubViews of View: 0xbb89870 - class: LTWBannerItemView Tag: 0 Frame: 
256.00,0.00,256.00,160.00
SubViews of View: 0xbb898e0 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
SubViews of View: 0xbb92370 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
  SubViews of View: 0xbb6c860 - class: UIButtonLabel Tag: 0 Frame: 
50.00,41.00,156.00,77.00

  SubViews of View: 0xbb8ff30 - class: LTWBannerItemView Tag: 0 Frame: 
512.00,0.00,256.00,160.00
SubViews of View: 0xbb8bb00 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
SubViews of View: 0xbb8bbb0 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
  SubViews of View: 0xbb8bcd0 - class: UIButtonLabel Tag: 0 Frame: 
29.00,41.00,197.00,77.00

  SubViews of View: 0xbb87190 - class: LTWBannerItemView Tag: 0 Frame: 
768.00,0.00,256.00,160.00
SubViews of View: 0xbb87230 - class: UIImageView Tag: 1 Frame: 
0.00,0.00,256.00,160.00
SubViews of View: 0xbb872e0 - class: UIButton Tag: 2 Frame: 
0.00,0.00,256.00,160.00
  SubViews of View: 0xbb87420 - class: UIButtonLabel Tag: 0 Frame: 
13.00,41.00,230.00,77.00

Child View Controller Loaded from NIB and added by Code using the 
addChildViewController method.
SubViews of View: 0xb741780 - class: UIView Tag:  Frame: 
0.00,100.00,1024.00,508.00
  SubViews of View: 0xb738fd0 - class: UILabel Tag:  Frame: 
174.00,100.00,97.00,21.00
  SubViews of View: 0xb7370b0 - class: UIButton Tag: 0 Frame: 
212.00,28

Re: View-based outline view problem

2014-07-10 Thread Quincey Morris
On Jul 10, 2014, at 00:25 , Shane Stanley  wrote:

> I fear I'm doing something basic incorrectly, but I can't see what. My 
> -outlineView:viewForTableColumn:row: is not even getting called, which seems 
> very odd. (And yes, I commented out 
> -outlineView:willDisplayCell:forTableColumn:item:). Any suggestions?

You are doing something basic incorrectly. That NSOutlineView delegate method 
is called ‘outlineView:viewForTableColumn:item:’.




___

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

Please do not post 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: Aligning baseline of NS controls

2014-07-10 Thread Ken Thomases
On Jul 10, 2014, at 9:03 AM, Keary Suska  wrote:

> On Jul 10, 2014, at 2:02 AM, Aandi Inston wrote:
> 
>> Suppose a dialog is to contain a line with multiple controls like
>> 
>> [ ] Add  seconds [before/after]

>> Each of these controls contains text, and the aim here is to align the text
>> so it does not jump up and down - to align the text baseline.
> 
> Umm, Auto Layout? You can easily align elements by baseline...

And even if you don't use auto layout as such, there were methods introduced to 
support it that you can use anyway.  In particular, -[NSView 
alignmentRectForFrame:] to get the alignment rectangle and 
-baselineOffsetFromBottom to find the baseline relative to that alignment 
rectangle.

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

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

Re: View-based outline view problem

2014-07-10 Thread Ken Thomases
On Jul 10, 2014, at 2:25 AM, Shane Stanley  wrote:

> I'm trying to convert a cell-based outline view to view-based. The model is a 
> file wrapper, I'm using a datasource, and it was working fine while 
> cell-based. I changed from a text cell to NSTableCellView, and when I set it 
> up to use bindings for its image view and text field, it also worked OK. But 
> when I try to do it without the bindings, I have no luck. The items all 
> appear with the name "Table View Cell" and the gear image.
> 
> I fear I'm doing something basic incorrectly, but I can't see what. My 
> -outlineView:viewForTableColumn:row: is not even getting called, which seems 
> very odd. (And yes, I commented out 
> -outlineView:willDisplayCell:forTableColumn:item:). Any suggestions?

Are your outlets connected?  Is your delegate object actually set as the table 
view's delegate?

Are the textField and imageView outlets of the NSTableCellView connected to the 
text field and image view within it?

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

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

Re: Aligning baseline of NS controls

2014-07-10 Thread Keary Suska
On Jul 10, 2014, at 2:02 AM, Aandi Inston wrote:

> I am porting a library for dynamic dialog creation to Cocoa.
> The implementation is using various standard controls such as
> NSTextField and NSButton. I have a question.
> 
> Suppose a dialog is to contain a line with multiple controls like
> 
> [ ] Add  seconds [before/after]
> 
> Here
> [ ] Add  is a check box
> _  is an editable text field
> seconds  is a noneditable text field
> [before/after]  is a popup button
> 
> Each of these controls contains text, and the aim here is to align the text
> so it does not jump up and down - to align the text baseline. If the top of
> the controls, or the bottom of the controls, are aligned then the text
> itself will not be aligned.
> 
> Two possibilities suggest themselves
> - fixed constants, based on experiments (which will perhaps go awry if the
> system configuration changes)
> - work out the height of each of these controls, assume padding is equal
> top and bottom, and adjust alignment by half of the difference (this is an
> attractive idea, but I note in a single experiment that the height of
> noneditable text was 16 while editable text was 21, a difference of 2.5
> pixels which is awkward).
> 
> Is there a better way to do this? I imagine it's a problem faced before.

Umm, Auto Layout? You can easily align elements by baseline...

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Shane Stanley
On 10 Jul 2014, at 6:37 pm, Bill Cheeseman  wrote:

> All I can say from my experience is that it requires a lot of trial-and-error

Thanks, Bill -- I was hoping someone would pipe up and say I forgot to do X. Oh 
well...

On 10 Jul 2014, at 10:00 pm, Graham Cox  wrote:

> Is there some good reason to change to view-based, or are you doing it just 
> because it seems to be the "modern" thing? I'd say, if it ain't broke...

Good question. There's no compelling reason for this one -- but there is for 
another more complex one, so I thought I'd cut my teeth on the simpler one 
first. Now I'm thinking of having them extracted...

-- 
Shane Stanley 



___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Bill Cheeseman

On Jul 10, 2014, at 8:00 AM, Graham Cox  wrote:

> Is there some good reason to change to view-based, or are you doing it just 
> because it seems to be the "modern" thing? I'd say, if it ain't broke...


I know you addressed your question to Shane, but speaking for myself: I'm 
writing a new application, which will require Mavericks or newer. I'm 
deliberately using all the latest Cocoa technology because that's the best way 
for me to learn it. (I didn't use bindings because I wanted to understand what 
methods were needed under the hood. I didn't use NSTreeController because I 
quickly discovered that the few tree-like things a source list needs to do are 
more easily done without NSTreeController.)

Also, specifically with respect to source lists and the custom features I'm 
implementing, there are some things you can't do with a cell-based outline. I 
don't recall what those things are, but they are called out in the appropriate 
reference documents.

-- 

Bill Cheeseman - b...@cheeseman.name

___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Graham Cox

On 10 Jul 2014, at 5:25 pm, Shane Stanley  wrote:

> I'm trying to convert a cell-based outline view to view-based.


Is there some good reason to change to view-based, or are you doing it just 
because it seems to be the "modern" thing? I'd say, if it ain't broke...

I've recently gone through a large rewrite of a section of our app to use a 
view-based rather than a cell-based table, because it gives us a better user 
interface, but otherwise, given the pain and usual undocumentedness of it (as 
is usual for a new Cocoa feature), I would not have bothered just for fun.

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

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

Master-Detail in iOS

2014-07-10 Thread Gerriet M. Denkmann
I got the default iOS Master-Detail project (using Swift) from Xocde 6 beta 3. 
Deployment target 7.1

There is a UISplitViewController which has an array of 2 
UINavigationControllers, both have each one UIViewController: the first has 
MasterViewController, the second one has DetailViewController.

UISplitViewController:
UINavigationController-1→ [MasterViewController]
UINavigationController-2→ [DetailViewController]

I added this to DetailViewController:

init( coder: NSCoder )
{
super.init(coder: coder)
println("\ninit \(self)")   //  seen whenever a 
DetailView is appearing
}

And I see that when ever there is a segue from Master to Detail this happens:
a new DetailViewController is created and the second UINavigationController in 
UISplitViewController changes and points to the just created 
DetailViewController controller.

UISplitViewController:
UINavigationController-1→ [MasterViewController]//  
unchanged
UINavigationController-2b → [DetailViewController-b]//  both 
changing at every segue

Is this expected behaviour?

Cannot be: in didFinishLaunchingWithOptions the UISplitViewController gets as 
delegate the first ever DetailViewController, which subsequently is never used.

Also after using the Back button (top left of Detail View) once, there never 
will be such a button to be used.
Probably result of current DetailViewController NOT being delegate of 
UISplitViewController.

How to fix this (meaning: the segue should reuse the already existing stuff in 
UISplitViewController instead creating new things) ?

Gerriet.


___

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

Please do not post 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: View-based outline view problem

2014-07-10 Thread Bill Cheeseman

On Jul 10, 2014, at 3:25 AM, Shane Stanley  wrote:

> I'm trying to convert a cell-based outline view to view-based. The model is a 
> file wrapper, I'm using a datasource, and it was working fine while 
> cell-based. I changed from a text cell to NSTableCellView, and when I set it 
> up to use bindings for its image view and text field, it also worked OK. But 
> when I try to do it without the bindings, I have no luck. The items all 
> appear with the name "Table View Cell" and the gear image.

I'm about 90% of the way through creating my first view-based source list from 
scratch, without bindings, and with lots of custom behaviors. I can't answer 
your question directly because the topic is too large. All I can say from my 
experience is that it requires a lot of trial-and-error (as an AppleScripter, 
you're good at that), and close study of the sample code pays big dividends.

The sample code projects I relied on include these:

 Apple's SidebarDemo sample code
 Apple's SourceView sample code
 Apple's TableViewPlayground sample code
 PXSourceList 

-- 

Bill Cheeseman - b...@cheeseman.name

___

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

Please do not post 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

Aligning baseline of NS controls

2014-07-10 Thread Aandi Inston
I am porting a library for dynamic dialog creation to Cocoa.
The implementation is using various standard controls such as
NSTextField and NSButton. I have a question.

Suppose a dialog is to contain a line with multiple controls like

[ ] Add  seconds [before/after]

Here
[ ] Add  is a check box
_  is an editable text field
seconds  is a noneditable text field
[before/after]  is a popup button

Each of these controls contains text, and the aim here is to align the text
so it does not jump up and down - to align the text baseline. If the top of
the controls, or the bottom of the controls, are aligned then the text
itself will not be aligned.

Two possibilities suggest themselves
- fixed constants, based on experiments (which will perhaps go awry if the
system configuration changes)
- work out the height of each of these controls, assume padding is equal
top and bottom, and adjust alignment by half of the difference (this is an
attractive idea, but I note in a single experiment that the height of
noneditable text was 16 while editable text was 21, a difference of 2.5
pixels which is awkward).

Is there a better way to do this? I imagine it's a problem faced before.

Thanks in advance.
___

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

Please do not post 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

View-based outline view problem

2014-07-10 Thread Shane Stanley
I'm trying to convert a cell-based outline view to view-based. The model is a 
file wrapper, I'm using a datasource, and it was working fine while cell-based. 
I changed from a text cell to NSTableCellView, and when I set it up to use 
bindings for its image view and text field, it also worked OK. But when I try 
to do it without the bindings, I have no luck. The items all appear with the 
name "Table View Cell" and the gear image.

I fear I'm doing something basic incorrectly, but I can't see what. My 
-outlineView:viewForTableColumn:row: is not even getting called, which seems 
very odd. (And yes, I commented out 
-outlineView:willDisplayCell:forTableColumn:item:). Any suggestions?

-- 
Shane Stanley 



___

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

Please do not post 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