NSDocument willPresentError(_:) in Swift 4 : Override not called

2017-06-29 Thread Jerome Krinock
I’m putting together a tiny demo project which subclasses NSDocument.  It has 
two targets, identical Cocoa macOS apps except one is in Objective-C and the 
other in Swift.  In the Objective-C target, I override -[NSDocument 
willPresentError:] like this:

- (NSError*)willPresentError:(NSError *)error {
NSLog(“Presenting!!”)
...
...
}

and that override is called prior to the display of an error dialog sheet, as 
expected.

In the Swift target, with this code:

override func willPresentError(_ error: Error) -> Error {
Swift.print("Presenting!")
...
...
}

running the Swift app in the exact same way, presenting the same error dialog, 
this override is never called.  It does not log “Presenting!”, and a breakpoint 
in there never breaks.

A different print(), in deinit(), logs as expected.

Is my syntax correct?  I’m using Xcode 9.0, Swift 4.0.

Thank you!
___

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: file encription/decriptoin iOS

2017-06-29 Thread Jens Alfke

> On Jun 29, 2017, at 5:33 AM, Dave Fernandes  
> wrote:
> 
> Ah. Thinking about the new device use case helps. Everything must be 
> accessible and decryptable using only the iCloud passphrase. But if the same 
> passphrase is used both to authorize access to the data and to decrypt it, 
> then Apple has the passphrase to decrypt each time the user logs in, do they 
> not? So encryption prevents against third parties seeing the data, but not 
> Apple itself. Or perhaps the passphrase is used to generate two independent 
> secrets and the passphrase itself is never sent over the wire?

Any competent* online service does not store your password. They only store a 
hashed version of it.

With web-based logins the password does usually get sent to the server, but it 
only keeps it long enough to verify the hash, never storing it persistently.

A login system like Apple’s is probably sending a random challenge value to the 
device, which then gets somehow transformed using the password in a way that 
can be verified using the hash (I’m hand-waving here, but there are many 
algorithms for this.) Or alternatively, the password defines an asymmetric 
key-pair**, of which Apple stores the public key, and the login then consists 
of signing the challenge value and sending it back, letting Apple verify the 
signature.

—Jens

* Unfortunately there are still incompetent services still out there. Match.com 
 is one, for example, or was a few years ago when I briefly 
tried using it. If you tell it you forgot your password, it *emails your 
password to you*. My jaw hit the floor and I deleted the account immediately.

** Deriving a key-pair from a password isn’t feasible with RSA, but it can be 
done with e.g. Curve25519.
___

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


How to Correctly Add subviews considering auto layout

2017-06-29 Thread Dave
iOS - Landscape Only.

Hi,

I have a View Controller in a Storyboard that contains a hierarchy of Stack 
Views, the leafs are a Custom Class that inherits from UIView. The Custom Class 

LTWGameCellView : LTWDrawFrameView

LTWDrawFrameView is Custom Class has methods in it that draw a frame around the 
View - this works fine.

LTWGameCellView inherits from LTWDrawFrameView and add up to 2 UIImageView 
subviews to itself. The Images are resources in the project that are loaded at 
runtime and added to the LTWGameCellView. The idea is to draw a Frame Around 
but the Image, but also to inset the image a small amount.



I’m using auto layout and it works ok, except that I’m not sure I’m what I’m 
doing is correct taking into account auto layout - please see code below. The 
“setCellAsPlayedWithPieceImage:" is called when the a player plays a piece into 
the Cell.

I want the (smaller) image to be centered in the (square) DrawFrame View.

Firstly I’m unsure if self.bounds is the correct starting place for placing the 
image view and if I should be setting the frame anyway? Maybe I should be 
adding a constraint to the Image View before I add it as a subview?

The problem I am seeing is that on the first run, the board is not setup 
correctly in that the frames are different, if I re-restart a new game after 
the first time, all is well. This is *was* being called from the 
“viewWillAppear:" of the owing view controller (see code below), so I changed 
things so that “newGame” is called from “viewDidAppear:”, this works well BUT 
you see an annoying flicker when the View Controller first opens.

Any advice or help on this would be greatly appreciated.

All the Best
Dave

-(void) viewWillAppear:(BOOL) theAnimateFlag
{
[super viewWillAppear:theAnimateFlag];

[self newChaosCellViewDictionary];
//[self newGame];
}


-(void) viewDidAppear:(BOOL) theAnimateFlag
{
[super viewDidAppear:theAnimateFlag];

[self newGame];
}

These are the methods I am using to create the ImageViews and add them as a 
subview.

The "setImageForCellWithImageFilePath:” setup up an Image View and stores it as 
a property. Then, later on  “setCellAsNormal” is called to Add the subview, 
then later still, “setCellAsNormal'





-(void) setImageForCellWithImageFilePath:(NSString*) theImageFilePath
{
UIImage*myImage;
UIImageView*myImageView;
CGRect  myImageFrameRect;
NSInteger   myLineWidth;

//**
//**Setup the Line Width (also the Inset size of the Image
//**
myLineWidth = kLTWChaosCellViewFrameLineSize;

//**
//**Inset the Image Rectangle
//**
myImageFrameRect = self.bounds;
myImageFrameRect = CGRectInset(myImageFrameRect,myLineWidth,myLineWidth);

myImage = [[UIImage alloc] initWithContentsOfFile:theImageFilePath];
if (myImage == nil)
{
LTWAssertAlways(@"Cell Image Could Not be Found");
return;
}

//**
//**Create the Image View
//**
myImageView = [[UIImageView alloc] initWithImage:myImage];
[myImageView setFrame:myImageFrameRect];
[myImageView setBackgroundColor:[UIColor clearColor]];

self.pCellImageView = myImageView;

//**
//**Setup the Frame - Causes Redraw
//**
[self setFrameColor:[UIColor blackColor]];
[self setFrameLineWidth:myLineWidth];
[self setDrawFrame:YES];
}



-(void) setCellAsNormal
{
self.pCellKind = kLTWChaosBoardCellKindNormal;

[self setBackgroundColor:self.pCellUIColor];
[self removeAllSubviews];
[self addSubview:self.pCellImageView];
}



-(void) setCellAsPlayedWithPieceImage:(UIImage*) thePieceImage
{
UIImageView*myImageView;
CGRect  myFrameRect;

myFrameRect = self.bounds;
myFrameRect = CGRectInset(myFrameRect,6,6);

myImageView = [[UIImageView alloc] initWithImage:thePieceImage];
[myImageView setFrame:myFrameRect];
[myImageView setBackgroundColor:[UIColor clearColor]];

//**
//** Add as Second Image View
//**
[self setBackgroundColor:self.pCellUIColor];
[self addSubview:myImageView];
}




___

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: file encription/decriptoin iOS

2017-06-29 Thread Dave Fernandes
Ah. Thinking about the new device use case helps. Everything must be accessible 
and decryptable using only the iCloud passphrase. But if the same passphrase is 
used both to authorize access to the data and to decrypt it, then Apple has the 
passphrase to decrypt each time the user logs in, do they not? So encryption 
prevents against third parties seeing the data, but not Apple itself. Or 
perhaps the passphrase is used to generate two independent secrets and the 
passphrase itself is never sent over the wire?

> On Jun 29, 2017, at 12:27 AM, Jens Alfke  wrote:
> 
> 
>> On Jun 28, 2017, at 8:04 PM, Dave Fernandes > > wrote:
>> 
>> So everything is protected by the iCloud Drive service key, but what does 
>> “which is then stored with the user’s iCloud account” mean? Is it stored on 
>> the device or in iCloud? That makes all the difference.
> 
> I agree it’s vague. The way I read it is that the service key is stored with 
> other account data in iCloud, but the account data is itself encrypted via 
> the user’s passphrase (which is not known to Apple.)
> 
> If the service key were stored locally, that would beg the question of how it 
> gets from one device to another. You have to be able to access everything 
> from a new device by logging into iCloud, so any secrets have to be stored 
> online. But by encrypting them using the passphrase, Apple prevents anyone 
> else (including themselves) from reading them.
> 
> —Jens

___

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

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

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

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


Re: UITableViewController

2017-06-29 Thread Quincey Morris
On Jun 29, 2017, at 01:05 , Gerriet M. Denkmann  wrote:
> 
> and also the Container View has:
> Triggered Segues
> viedDidLoad   TableViewController Embed

I have the same thing, so I don’t know what’s different.

> What I do not understand: Container View is a UIView, which does not have 
> viedDidLoad (although its ViewController has such a method).

I think the container view’s behavior is a fiction. The *containment* hierarchy 
is between view controllers, so it’s supposed to be happening in the view’s 
view controller’s viewDidLoad (I guess), which would explain this connection.

According to something Kyle Sluder said a few weeks ago, you should get a 
prepareForSegue for the embed segue.

Most strange.

___

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

2017-06-29 Thread Gerriet M. Denkmann

> On 29 Jun 2017, at 12:13, Quincey Morris 
>  wrote:
> 
> On Jun 28, 2017, at 22:02 , Gerriet M. Denkmann  wrote:
>> 
>> I had to do two more steps:
>> 
>> 1. give the segue an identifier, like: “EmbedSegueToTableViewController”
>> 
>> 2. in the UITableViewController which formerly did have a UITableView and 
>> now has the container view:
>> 
>> - (void)viewDidLoad 
>> {
>>  …
>>  [ self performSegueWithIdentifier: @“EmbedSegueToTableViewController” 
>> sender: self ];
>> }
> 
> That’s bizarre, and shouldn’t be necessary. I just tried my test project 
> again to make sure, and the table view appears without needing to do this.

My new TableViewController shows in the Connections Inspector:
Presenting Segues
Embed → Container View viewDidLoad

and also the Container View has:
Triggered Segues
viedDidLoad TableViewController Embed

What I do not understand: Container View is a UIView, which does not have 
viedDidLoad (although its ViewController has such a method).

The ViewController (MasterViewController) which owns Container View has no 
Triggered Segues.


> 
> Are you sure this wasn’t a timing problem, where you expected the table view 
> to exist before the loading process got to it? I can’t think of any other 
> explanation.

The window is controlled by MasterViewController; it does its viewDidLoad; 
everything looks fine, but the container View is just a white rectangle.
No prepareForSegue: is called.

But with [ self performSegueWithIdentifier: kSegueToFreshTable sender: self ] 
the window contains a tableView and prepareForSegue is called, with 
destinationViewController = my new TableViewController.

Kind regards,

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