Re: Saving window and view state with NSDocument

2015-09-21 Thread Kurt Sutter
Thanks for the info

> BTW you decided to fight against framework (as others mentioned state 
> restoration is responsible for this). 

The documentation on state restoration is somewhat sparse. However, as I 
understood, it only kicks in when I re-open an application. When the user opens 
a document after opening the application, state restoration would not restore 
that document — would it?

> On 21 Sep 2015, at 23:52, Marek Hrušovský  wrote:
> 
> Personally I would do it like this:
> 1. Figure out what values you need to store 
> 2. Create custom object called configuration; for each window one kind
> 3. Make it conform nscoding and add a delegate property (which will point to 
> windowcontroller)
> 3. implement initwithcoder/encodewithcoder
> 3. add this to your model
> 
> Saving:
> As usual
> 
> Loading
> 1. override setDocument on your windowController
> 2. call super
> 3. get the configuration from document, set it's delegate and apply it where 
> you need it
> 
> I thought of other approaches but they were more ugly or involved more code.
> BTW you decided to fight against framework (as others mentioned state 
> restoration is responsible for this). 
> Also don't forget to call updateChangeCount (if you don't support undo). 
> 
> 
> 
> On Mon, Sep 21, 2015 at 9:46 PM, Kurt Sutter  > wrote:
> Thanks, Marek
> 
> So how would I go at this? Since I want to store that data into the document, 
> I’d need, in dataOfType:error:, to create a NSKeyedArchiver, and then would I 
> just encode self.windowControllers? Then, in readFromData:ofType:error:, I 
> would read in the coder, and in makeWindowControllers I would then re-create 
> the window controllers? Would that work? (I have started to try exactly that, 
> but I have not yet succeeded with making it work. It somehow seems a bold 
> thing to do.)
> 
> Kurt
> 
>  
>> On 21 Sep 2015, at 20:22, Marek Hrušovský > > wrote:
>> 
>> I am far from architect but each window has an option "initWithCoder" and 
>> within XIB you can specify option "prefer coder instantiation". The 
>> information you want to store is not related to the model object (within 
>> document) cannot be reused.  
>> So basically I would implement NSCoder methods encode/init withCoder
>> 
>> Marek.
>> 
>> On Mon, Sep 21, 2015 at 8:09 PM, Kurt Sutter > > wrote:
>> Hi all
>> 
>> I am trying to figure out how to store information about my windows and 
>> views in a document, and how to restore it. Note that I am talking about 
>> storing the information in the document itself, not in the application’s 
>> preferences settings.
>> 
>> Specifically, I have a child of NSDocument that saves its model data using 
>> dataOfType:error: and restores it using readFromData:ofType:error: That 
>> works fine. Now, that document may have a variable number of windows for 
>> showing aspects of the data of the document’s model, and each window has a 
>> number of views. The windows and views contain state information, such as 
>> scroll positions, window positions, zoom factors, etc.
>> 
>> I want the state information of the windows and views to be stored in the 
>> document so that the same windows and views reopen when the user opens the 
>> document.
>> 
>> What is the best way to do that? I guess I have to take two steps:
>> 
>> (a) collect that state information in dataOfType:error: and store it in the 
>> NSData object to be returned and
>> (b) retrieve that data from the NSDocument in readFromData:ofType:error: and 
>> then somehow apply it in the NSDocument’s makeWindowControllers method.
>> 
>> While both of this is certainly feasible, I am not sure what is the most 
>> elegant way to do it. Do I run encodeWithCoder against the document’s window 
>> controllers during save, and then somehow restore the window controllers in 
>> the makeWindowControllers? Or what else?
>> 
>> I have tried to find pointers on how to do this in the most elegant manner, 
>> but I found nothing useful. So I would greatly appreciate any proposals.
>> 
>> Thanks in advance
>> 
>> Kurt
>> ___
>> 
>> 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/xhruso00%40gmail.com 
>> 
>> 
>> This email sent to xhrus...@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 

Re: iOS 9 or Watch App

2015-09-21 Thread Michael David Crawford
For me, it works OK to put the Xcode app bundles in folders:

/Applications/Xcode_5/Xcode.app

/Applications/Xcode_6/Xcode.app

however you may only have one version of the command line tools
installed in /usr/bin and the like.
Michael David Crawford P.E., Consulting Process Architect
mdcrawf...@gmail.com
http://mike.soggywizard.com/

  One Must Not Trifle With Wizards For It Makes Us Soggy And Hard To Light.


On Sun, Sep 20, 2015 at 8:35 PM, Quincey Morris
 wrote:
> On Sep 20, 2015, at 11:41 , Raglan T. Tiger  wrote:
>>
>> So, against my better judgement, I updated to Xcode 7.
>>
>> The installed version is 6.31, there ar no iOS9 or Watch SDKs.
>
> I don’t know what “6.31” means - maybe you mean 6.3.1? In which case you’re 
> running Xcode 6, not Xcode 7.
>
> There’s no “installed” for Xcode any more, in the sense of stuff copied into 
> a standardized system-wide location. Xcode 6 and Xcode 7 are just two 
> gigantic app bundles, each of which contains all and only the SDKs that are 
> allowed for that Xcode version. You can have both available simultaneously.
>
> So, if you want iOS 9 or watchOS, then you need to launch Xcode 7. If you’re 
> launching Xcode 6 by mistake, you’re going to have to figure out where it is, 
> and delete it if you don’t want it anymore. Or launch Xcode 7 by explicitly 
> double-clicking on its app bundle.
>
>
>
> ___
>
> 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/mdcrawford%40gmail.com
>
> This email sent to mdcrawf...@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: Error unwrapping an optional which isn't an optional

2015-09-21 Thread Charles Srstka
> On Sep 21, 2015, at 6:03 PM, Greg Parker  wrote:
> 
> selectedRow's "row index or -1" behavior is an obvious candidate for a Swift 
> optional, but we don't currently have a good way to bridge such API with 
> Objective-C.

How about allowing the “nullable” keyword on non-pointer types, but adding a 
parameter that specifies the nil condition? An API like selectedRow could 
simply have nullable(-1) added to its type, and then Swift could interpret the 
value as nil if it encountered a -1 from that API.

Charles

___

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

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

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

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

Re: Error unwrapping an optional which isn't an optional

2015-09-21 Thread John Daniel
I think the optional in question is the IB object. You may be accessing this 
property before your nib is completely setup. 

John Daniel
Sent from my iPad
___

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: Error unwrapping an optional which isn't an optional

2015-09-21 Thread Greg Parker

> On Sep 21, 2015, at 11:01 AM, Alex Hall  wrote:
> 
> Hi list,
> I'm setting up a binding using an NSController, which I want to connect the 
> currently selected row in a table to the values of some UI controls. Put 
> another way, whenever the table's selected row changes, the binding should 
> cause some controls to display new information pulled from the row.
> 
> It's not working, but the error I'm seeing makes no sense. I've switched to 
> using tableViewSelectionDidChange in a delegate, and that works perfectly. 
> I'm not desperate to solve this problem since my delegate does what I want; 
> I'm more curious about why it might be happening.
> 
> The key for the binding is my view controller .currentTweet. That property is 
> computed, and I've marked it as dynamic and implemented keyPathsForValues. 
> Yet, when I run it with the binding in place: "fatal error: unexpectedly got 
> nil while unwrapping an optional value." The weird part: nowhere on the line 
> in question do I use an optional. Here are two declarations. The first is 
> where the second gets its value; the second is what my controller is bound 
> to. Both of these happen in my ViewController subclass, outside of any 
> methods.
> 
>   dynamic var currentTweet:Tweet? {
>   get {
>   return currentTab.tweetsList[tweetsTable.selectedRow] 
> //Xcode points to this line as the problem
>   }
>   }
>   
>   dynamic var currentTweetID:String? {
>   get {
>   if let tempTweet=currentTweet, tempID = 
> tempTweet.idAsString {
>   return tempID
>   }
>   return nil
>   }
>   }
> 
> Yes, both properties are optional, but the line Xcode is complaining about 
> has no optionals at all.

How are currentTab and tweetsList and tweetsTable declared? Those are the 
obvious candidates for an optional access.

What is the stack trace of the error? Perhaps one of those references is itself 
a complex accessor that accesses an optional internally.


> I thought about putting the tweetsTable.selectedRow bit in an 'if let', but 
> that won't work because it's not optional so Swift won't let it in an 'if 
> let'.

selectedRow's "row index or -1" behavior is an obvious candidate for a Swift 
optional, but we don't currently have a good way to bridge such API with 
Objective-C.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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: Tracking down source of [_NSControllerObjectProxy copyWithZone:]… error

2015-09-21 Thread Greg Parker

> On Sep 19, 2015, at 8:09 PM, Alex Hall  wrote:
> 
> Hey list,
> A binding is driving my app (my actual one, not the test one) and has been 
> for days now--awesome! Amid more refactoring of my code, and adding a second 
> binding which didn't take because of uninitialized properties, I've now 
> started seeing this error in my debug log:
> 
> [_NSControllerObjectProxy copyWithZone:]: unrecognized selector sent to 
> instance 0x60800ae0
> 
> failed to set (contentViewController) user defined inspected property on 
> (NSWindow): -[_NSControllerObjectProxy copyWithZone:]: unrecognized selector 
> sent to instance 0x60800ae0
> 
> From what I've been reading, this is due to something trying to copy an 
> object that doesn't conform to the NSCopy protocol. Most likely, I have a 
> proxy object somewhere Cocoa expects an instance, and since the proxy can't 
> be copied, this is happening. The problem is, I can't see *where* this is 
> going on. My debug log is showing me this, but my debug navigator is empty. 
> There's no runtime error showing in a source file like there is when the line 
> causing the problem is clear, and since I only have an address for the 
> instance and not a name, I'm at a bit of a loss. What is a good strategy for 
> discovering the source of this problem so I can fix it?

This is probably failing to crash because "unrecognized selector" throws an 
exception and the exception is being caught and ignored somewhere.

If you can reproduce this yourself, try running with an Exceptions breakpoint 
set. That should stop in the debugger with the call site in the stack trace. 
(Breakpoints navigator > "+" button at the bottom > Add Exception Breakpoint)

Another dumb alternative: implement -[_NSControllerObjectProxy copyWithZone:] 
to call abort() or otherwise halt the process. Then it will stop in the 
debugger or generate a crash log with a stack trace pointing to the call site.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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: iOS 9 or Watch App

2015-09-21 Thread Quincey Morris
On Sep 21, 2015, at 14:08 , Raglan T. Tiger  wrote:
> 
> Does anyone know if Xcode 7 should show as version 7 in the Finder  preview 
> panel?

Yes, it does.

Have you checked to make sure you don’t have a copy of Xcode 6 on an external 
disk? Note that you can right-click on an existing project, and the Finder will 
pop up a menu that shows you all apps able to open the project, including the 
version numbers, with different versions listed separately.



___

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: Saving window and view state with NSDocument

2015-09-21 Thread Quincey Morris
On Sep 21, 2015, at 14:52 , Marek Hrušovský  wrote:
> 
> Personally I would do it like this:
> 1. Figure out what values you need to store
> 2. Create custom object called configuration; for each window one kind
> 3. Make it conform nscoding and add a delegate property (which will point
> to windowcontroller)
> 3. implement initwithcoder/encodewithcoder
> 3. add this to your model

I agree with your general approach, but I think it needs to be understood that 
the “values you need to store” should be representations of the UI state in 
terms of the data model, not the UI state itself. That is, I think it’s a 
terrible idea to archive window controllers, or scroll offsets, or any view 
geometry like that. You don’t know that you can actually recreate the original 
UI state (for example, you don’t even know you can restore the original window 
sizes, since the display configuration can change at any time).

I also agree with your point that competing with state restoration may not work 
out so well. It should be possible to turn off all manifestations of state 
restoration, but in practice this is another lousy compromise.

___

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: Is it possible to transfer data by using light

2015-09-21 Thread Sixten Otto
On Sun, Sep 20, 2015 at 9:55 PM, Jens Alfke  wrote:

> But honestly, if you're going this route, it will be much faster to
> transmit QR codes, since each code contains thousands of bits.
>

Especially given that recent versions of iOS can detect and decode QR codes
automatically, much like face detection.

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVMetadataMachineReadableCodeObject_Class/index.html

https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CIQRCodeFeature/


> On Sep 20, 2015, at 7:21 PM, ico  wrote:
> >
> > After reading all of the replies, no one mentioned how to use iPhone to
> > detect the light changes (bright and dark) in codes, I just have no clue
> > how to make it works as long as I remember developers have no right to
> > access the light sensor, so I guess we have to use camera to achieve
> this,
> > but I just don't know how. Can anyone point me to something to read so I
> > can start digging into this and make the whole thing start to work?
> >
> > Thank you all.
> >
> > On Fri, 18 Sep 2015 at 20:38 Michael David Crawford <
> mdcrawf...@gmail.com>
> > wrote:
> >
> >> Do iOS devices support Trusted Computing in hardware?  If so is it
> >> accessible to userspace apps?
> >>
> >> If so, you could store your phones secret in a write-only register.
> >> For the profoundly paranoid, even the duplication of your storage
> >> would not yield your phone's secret, The Bad Guy would need your
> >> personal phone.
> >>
> >> Modern Macs - to the best of my knowledge - provide trusted computing
> >> chips, on can access them from userspace with a modest bit of code.
> >> Michael David Crawford P.E., Consulting Process Architect
> >> mdcrawf...@gmail.com
> >> http://mike.soggywizard.com/
> >>
> >>  One Must Not Trifle With Wizards For It Makes Us Soggy And Hard To
> >> Light.
> >>
> >>
> >>> On Fri, Sep 18, 2015 at 3:12 AM, Maxthon Chan 
> wrote:
> >>> The "over-the-shoulder" issue can be avoided using what is effectively
> a
> >> Diffie-Hellman on top of QR codes. This can be done using front-facing
> >> cameras on two devices placed face-to-face.
> >>>
> >>> Sent from my iPhone
> >>>
>  On Sep 18, 2015, at 00:46, Pascal J. Bourguignon <
> p...@informatimago.com>
> >> wrote:
> 
> 
> 
> > On 17/09/15 17:32, Michael David Crawford wrote:
> > And what the man said: I myself experience seizures in which I lose
> > consciousness for as long as three weeks.  Before they were diagnosed
> > I would experience seizures while driving my car then suddenly find
> > myself in unfamiliar places without any clue how I got there.
> >
> > I don't know for sure but strongly suspect that modern computer user
> > interfaces caused my seizure disorder as well as that of my cousin.
> > Seizures are not otherwise found among any of our blood relatives.
> 
>  But then if you don't use the whole screen, but only the area that
>  should be in front of the camera of the superposed phone, then users
>  shouldn't be subjected to much stroboscopic light.
> 
>  Having the objective so close from the light source does not allow
>  the camera to distinguish pixels; for example, a black to white
>  transition takes about 1/10 of the height of the camera view.
>  But this means that you might still able to transmit about ten pixels
> >> at once,
>  and you can multiply that by a number of color that you can detect
> >> reliably
>  being that out of focus. Basically, I would expect 8 colors to be
> >> clearly
>  distinguishable.  Actually, probably more colors should be
> >> distinguishable,
>  if you can filter out the interferences due to the grid of the camera
> >> vs.
>  the grid of the screen. So assume 4 bits for the color, and 9 areas,
>  that's 36 bit/moment, and you should be able to do 30 moment/second,
>  for a total of 1080 bit/second.  A little less for ECC, about 1 KB/s
>  is not too bad.  It's good enough to transmit a good private key, and
> >> then
>  transfer the data thru wifi.
> 
> 
>  Of course, if you move the camera out to focus on the screen, then
>  you can transmit at a higher speed things like QR codes, but they
>  could also be seen over the shoulder by high resolution cameras.
> 
>  --
>  __Pascal J. Bourguignon__
>  http://www.informatimago.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/max%40maxchan.info
> 
>  This email sent to m...@maxchan.info
> >>>
> >>> 

Re: Is it possible to transfer data by using light

2015-09-21 Thread Jens Alfke

> On Sep 21, 2015, at 8:54 AM, Sixten Otto  wrote:
> 
> Especially given that recent versions of iOS can detect and decode QR codes
> automatically, much like face detection.

And Mac OS, too.

I just looked up some code I wrote a few months ago to do QR-code scanning. 
Here’s the guts of it:
https://gist.github.com/snej/6440a2e041222018cc7c
And here’s how to generate a QR-code:
https://gist.github.com/snej/c210cc4cbfe8fd277186

—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: iOS 9 or Watch App

2015-09-21 Thread Conrad Shultz

> On Sep 21, 2015, at 6:20 AM, Michael David Crawford  
> wrote:
> 
> however you may only have one version of the command line tools
> installed in /usr/bin and the like.

You might take a look at 
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
 


-Conrad
___

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

Error unwrapping an optional which isn't an optional

2015-09-21 Thread Alex Hall
Hi list,
I'm setting up a binding using an NSController, which I want to connect the 
currently selected row in a table to the values of some UI controls. Put 
another way, whenever the table's selected row changes, the binding should 
cause some controls to display new information pulled from the row.

It's not working, but the error I'm seeing makes no sense. I've switched to 
using tableViewSelectionDidChange in a delegate, and that works perfectly. I'm 
not desperate to solve this problem since my delegate does what I want; I'm 
more curious about why it might be happening.

The key for the binding is my view controller .currentTweet. That property is 
computed, and I've marked it as dynamic and implemented keyPathsForValues. Yet, 
when I run it with the binding in place: "fatal error: unexpectedly got nil 
while unwrapping an optional value." The weird part: nowhere on the line in 
question do I use an optional. Here are two declarations. The first is where 
the second gets its value; the second is what my controller is bound to. Both 
of these happen in my ViewController subclass, outside of any methods.

dynamic var currentTweet:Tweet? {
get {
return currentTab.tweetsList[tweetsTable.selectedRow] 
//Xcode points to this line as the problem
}
}

dynamic var currentTweetID:String? {
get {
if let tempTweet=currentTweet, tempID = 
tempTweet.idAsString {
return tempID
}
return nil
}
}

Yes, both properties are optional, but the line Xcode is complaining about has 
no optionals at all. My only thought is that this binding is happening before 
the table is created, thus tweetsTable.selectedRow has no value? I thought 
about putting the tweetsTable.selectedRow bit in an 'if let', but that won't 
work because it's not optional so Swift won't let it in an 'if let'.

As I said, I'm just curious about this, not desperate to fix it and totally 
lost like a couple weeks back. :) My delegate does a fine job doing what I 
want, and I might never use a binding for this job at all. The error is just 
such an odd one, considering there are no optionals on that line.


--
Have a great day,
Alex Hall
mehg...@icloud.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

Saving window and view state with NSDocument

2015-09-21 Thread Kurt Sutter
Hi all

I am trying to figure out how to store information about my windows and views 
in a document, and how to restore it. Note that I am talking about storing the 
information in the document itself, not in the application’s preferences 
settings.

Specifically, I have a child of NSDocument that saves its model data using 
dataOfType:error: and restores it using readFromData:ofType:error: That works 
fine. Now, that document may have a variable number of windows for showing 
aspects of the data of the document’s model, and each window has a number of 
views. The windows and views contain state information, such as scroll 
positions, window positions, zoom factors, etc.

I want the state information of the windows and views to be stored in the 
document so that the same windows and views reopen when the user opens the 
document.

What is the best way to do that? I guess I have to take two steps:

(a) collect that state information in dataOfType:error: and store it in the 
NSData object to be returned and
(b) retrieve that data from the NSDocument in readFromData:ofType:error: and 
then somehow apply it in the NSDocument’s makeWindowControllers method.

While both of this is certainly feasible, I am not sure what is the most 
elegant way to do it. Do I run encodeWithCoder against the document’s window 
controllers during save, and then somehow restore the window controllers in the 
makeWindowControllers? Or what else?

I have tried to find pointers on how to do this in the most elegant manner, but 
I found nothing useful. So I would greatly appreciate any proposals.

Thanks in advance

Kurt
___

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: Is it possible to transfer data by using light

2015-09-21 Thread Alex Zavatone

On Sep 21, 2015, at 11:54 AM, Sixten Otto wrote:

> On Sun, Sep 20, 2015 at 9:55 PM, Jens Alfke  wrote:
> 
>> But honestly, if you're going this route, it will be much faster to
>> transmit QR codes, since each code contains thousands of bits.
>> 
> 
> Especially given that recent versions of iOS can detect and decode QR codes
> automatically, much like face detection.
> 
> https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVMetadataMachineReadableCodeObject_Class/index.html
> 
> https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CIQRCodeFeature/

IIRC, we tested that over a year ago with great success under iOS.
___

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

Popover presentation on iPhone

2015-09-21 Thread Joseph Menezes
Hi,
 I had implemented a popover presentation in iPhone with iOS 8.4 SDK. 
When i compiled this code in iOS 9, this implementation is not working. The 
popover is displayed as full screen.

Even if i set, modalPresentationStyle of the presented view controller to be  
UIModalPresentationPopover and set the popoverPresentationController delegate 
to my custom view controller, none of the delegate methods get called.

The documentation for “UIModalPresentationPopover" says

"In a horizontally regular environment, a presentation style where the content 
is displayed in a popover view. In a horizontally compact environment, this 
option behaves the same as UIModalPresentationFullScreen.”

is that means it is not possible to present a modal view controller as popover 
in iPhone? even though implementing the delegate method,

- 
(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController
 *)controller traitCollection:(UITraitCollection *)traitCollection
{
return UIModalPresentationNone;
}

Regards,
Joseph Menezes

___

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: [OT] VPN Problems?

2015-09-21 Thread Dave

> On 18 Sep 2015, at 23:32, Philip Ershler  wrote:
> 
> I have no trouble from a 10.10 client to a 10.10 server at all. 
> 
> Phil

Cheers found the problem - there’s some weirdness in Mac OS X to do with SSL. 

Cheers
Dave



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Top-level contextual menu for view hierarchy

2015-09-21 Thread Matt Reagan
Hi cocoa-dev,

I have a custom UI component that wraps a number of subviews (mostly standard 
Cocoa views: NSTextField, NSImageView, etc.).

I'm attempting to provide a contextual menu for the entire top-level view / 
control in this case, so that regardless of which particular subview is 
right/control-clicked, the same menu can be shown. NSView by default does not 
call into super for -menuForEvent AFAICS, it just returns nil. The problem is 
easy to reproduce in a test app by adding e.g. an NSImageView to a custom 
container view subclass. The container view can provide a menu for 
-menuForEvent, which shows if the user control-clicks anywhere outside the 
child NSImageView. However a control click on the NSImageView shows nothing.

(NOTE: right-click works in the above scenario, but a control-click does not.)

My question: is there a simple Apple-prescribed approach for providing a single 
top-level contextual menu for a view *and* its subview tree for both 
right/control-click? I've found I can get this working with hacky approaches 
like traversing the view hierarchy and calling -setMenu on every subview, or 
overriding -menuForEvent on every single subview class, but this seems clunky 
and unnecessary. I also considered trying to solve this by leveraging -hitTest, 
but again, that seems like it shouldn't be required.

Does anyone have any suggestions?

Thanks,
-matt
___

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: Saving window and view state with NSDocument

2015-09-21 Thread Kurt Sutter
Isn’t state restoration something that goes into the app’s preferences (or 
somewhere else into the app’s container)? What I am looking for is some way to 
store that information in the document.

> On 21 Sep 2015, at 20:53, Quincey Morris 
>  wrote:
> 
> On Sep 21, 2015, at 11:09 , Kurt Sutter  > wrote:
>> 
>> I want the state information of the windows and views to be stored in the 
>> document so that the same windows and views reopen when the user opens the 
>> document.
>> 
>> What is the best way to do that? I guess I have to take two steps:
>> 
>> (a) collect that state information in dataOfType:error: and store it in the 
>> NSData object to be returned and
>> (b) retrieve that data from the NSDocument in readFromData:ofType:error: and 
>> then somehow apply it in the NSDocument’s makeWindowControllers method.
> 
> You don’t mention OS X state restoration:
> 
>   
> https://developer.apple.com/library/prerelease/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html
>  
> 
> 
> (under heading "Windows Are Restored Automatically”), but that sounds like 
> what you’re looking for.
> 
> Note that state restoration is extremely badly documented in Apple’s 
> documentation. You’ll need to sift through API for individual classes and 
> protocols, and sometimes look at the Obj-C header comments, to get a 
> reasonably complete picture of what’s going on.
> 
> There are probably some relevant WWDC videos, perhaps starting with "Resume 
> and Automatic Termination in Lion” from 2011.

___

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: Saving window and view state with NSDocument

2015-09-21 Thread Kurt Sutter
Thanks, Marek

So how would I go at this? Since I want to store that data into the document, 
I’d need, in dataOfType:error:, to create a NSKeyedArchiver, and then would I 
just encode self.windowControllers? Then, in readFromData:ofType:error:, I 
would read in the coder, and in makeWindowControllers I would then re-create 
the window controllers? Would that work? (I have started to try exactly that, 
but I have not yet succeeded with making it work. It somehow seems a bold thing 
to do.)

Kurt

 
> On 21 Sep 2015, at 20:22, Marek Hrušovský  wrote:
> 
> I am far from architect but each window has an option "initWithCoder" and 
> within XIB you can specify option "prefer coder instantiation". The 
> information you want to store is not related to the model object (within 
> document) cannot be reused.  
> So basically I would implement NSCoder methods encode/init withCoder
> 
> Marek.
> 
> On Mon, Sep 21, 2015 at 8:09 PM, Kurt Sutter  > wrote:
> Hi all
> 
> I am trying to figure out how to store information about my windows and views 
> in a document, and how to restore it. Note that I am talking about storing 
> the information in the document itself, not in the application’s preferences 
> settings.
> 
> Specifically, I have a child of NSDocument that saves its model data using 
> dataOfType:error: and restores it using readFromData:ofType:error: That works 
> fine. Now, that document may have a variable number of windows for showing 
> aspects of the data of the document’s model, and each window has a number of 
> views. The windows and views contain state information, such as scroll 
> positions, window positions, zoom factors, etc.
> 
> I want the state information of the windows and views to be stored in the 
> document so that the same windows and views reopen when the user opens the 
> document.
> 
> What is the best way to do that? I guess I have to take two steps:
> 
> (a) collect that state information in dataOfType:error: and store it in the 
> NSData object to be returned and
> (b) retrieve that data from the NSDocument in readFromData:ofType:error: and 
> then somehow apply it in the NSDocument’s makeWindowControllers method.
> 
> While both of this is certainly feasible, I am not sure what is the most 
> elegant way to do it. Do I run encodeWithCoder against the document’s window 
> controllers during save, and then somehow restore the window controllers in 
> the makeWindowControllers? Or what else?
> 
> I have tried to find pointers on how to do this in the most elegant manner, 
> but I found nothing useful. So I would greatly appreciate any proposals.
> 
> Thanks in advance
> 
> Kurt
> ___
> 
> 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/xhruso00%40gmail.com 
> 
> 
> This email sent to xhrus...@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: Error unwrapping an optional which isn't an optional

2015-09-21 Thread Quincey Morris
On Sep 21, 2015, at 11:01 , Alex Hall  wrote:
> 
> I'm setting up a binding using an NSController, which I want to connect the 
> currently selected row in a table to the values of some UI controls. Put 
> another way, whenever the table's selected row changes, the binding should 
> cause some controls to display new information pulled from the row.

Several things about this:

1. 
>   return currentTab.tweetsList[tweetsTable.selectedRow] 
> //Xcode points to this line as the problem

Sometimes, this sort of thing is just a trivial error because Swift inferred an 
optional type and you weren’t expecting it. You can solve this by temporarily 
writing out the code with the types you expect, approximately like this:

let selectedRow: Int = tweetsTable.selectedRow
let tweetsList: [Tweet] = currentTab.tweetsList
let result: Tweet = tweetsList [selectedRow]

Or, it may be something subtler where the SDK has told Swift that an object 
can’t be nil, but it really can (at run time, because this is Obj-C 
underneath). This would likely be regarded as a bug in the SDK.

2.
>   return currentTab.tweetsList[tweetsTable.selectedRow] 
> //Xcode points to this line as the problem


This is a dangerous line of code, because (if tweetsTable is a table view) 
tweetsTable.selectedRow can validly be -1, and that’s gonna crash your app.

3. In spite of all the things I’ve said in the recent past, this is one of the 
situations where you *should* bind the row-specific controls to a 
NSArrayController’s “selection” property.

That’s because one of the useful bindings behaviors is dealing with situations 
where you want to show something different for no-selection, single-selection 
and multiple-selection cases. There are bindings options to disable controls 
when there isn’t a single selected element, and bindings options to customize 
placeholder text, too (4 different placeholders, of which you’re likely to want 
to use just the no-selection and multiple-selection cases).

4.
>   dynamic var currentTweet:Tweet? {
>   get {
>   …
>   }
>   }


If you have only a getter, there’s no need for the ‘get’ keyword and the 
unnecessary extra level of braces. All you need is a ‘return’ at the top level 
of the property. One of the banner features of Swift (for the recovering Obj-C 
programmer) is that you don’t have to write out syntax that compiler already 
knows must be there, or that it can reasonably assume. I sympathize with 
developers whose sense of consistency is offended by this, but OTOH I’ll have 
finished writing my property before you’ve finished lining up your braces, and 
my source files will be half the size or yours. ;)

5.
>   if let tempTweet=currentTweet, tempID = 
> tempTweet.idAsString {
>   return tempID
>   }
>   return nil

I strongly commend the advantages of ‘guard’ for this sort of thing:

guard let tempTweet=currentTweet, tempID = tempTweet.idAsString else { 
return nil }
return tempID

This makes it clear that the nil return is exceptional (relative to the name of 
the property, even if it’s not really an error return), and avoids burying the 
important answer inside yet more braces.


___

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: Saving window and view state with NSDocument

2015-09-21 Thread Marek Hrušovský
I am far from architect but each window has an option "initWithCoder" and
within XIB you can specify option "prefer coder instantiation". The
information you want to store is not related to the model object (within
document) cannot be reused.
So basically I would implement NSCoder methods encode/init withCoder

Marek.

On Mon, Sep 21, 2015 at 8:09 PM, Kurt Sutter  wrote:

> Hi all
>
> I am trying to figure out how to store information about my windows and
> views in a document, and how to restore it. Note that I am talking about
> storing the information in the document itself, not in the application’s
> preferences settings.
>
> Specifically, I have a child of NSDocument that saves its model data using
> dataOfType:error: and restores it using readFromData:ofType:error: That
> works fine. Now, that document may have a variable number of windows for
> showing aspects of the data of the document’s model, and each window has a
> number of views. The windows and views contain state information, such as
> scroll positions, window positions, zoom factors, etc.
>
> I want the state information of the windows and views to be stored in the
> document so that the same windows and views reopen when the user opens the
> document.
>
> What is the best way to do that? I guess I have to take two steps:
>
> (a) collect that state information in dataOfType:error: and store it in
> the NSData object to be returned and
> (b) retrieve that data from the NSDocument in readFromData:ofType:error:
> and then somehow apply it in the NSDocument’s makeWindowControllers method.
>
> While both of this is certainly feasible, I am not sure what is the most
> elegant way to do it. Do I run encodeWithCoder against the document’s
> window controllers during save, and then somehow restore the window
> controllers in the makeWindowControllers? Or what else?
>
> I have tried to find pointers on how to do this in the most elegant
> manner, but I found nothing useful. So I would greatly appreciate any
> proposals.
>
> Thanks in advance
>
> Kurt
> ___
>
> 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/xhruso00%40gmail.com
>
> This email sent to xhrus...@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: Saving window and view state with NSDocument

2015-09-21 Thread Quincey Morris
On Sep 21, 2015, at 11:09 , Kurt Sutter  wrote:
> 
> I want the state information of the windows and views to be stored in the 
> document so that the same windows and views reopen when the user opens the 
> document.
> 
> What is the best way to do that? I guess I have to take two steps:
> 
> (a) collect that state information in dataOfType:error: and store it in the 
> NSData object to be returned and
> (b) retrieve that data from the NSDocument in readFromData:ofType:error: and 
> then somehow apply it in the NSDocument’s makeWindowControllers method.

You don’t mention OS X state restoration:


https://developer.apple.com/library/prerelease/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html
 


(under heading "Windows Are Restored Automatically”), but that sounds like what 
you’re looking for.

Note that state restoration is extremely badly documented in Apple’s 
documentation. You’ll need to sift through API for individual classes and 
protocols, and sometimes look at the Obj-C header comments, to get a reasonably 
complete picture of what’s going on.

There are probably some relevant WWDC videos, perhaps starting with "Resume and 
Automatic Termination in Lion” from 2011.
___

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: iOS 9 or Watch App

2015-09-21 Thread Raglan T. Tiger

-rags



> On Sep 21, 2015, at 11:57 AM, Conrad Shultz  wrote:
> 
> 
>> On Sep 21, 2015, at 6:20 AM, Michael David Crawford  
>> wrote:
>> 
>> however you may only have one version of the command line tools
>> installed in /usr/bin and the like.
> 
> You might take a look at 
> https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
>  
> 
> 
> -Conrad


I don't keep multiple versions of Xcode and in the past anytime I updated the 
currently installed version was overwritten as I expect.

When Xcode 7 was installed ( not the beta preview ) I expected the same 
behavior.

Seems like some kind of Apple glitch.

I restored version 6.2 from Time Machine and now the App Store shows Xcode 7 as 
an available update.

Does anyone know if Xcode 7 should show as version 7 in the Finder  preview 
panel?

-rags







___

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: Saving window and view state with NSDocument

2015-09-21 Thread Marek Hrušovský
Personally I would do it like this:
1. Figure out what values you need to store
2. Create custom object called configuration; for each window one kind
3. Make it conform nscoding and add a delegate property (which will point
to windowcontroller)
3. implement initwithcoder/encodewithcoder
3. add this to your model

Saving:
As usual

Loading
1. override setDocument on your windowController
2. call super
3. get the configuration from document, set it's delegate and apply it
where you need it

I thought of other approaches but they were more ugly or involved more code.
BTW you decided to fight against framework (as others mentioned state
restoration is responsible for this).
Also don't forget to call updateChangeCount (if you don't support undo).



On Mon, Sep 21, 2015 at 9:46 PM, Kurt Sutter  wrote:

> Thanks, Marek
>
> So how would I go at this? Since I want to store that data into the
> document, I’d need, in dataOfType:error:, to create a NSKeyedArchiver, and
> then would I just encode self.windowControllers? Then,
> in readFromData:ofType:error:, I would read in the coder, and in
> makeWindowControllers I would then re-create the window controllers? Would
> that work? (I have started to try exactly that, but I have not yet
> succeeded with making it work. It somehow seems a bold thing to do.)
>
> Kurt
>
>
>
> On 21 Sep 2015, at 20:22, Marek Hrušovský  wrote:
>
> I am far from architect but each window has an option "initWithCoder" and
> within XIB you can specify option "prefer coder instantiation". The
> information you want to store is not related to the model object (within
> document) cannot be reused.
> So basically I would implement NSCoder methods encode/init withCoder
>
> Marek.
>
> On Mon, Sep 21, 2015 at 8:09 PM, Kurt Sutter  wrote:
>
>> Hi all
>>
>> I am trying to figure out how to store information about my windows and
>> views in a document, and how to restore it. Note that I am talking about
>> storing the information in the document itself, not in the application’s
>> preferences settings.
>>
>> Specifically, I have a child of NSDocument that saves its model data
>> using dataOfType:error: and restores it using readFromData:ofType:error:
>> That works fine. Now, that document may have a variable number of windows
>> for showing aspects of the data of the document’s model, and each window
>> has a number of views. The windows and views contain state information,
>> such as scroll positions, window positions, zoom factors, etc.
>>
>> I want the state information of the windows and views to be stored in the
>> document so that the same windows and views reopen when the user opens the
>> document.
>>
>> What is the best way to do that? I guess I have to take two steps:
>>
>> (a) collect that state information in dataOfType:error: and store it in
>> the NSData object to be returned and
>> (b) retrieve that data from the NSDocument in readFromData:ofType:error:
>> and then somehow apply it in the NSDocument’s makeWindowControllers method.
>>
>> While both of this is certainly feasible, I am not sure what is the most
>> elegant way to do it. Do I run encodeWithCoder against the document’s
>> window controllers during save, and then somehow restore the window
>> controllers in the makeWindowControllers? Or what else?
>>
>> I have tried to find pointers on how to do this in the most elegant
>> manner, but I found nothing useful. So I would greatly appreciate any
>> proposals.
>>
>> Thanks in advance
>>
>> Kurt
>> ___
>>
>> 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/xhruso00%40gmail.com
>>
>> This email sent to xhrus...@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