Re: How to draw a NSView on top of a WebView and don't get overriden trying

2015-05-14 Thread Mike Abdullah

> On 14 May 2015, at 03:43, Michael David Crawford  wrote:
> 
> would it work render the web view in an offscreen buffer, then copy
> that onto an on-screen view of your own?
> 
> At that point you could either have your child view, or simply draw
> into one big view.

That works for much web content, but not all. If you want to include things in 
web pages like Flash, video content, or 3D effects, those render using Core 
Animation or similar, and won’t be captured by offscreen rendering.


___

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: How to draw a NSView on top of a WebView and don't get overriden trying

2015-05-14 Thread Uli Kusterer
Two things I’d try:

1) Make your view layer-backed
2) Ensure that your view is a peer, not a subview of the web view.

Any of that your issue?

> On 14 May 2015, at 03:31, Juanjo Conti  wrote:
> 
> I'm writing a screen saver, so using another window is not possible :(
> 
> On Tue, May 12, 2015 at 6:00 PM, Mike Abdullah 
> wrote:
> 
>> The failsafe way is to place a child window over the WebView. I’m not 100%
>> sure but I think popovers work that way behind the scenes, so maybe one of
>> them would be usable for this.
>> 
>>> On 12 May 2015, at 22:44, Juanjo Conti  wrote:
>>> 
>>> I have a WebView and I want to show some messages over it. For this I'm
>>> using a NSView.
>>> 
>>> If I add it as a subView of WebView or if I add it as a subView of the
>>> WebView's superView, it's shown for a while but if the WebView gets
>>> scrolled or if I load sites gmail.com or twitter (without logging in),
>> the
>>> website hides my NSView.
>>> 
>>> Is this a known problem? is there any solution?
>>> 
>>> Thanks in advance,
>>> --
>>> 
>>> Juanjo Conti http://goog_2023646312>@carouselapps.com
>>> >
>>> 
>>> Software Engineer - Carousel Apps 
>>> 
>>> --
>>> Carousel Apps Limited, registered in England & Wales with registered
>> number
>>> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
>>> Street, London SE1 3HN. Any communication sent by or on behalf of
>> Carousel
>>> App Ltd or any of its subsidiary, holding or affiliated companies or
>>> entities (together "Watu") is confidential and may be privileged or
>>> otherwise protected. If you receive it in error please inform us and then
>>> delete it from your system. You should not copy it or disclose its
>> contents
>>> to anyone. Messages sent to and from Watu may be monitored to ensure
>>> compliance with our internal policies and to protect our business. Emails
>>> are not secure and cannot be guaranteed to be error free. Anyone who
>>> communicates with us by email is taken to accept these risks.
>>> ___
>>> 
>>> 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/mabdullah%40karelia.com
>>> 
>>> This email sent to mabdul...@karelia.com
>> 
>> 
> 
> 
> -- 
> 
> Juanjo Conti http://goog_2023646312>@carouselapps.com
> >
> 
> Software Engineer - Carousel Apps 
> 
> -- 
> Carousel Apps Limited, registered in England & Wales with registered number 
> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
> App Ltd or any of its subsidiary, holding or affiliated companies or 
> entities (together "Watu") is confidential and may be privileged or 
> otherwise protected. If you receive it in error please inform us and then 
> delete it from your system. You should not copy it or disclose its contents 
> to anyone. Messages sent to and from Watu may be monitored to ensure 
> compliance with our internal policies and to protect our business. Emails 
> are not secure and cannot be guaranteed to be error free. Anyone who 
> communicates with us by email is taken to accept these risks.
> ___
> 
> 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/witness.of.teachtext%40gmx.net
> 
> This email sent to witness.of.teacht...@gmx.net

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


___

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: How to draw a NSView on top of a WebView and don't get overriden trying

2015-05-14 Thread Juanjo Conti
I've tried 2 and didn't work. How do I do 1?

On Thu, May 14, 2015 at 7:46 AM, Uli Kusterer 
wrote:

> Two things I’d try:
>
> 1) Make your view layer-backed
> 2) Ensure that your view is a peer, not a subview of the web view.
>
> Any of that your issue?
>
> > On 14 May 2015, at 03:31, Juanjo Conti  wrote:
> >
> > I'm writing a screen saver, so using another window is not possible :(
> >
> > On Tue, May 12, 2015 at 6:00 PM, Mike Abdullah 
> > wrote:
> >
> >> The failsafe way is to place a child window over the WebView. I’m not
> 100%
> >> sure but I think popovers work that way behind the scenes, so maybe one
> of
> >> them would be usable for this.
> >>
> >>> On 12 May 2015, at 22:44, Juanjo Conti 
> wrote:
> >>>
> >>> I have a WebView and I want to show some messages over it. For this I'm
> >>> using a NSView.
> >>>
> >>> If I add it as a subView of WebView or if I add it as a subView of the
> >>> WebView's superView, it's shown for a while but if the WebView gets
> >>> scrolled or if I load sites gmail.com or twitter (without logging in),
> >> the
> >>> website hides my NSView.
> >>>
> >>> Is this a known problem? is there any solution?
> >>>
> >>> Thanks in advance,
> >>> --
> >>>
> >>> Juanjo Conti http://goog_2023646312>@carouselapps.com
> >>> >
> >>>
> >>> Software Engineer - Carousel Apps 
> >>>
> >>> --
> >>> Carousel Apps Limited, registered in England & Wales with registered
> >> number
> >>> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
> >>> Street, London SE1 3HN. Any communication sent by or on behalf of
> >> Carousel
> >>> App Ltd or any of its subsidiary, holding or affiliated companies or
> >>> entities (together "Watu") is confidential and may be privileged or
> >>> otherwise protected. If you receive it in error please inform us and
> then
> >>> delete it from your system. You should not copy it or disclose its
> >> contents
> >>> to anyone. Messages sent to and from Watu may be monitored to ensure
> >>> compliance with our internal policies and to protect our business.
> Emails
> >>> are not secure and cannot be guaranteed to be error free. Anyone who
> >>> communicates with us by email is taken to accept these risks.
> >>> ___
> >>>
> >>> 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/mabdullah%40karelia.com
> >>>
> >>> This email sent to mabdul...@karelia.com
> >>
> >>
> >
> >
> > --
> >
> > Juanjo Conti http://goog_2023646312>@carouselapps.com
> > >
> >
> > Software Engineer - Carousel Apps 
> >
> > --
> > Carousel Apps Limited, registered in England & Wales with registered
> number
> > 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
> > Street, London SE1 3HN. Any communication sent by or on behalf of
> Carousel
> > App Ltd or any of its subsidiary, holding or affiliated companies or
> > entities (together "Watu") is confidential and may be privileged or
> > otherwise protected. If you receive it in error please inform us and then
> > delete it from your system. You should not copy it or disclose its
> contents
> > to anyone. Messages sent to and from Watu may be monitored to ensure
> > compliance with our internal policies and to protect our business. Emails
> > are not secure and cannot be guaranteed to be error free. Anyone who
> > communicates with us by email is taken to accept these risks.
> > ___
> >
> > 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/witness.of.teachtext%40gmx.net
> >
> > This email sent to witness.of.teacht...@gmx.net
>
> Cheers,
> -- Uli Kusterer
> “The Witnesses of TeachText are everywhere...”
> http://zathras.de
>
>


-- 

Juanjo Conti http://goog_2023646312>@carouselapps.com
>

Software Engineer - Carousel Apps 

-- 
Carousel Apps Limited, registered in England & Wales with registered number 
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
App Ltd or any of its subsidiary, holding or affiliated companies or 
entities (together "Watu") is confidential and may be privileged or 
otherwise protected. If you receive it in error please inform us and then 
delete it from your system. You should not copy it or disclose its contents 
to anyone. Messages sent to and from Watu may be monitored to ensure 
compliance with our internal policies

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-14 Thread William Squires
Thanks, I didn't even think of that, but yeah, it would be easier. Still, I'd 
like to know how to properly write a value transformer in Swift.

On May 12, 2015, at 5:38 PM, Quincey Morris 
 wrote:

> On May 12, 2015, at 14:29 , William Squires  wrote:
>> 
>> class IsNotEmptyTransformer : NSValueTransformer
>> {
>> }
>> 
>> but the example in the documentation is in ObjC, not Swift, and refers to 
>> id, not to "Bool"s or "String"s. Hints, anyone?
> 
> Using a value transformer at all seems like a poor choice, and using one in 
> Swift seems even less desirable.
> 
> If you are intent on using one, you’ll need to ask a more specific question. 
> What ‘id’ are you referring to? If you’re talking about the transformed 
> value, then you have to use an object — specifically NSNumber to represent a 
> boolean value. IOW, for your use case, the transformer would transform 
> between NSNumber and NSString.
> 
> Surely it would be far easier, though, to do what you would do in a modern 
> Obj-C app: use a derived property. Add a new property to the window 
> controller:
> 
> class MyWindowController : NSWindowController
> {
>  dynamic var message: String
>  dynamic var messageIsEmpty: Bool {return String == “”}
> 
> and bind the button’s Enabled binding to the “messageIsEmpty” property. 
> That’s not quite all, though, because as it stands, “messageIsEmpty” isn’t 
> KVO-compliant, so you also need to add:
> 
>  static var keyPathsForValuesAffectingMessageIsEmpty: NSSet {return NSSet 
> (object: "messageIsEmpty”)}
> 
> (All code written in Mail, not tested.)
> 

___

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

Fast enumeration question.

2015-05-14 Thread Alex Zavatone
I'm sure this will sound like the noobiest question ever, but with Fast 
Enumeration, if in an if statement within the loop, is there a way to stop loop 
execution and essentially do a "proceed to the next item in the list please"?

Interested in something like BASIC's next repeat or something to that effect.

In my scanning of the Apple docs, I didn't see that.  Does break do that or 
simply break out of the loop all together?

For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 4 
and keep going.

Thanks much.
___

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: Fast enumeration question.

2015-05-14 Thread Mike Abdullah
You want:

continue;

Same as a regular for loop in C.

> On 14 May 2015, at 18:09, Alex Zavatone  wrote:
> 
> I'm sure this will sound like the noobiest question ever, but with Fast 
> Enumeration, if in an if statement within the loop, is there a way to stop 
> loop execution and essentially do a "proceed to the next item in the list 
> please"?
> 
> Interested in something like BASIC's next repeat or something to that effect.
> 
> In my scanning of the Apple docs, I didn't see that.  Does break do that or 
> simply break out of the loop all together?
> 
> For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 
> 4 and keep going.
> 
> Thanks much.
> ___
> 
> 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/mabdullah%40karelia.com
> 
> This email sent to mabdul...@karelia.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: Fast enumeration question.

2015-05-14 Thread William Squires
Not as far as I know; this is one of those times when you're better off doing a 
manual loop with a regular for( ; ; ) {} statement; then you can test the loop 
iterator with a switch() and take appropriate action (or none at all, if 
desired.)

On May 14, 2015, at 11:09 AM, Alex Zavatone  wrote:

> I'm sure this will sound like the noobiest question ever, but with Fast 
> Enumeration, if in an if statement within the loop, is there a way to stop 
> loop execution and essentially do a "proceed to the next item in the list 
> please"?
> 
> Interested in something like BASIC's next repeat or something to that effect.
> 
> In my scanning of the Apple docs, I didn't see that.  Does break do that or 
> simply break out of the loop all together?
> 
> For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 
> 4 and keep going.
> 
> Thanks much.
> ___
> 
> 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/wsquires%40satx.rr.com
> 
> This email sent to wsqui...@satx.rr.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: Fast enumeration question.

2015-05-14 Thread Roland King
'continue’

Just like other c loop constructs. 



> On 15 May 2015, at 12:09 am, Alex Zavatone  wrote:
> 
> I'm sure this will sound like the noobiest question ever, but with Fast 
> Enumeration, if in an if statement within the loop, is there a way to stop 
> loop execution and essentially do a "proceed to the next item in the list 
> please"?
> 
> Interested in something like BASIC's next repeat or something to that effect.
> 
> In my scanning of the Apple docs, I didn't see that.  Does break do that or 
> simply break out of the loop all together?
> 
> For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 
> 4 and keep going.
> 
> Thanks much.
> ___
> 

___

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: Fast enumeration question.

2015-05-14 Thread Alex Zavatone
Just tested Mike's suggestion and "continue" does the trick.

Here's a test that verifies that..

 NSArray *myStuff = [[NSArray alloc]initWithObjects:@"A", @"B", @"Puppies", 
@"C",@"D", nil];

for (NSString *myThing in myStuff) {
if ([myThing isEqualToString:@"Puppies"]) {
continue;
}

NSLog(@"%@",myThing);

}

2015-05-14 12:19:10.422 test[6083:207] A
2015-05-14 12:19:10.423 test[6083:207] B
2015-05-14 12:19:10.423 test[6083:207] C
2015-05-14 12:19:10.424 test[6083:207] D



On May 14, 2015, at 12:15 PM, William Squires wrote:

> Not as far as I know; this is one of those times when you're better off doing 
> a manual loop with a regular for( ; ; ) {} statement; then you can test the 
> loop iterator with a switch() and take appropriate action (or none at all, if 
> desired.)
> 
> On May 14, 2015, at 11:09 AM, Alex Zavatone  wrote:
> 
>> I'm sure this will sound like the noobiest question ever, but with Fast 
>> Enumeration, if in an if statement within the loop, is there a way to stop 
>> loop execution and essentially do a "proceed to the next item in the list 
>> please"?
>> 
>> Interested in something like BASIC's next repeat or something to that effect.
>> 
>> In my scanning of the Apple docs, I didn't see that.  Does break do that or 
>> simply break out of the loop all together?
>> 
>> For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 
>> 4 and keep going.
>> 
>> Thanks much.
>> ___
>> 
>> 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/wsquires%40satx.rr.com
>> 
>> This email sent to wsqui...@satx.rr.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/zav%40mac.com
> 
> This email sent to z...@mac.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

Optionals? A better option!

2015-05-14 Thread William Squires
or, to put it another way; "optional Optionals, a better " :)

Option 1 (1?):
  Have the compiler/linker enforce that all variables are initialized to zero 
(Int, Float, Double), false (Bool), empty (String, array, dictionary), or nil 
(object reference) if the coder doesn't specify them. (in the case of an 
enumeration, it would either be the 1st enumerated constant, or the one whose 
raw value = 0; implicitly or explicitly)

If i say:

var i: Int

I should get i = 0 by default, but I could still write

var i: Int = 3

if I want i to start with the value of 3. I can even do:

var i: Int

i = 3

if I want, but at least I won't get a random value (like in C) if I do forget 
to initialize it myself. There's not really any need for optional values if all 
variables are always initialized. And - as a programmer - you can always revert 
to initializing it to a 'canary' value (with an appropriately named constant; 
no magic numbers, please!) that you can test against after receiving user 
input, which IMHO, is good defensive programming, anyway.
  Swift shows promise, but - like all computer languages - it's a trade-off 
between generated code side, and the amount of abstraction the language 
presents to those using it, making it easier to turn ideas into code. Making a 
(more abstract) language unnecessarily complicated with '?' and '!' doesn't 
seem to be going in the right direction, while making string concatenation less 
complicated with an overloaded '+' operator does seem to be going in the right 
direction (now, if we can only make extracting substrings less complicated, 
that'll be even better! It's currently a pain-in-the-compiler-backend!)

Option 2:
  The other option would be to have methods/functions that return an optional 
be named in such a way that indicates you're going to receive an optional as a 
return value. For example:

var str = "123"
var i: Int = str.toInt()

would, on the surface of it, seem fairly obvious. But this is a trap for noobs 
- .toInt() returns String?, not String, thus you'll get a compiler error. OTOH, 
if it were called, ".toIntQuestion" as:

var i: Int = str.toIntQuestion()  // Now it's fairly obvious you forgot the "?" 
somewhere!

then the method name would indicate that you should expect to receive an Int?, 
making it much more obvious why the compiler is asking if you want to "fix" it 
by inserting a "?" or "!" Likewise, if a method returns NSTableViewCell!, then 
it would be named, ".toNStableViewCellBang", or "toNSTableViewCellExclam" (or 
some such).
  This isn't necessary with outlets, though, as IB will generate the proper 
syntax for you if you control-drag from the control to the .swift file; you'll 
get

@IBOutlet weak var tableView: NSTableView!

with no muss or fuss, assuming you named the outlet "tableView".




___

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: Fast enumeration question.

2015-05-14 Thread William Squires
Oh well, "continue" it is. Though you can still do it manually, if you want! :)

On May 14, 2015, at 11:15 AM, William Squires  wrote:

> Not as far as I know; this is one of those times when you're better off doing 
> a manual loop with a regular for( ; ; ) {} statement; then you can test the 
> loop iterator with a switch() and take appropriate action (or none at all, if 
> desired.)
> 
> On May 14, 2015, at 11:09 AM, Alex Zavatone  wrote:
> 
>> I'm sure this will sound like the noobiest question ever, but with Fast 
>> Enumeration, if in an if statement within the loop, is there a way to stop 
>> loop execution and essentially do a "proceed to the next item in the list 
>> please"?
>> 
>> Interested in something like BASIC's next repeat or something to that effect.
>> 
>> In my scanning of the Apple docs, I didn't see that.  Does break do that or 
>> simply break out of the loop all together?
>> 
>> For example, if I'm counting from 1 to 10, hit 3, I want the loop to skip to 
>> 4 and keep going.
>> 
>> Thanks much.
>> ___
>> 
>> 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/wsquires%40satx.rr.com
>> 
>> This email sent to wsqui...@satx.rr.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: Optionals? A better option!

2015-05-14 Thread Quincey Morris
On May 14, 2015, at 09:50 , William Squires  wrote:
> 
>  Have the compiler/linker enforce that all variables are initialized to zero 
> (Int, Float, Double), false (Bool), empty (String, array, dictionary), or nil 
> (object reference) if the coder doesn't specify them. (in the case of an 
> enumeration, it would either be the 1st enumerated constant, or the one whose 
> raw value = 0; implicitly or explicitly)

The problem being solved in Swift is to *eliminate* the brute-force 
initialization of instance variables. That’s in part because the Obj-C standard 
of getting all-zero-bits isn’t necessarily the correct value in all cases, and 
in part because the zeroing is duplicative when there is code to initialize 
ivars explicitly too.

You may think this duplication is minor, but it starts to matter when the 
language (e.g. Swift) has “value classes” (i.e. structs that can have 
initializers and methods). In that case, there can be a lot of creating new 
struct instances, and it’s desirable to avoid emitting code for unnecessary 
initializations.

> There's not really any need for optional values if all variables are always 
> initialized.

I think you’re utterly wrong about this. Optionality is not just about making 
sure that variables are initialized. It’s also about introducing a language 
construct that expresses the fact that some variables don’t always have a 
value. For example, you can’t put nil pointers in a NSArray, which means you 
can’t easily have a sparse array. Similarly, you don’t have a direct way of 
expressing the fact that a function might return a value or not. This is not 
about initialization, it’s about optionality of values, so why not have 
optionality as a first class language concept?

> And - as a programmer - you can always revert to initializing it to a 
> 'canary' value (with an appropriately named constant; no magic numbers, 
> please!) that you can test against after receiving user input, which IMHO, is 
> good defensive programming, anyway.

Yes, we have [NSNull null] and NSNotFound, for example. However, these are 
*terrible* solutions to the problem — though the only solution Obj-C has, so 
they don’t always seem terrible when you’re used to them.

The problem with [NSNull null] is that it has the wrong class. That means you 
always have to code around it.

NSNotFound has several problems:

— You don’t (officially) know *where* in the range of possible integer numbers 
it is, so you don’t know when calculations near that value are dangerous

— It’s used in both signed and unsigned contexts, so it really has 2 values

— Archiving a variable with the value NSNotFound is dangerous, because it’s not 
32/64-bit agnostic. That is, if you archive it when NSUInteger is 32 bits, and 
unarchive it when NSUInteger is 64 bits, it’s not going to be NSNotFound any 
more.

___

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: Optionals? A better option!

2015-05-14 Thread Kyle Sluder
On Thu, May 14, 2015, at 12:34 PM, Quincey Morris wrote:
> — It’s used in both signed and unsigned contexts, so it really has 2
> values

FWIW, NSNotFound is defined as NSIntegerMax, so it has the same value in
both signed and unsigned contexts.

--Kyle Sluder

___

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

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

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

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

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-14 Thread Quincey Morris
On May 14, 2015, at 08:40 , William Squires  wrote:
> 
> I'd like to know how to properly write a value transformer in Swift.

Something like this, I expect:

> class StringNotNilTransformer: NSObject {
>   
>   static var transformedValueClass: AnyClass { return NSNumber.self }
>   static let allowsReverseTransformation = false
>   
>   func transformedValue (value: AnyObject?) -> AnyObject? {
>   if let string = value as? String {
>   return NSNumber (bool: string != "");
>   }
>   return NSNumber (bool: false);
>   }
> }


I only checked this in a playground, but I suspect the following slightly 
simpler version would also work too:

> class StringNotNilTransformer: NSObject {
>   
>   static var transformedValueClass: AnyClass { return NSNumber.self }
>   static let allowsReverseTransformation = false
>   
>   func transformedValue (value: AnyObject?) -> AnyObject? {
>   if let string = value as? String {
>   return string != "";
>   }
>   return false;
>   }
> }



___

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: Optionals? A better option!

2015-05-14 Thread Quincey Morris
On May 14, 2015, at 10:52 , Kyle Sluder  wrote:
> 
> FWIW, NSNotFound is defined as NSIntegerMax, so it has the same value in
> both signed and unsigned contexts.

a. Oh, yeah, I knew that. 

b. It kinda proves my point, though. I write enough Obj-C code that I shouldn’t 
confuse myself about this, but I just did.



___

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: Optionals? A better option!

2015-05-14 Thread Jens Alfke
With all due respect, I think you’re falling into the common engineer pitfall 
of jumping to the conclusion that there’s a trivial solution without first 
understanding the problem. (Sometimes expressed as “any bug in your program is 
trivial; any bug I have to fix is intractable.”) Which is to say that, if you 
really want to engage in productive debate or provide alternatives, you should 
spend some time learning the theory behind languages and also looking at 
non-C-like languages, especially functional ones. (Apologies if you’ve got such 
experience, but based on your answer I’m guessing you don’t.)

I’m not terribly qualified here; I’ve dabbled in language and compiler design 
in the distant past. Not enough to make me an expert, but enough to make me 
respect that there are a lot of hidden difficulties and ramifications to even 
simple language features.

Optionals come out of a long line of thinking in functional programming 
languages. The broader idea is that if a value can have multiple mutually 
exclusive states (in this case “has a value” vs “has no value”) then those 
states should be tagged and should require explicit action to select between. 
That’s basically what Swift enums are (and the same concept is found in a lot 
of other languages like Haskell, Erlang, Scala, Rust…)

There’s a school of thought that null pointers are harmful; optionals are a 
reaction to that. I just looked up the source — Tony Hoare gave a presentation 
where he formally apologized for inventing null pointers in 1965 as part of 
ALGOL W:

"I call it my billion-dollar mistake. It was the invention of the null 
reference in 1965. At that time, I was designing the first comprehensive type 
system for references in an object oriented language (ALGOL W). My goal was to 
ensure that all use of references should be absolutely safe, with checking 
performed automatically by the compiler. But I couldn't resist the temptation 
to put in a null reference, simply because it was so easy to implement. This 
has led to innumerable errors, vulnerabilities, and system crashes, which have 
probably caused a billion dollars of pain and damage in the last forty years.”
— http://en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retractions 


It’s a great quote, but I don’t think that was the first appearance of null. 
LISP dates back to the late ‘50s and has always had nil references (right?)

—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: How to draw a NSView on top of a WebView and don't get overriden trying

2015-05-14 Thread David Durkee
This is an entirely different approach, and requires a different skill set, but 
could you use JavaScript to inject your content into the DOM of the web page 
being displayed as a floating element? Use 
stringByEvaluatingJavaScriptFromString: to execute your own JavaScript.

David

> On May 13, 2015, at 8:31 PM, Juanjo Conti  > wrote:
> 
> I'm writing a screen saver, so using another window is not possible :(
> 

___

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

Core Data Mapping Model and empty filter predicates

2015-05-14 Thread Rick Mann
I've run into an issue that I haven't seen before with our mapping models: If 
the filter predicate was set, and is then cleared, migration complains about 
the empty filter predicate with:

NSInvalidArgumentException: Unable to parse the format string ""

I'm having to hand-edit the mapping XML files to remove the 
"sourcefilterpredicatestring" attribute tag altogether in order to make it 
happy.

Is this a bug introduced in Xcode 6.3.1, that emptying the editor Filter 
Predicate field leaves an empty XML tag, that the migration code can't handle? 
That's what seems to be happening, but I haven't checked against an older 
version of Xcode to see if it doesn't do that.

-- 
Rick Mann
rm...@latencyzero.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: Fast enumeration question.

2015-05-14 Thread Charles Srstka
On May 14, 2015, at 11:52 AM, William Squires  wrote:
> 
> Oh well, "continue" it is. Though you can still do it manually, if you want! 
> :)

While that’s true, fast enumeration performs better.

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