watchOS

2016-12-06 Thread Gerriet M. Denkmann
watchOS 3
The watchApp  has NotificationController ← WKUserNotificationInterfaceController

watchApp gets a Local Notification with one associated UNNotificationAction 
with title = “Accept”

[NotificationController init]
[NotificationController didReceiveNotification:withCompletion:]
[NotificationController willActivate]

now the notification is shown with two buttons:
“Accept”
“Dismiss”

So  far ok.

But I have no idea how to tell whether the user did click on “Accept” or 
“Dismiss” .

On iOS I would use the UNUserNotificationCenterDelegate method
userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
but this is never called on watchOS.

It is called on the paired iOS app, but this does not help much. The watchApp 
needs to know whether the user did accept the Notification or not.

Gerriet.


___

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

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

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

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

Re: Representing an object graph

2016-12-06 Thread Chris Hanson
On Dec 5, 2016, at 4:18 PM, Daryle Walker  wrote:

> I've heard that Core Data is a object graph and persistence library. What if 
> you want just the first part?  The graph seems like a neat way to save on 
> modeling code, the external format is not database-ish at all (so the 
> capability for custom export formats won't help). Can I just not use the 
> persistence part and use custom save & load functions? Or do I have to (or 
> should) give up on Core Data?

This is exactly the sort of thing that subclassing NSAtomicStore 
 lets you do.

There are only a few methods to override, and then you can just use one of your 
own documents as if it were one of the built-in persistent store types.

  -- Chris

___

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

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

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

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


UINavigationBar content margins in UIPresentationController subclass

2016-12-06 Thread Daniel Stenmark
I have a UIPresentationController subclass with a UINavigationBar embedded in 
the container view.  However, when setting the rightBarButtonItem, the spacing 
I usually expect from the item to the screen isn't there.

http://imgur.com/LHcqhyd

Anyone have an idea where I might be going wrong here?  The relevant code for 
the presentation controller is as follows:

@objc public protocol SheetPresentationControllerDelegate : class {
func sheetPresentationControllerWillDismiss(_ sheetPresentationController: 
SheetPresentationController)
}

open class SheetPresentationController: UIPresentationController {



fileprivate let dimmedView: UIView = {
let result = UIView()
result.backgroundColor = .black
result.alpha = 0
result.autoresizingMask = [.flexibleWidth, .flexibleHeight]
return result
}()



fileprivate let topView: UIView = {
let result = UIView()
result.backgroundColor = .white
return result
}()



fileprivate let navigationBar: UINavigationBar = {
let result = UINavigationBar()
result.backgroundColor = .white
result.items = [UINavigationItem()]
return result
}()



open var title: String? {
get {
return self.navigationBar.topItem?.title
}
set {
self.navigationBar.topItem?.title = newValue
}
}



open var titleView: UIView? {
get {
return self.navigationBar.topItem?.titleView
}
set {
self.navigationBar.topItem?.titleView = newValue
}
}



open weak var sheetDelegate: SheetPresentationControllerDelegate?



fileprivate dynamic func dismiss(_ sender: NSObject) {
self.presentingViewController.dismiss(animated: true, completion: nil)
}



override open func presentationTransitionWillBegin() {
super.presentationTransitionWillBegin()



guard let containerView = self.containerView else {
return
}



containerView.addSubview(self.dimmedView)
self.dimmedView.frame = CGRect(origin: .zero, size: 
containerView.bounds.size)



let gestureRecognizer = UITapGestureRecognizer(target: self, action: 
#selector(dismiss))
self.dimmedView.addGestureRecognizer(gestureRecognizer)



self.presentedViewController.transitionCoordinator?.animate( 
alongsideTransition: { (context) in
self.dimmedView.alpha = 0.5



}, completion: nil)



containerView.addSubview(self.topView)
containerView.addSubview(self.navigationBar)



self.navigationBar.topItem?.rightBarButtonItems = 
[UIBarButtonItem(title: NSLocalizedString("Done", comment: ""), style: .done, 
target: self, action: #selector(dismiss))]
}



override open func dismissalTransitionWillBegin() {
super.dismissalTransitionWillBegin()



self.sheetDelegate?.sheetPresentationControllerWillDismiss(self)



self.presentedViewController.transitionCoordinator?.animate( 
alongsideTransition: { (context) in
self.dimmedView.alpha = 0



}, completion: nil)
}



override open var frameOfPresentedViewInContainerView : CGRect {
return CGRect(x: 0, y: self.navigationBar.frame.origin.y + 
self.navigationBar.intrinsicContentSize.height, width: 
self.containerView?.bounds.width ?? 0, height: 
self.presentedViewController.preferredContentSize.height)
}



override open func containerViewWillLayoutSubviews() {
super.containerViewWillLayoutSubviews()



self.topView.frame = CGRect(x: 0, y: 0, width: 
self.containerView?.bounds.width ?? 0, height: 
self.presentingViewController.topLayoutGuide.length)
self.navigationBar.frame = CGRect(x: 0, y: self.topView.frame.origin.y 
+ self.topView.bounds.height, width: self.containerView?.bounds.width ?? 0, 
height: self.navigationBar.intrinsicContentSize.height)



self.presentedView?.frame = self.frameOfPresentedViewInContainerView
}
}

Dan
___

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


Why aren't NSFilePromiseProviderDelegate methods being called?

2016-12-06 Thread Charles Srstka
Okay, so I decided to try to experiment with NSFilePromiseProvider, in order to 
replace some legacy code using old-fashioned drag-and-drop methods. However, 
for some reason, the drag-and-drop system seems to completely ignore my 
NSFilePromiseProviderDelegate methods, and calls the old-fashioned ones 
instead. If they’re not there, it throws an exception. What the heck?

Here’s the code:

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var outlineView: NSOutlineView?

class Item: NSObject {
@objc let name: String
@objc let children: [Item]

init(name: String, children: [Item] = []) {
self.name = name
self.children = children
super.init()
}
}

@IBOutlet weak var window: NSWindow!

dynamic var items = [Item(name: "Foo"), Item(name: "Bar"), Item(name: 
"Baz", children: [Item(name: "Qux")])]

func applicationDidFinishLaunching(_ aNotification: Notification) {
self.outlineView?.setDraggingSourceOperationMask(.copy, forLocal: false)
}
}

extension AppDelegate: NSOutlineViewDataSource {
func outlineView(_ outlineView: NSOutlineView, pasteboardWriterForItem 
item: Any) -> NSPasteboardWriting? {
return NSFilePromiseProvider(fileType: kUTTypePlainText as String, 
delegate: self)
}

// If this method doesn't exist, an exception is thrown on drag
func outlineView(_ outlineView: NSOutlineView, 
namesOfPromisedFilesDroppedAtDestination dropDestination: URL, forDraggedItems 
items: [Any]) -> [String] {
print("Why does this get called instead of my 
NSFilePromiseProviderDelegate methods?!")

try! "foo".write(to: dropDestination.appendingPathComponent("foo.txt"), 
atomically: true, encoding: .utf8)
return ["foo.txt"]
}
}

extension AppDelegate: NSFilePromiseProviderDelegate {
func filePromiseProvider(_ filePromiseProvider: NSFilePromiseProvider, 
fileNameForType fileType: String) -> String {
print("fileNameForType: got called with type \(fileType)")
return "foo.txt"
}

func filePromiseProvider(_ filePromiseProvider: NSFilePromiseProvider, 
writePromiseTo url: URL, completionHandler: @escaping (Error?) -> Void) {
print("writePromiseTo: got called with URL \(url)")
do {
try "foo".write(to: url, atomically: true, encoding: .utf8)
completionHandler(nil)
} catch {
completionHandler(error)
}
}
}

Output is:

Why does this get called instead of my NSFilePromiseProviderDelegate methods?!

I mean, it works, but it works using the older system. I want it to use the 
modern system. Why won’t it?

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: Documentation Workflow

2016-12-06 Thread Jens Alfke

> On Dec 6, 2016, at 3:45 PM, Carl Hoefs  wrote:
> 
> Just now I was looking for a list of NSString method signatures to peruse. 

Open NSString.h?

—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: Using floating point instructions

2016-12-06 Thread G 3


On Dec 6, 2016, at 4:41 PM, Greg Parker wrote:




On Dec 6, 2016, at 7:27 AM, G 3  wrote:

I'm working on a program that calls PowerPC assembly floating  
point instructions from C. It would have calls like this:


double inputA, inputB, answer;
asm volatile("fadd %0, %1, %2" : "=f" (answer) : "f" (inputA),  
"f" (inputB));   // answer = inputA + inputB


The odd thing is it only works in the debug configuration in  
XCode. In Release configuration, I see this error:

error: output constraint 0 must specify a single register
error: output operand 0 must use '&' constraint

Is there a way to fix this problem?


You'll get better answers from a clang list such as cfe- 
us...@lists.llvm.org. Most of the audience here probably does not  
have a copy of clang that can compile PowerPC code.


Why are you using constraint "f" here? I would expect you to use  
"d" with variables of type double.


I did a little experiment and tried this: asm volatile("fadd %0, %1, % 
2" : "=f" (answer) : "d" (inputA), "f" (inputB));


It didn't work. This is the error message I saw: error: impossible  
constraint in 'asm'.


___

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: Documentation Workflow

2016-12-06 Thread Carl Hoefs

> On Dec 3, 2016, at 11:52 AM, Richard Charles  wrote:
> 
>> On Dec 2, 2016, at 11:34 AM, Slipp Douglas Thompson 
>>  wrote:
>> 
>> Alternatively, there's always archive.org's Wayback Machine.
> 
>> Since developer.apple.com's URL paths have changed quite a bit with the 
>> recent narrow-body-giant-text-ification, I plugged 
>> https://developer.apple.com/library/ios/navigation/ into the Wayback Machine 
>> ( https://developer.apple.com/library/mac/navigation/ also works), chose a 
>> capture date a couple years ago, and then used the “Documents [ 
>> ] 4293 of 4293” search input to find the doc I was looking for.
> 
> It appears that October 21, 2014 was the last archive date for old style iOS 
> documentation and content.
> 
> It appears that November 5, 2015 was the last archive date for old style mac 
> documentation and content.
> 
> This would be a good starting point if you are looking for something older 
> that is now gone.
> 

Just now I was looking for a list of NSString method signatures to peruse. Is 
that now impossible? It seems all methods are shoveled onto a single mega-page 
called "Methods to Override", with full descriptions, but no there's no 
overview method list any more, as there is no disclosure triangle on the 
"Methods to Override" element in the left column. 

-Carl


___

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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread じょいすじょん

> On 2016 Dec 7, at 6:27, Carl Hoefs  wrote:
> 
>> 
>> On Dec 6, 2016, at 1:33 PM, Carl Hoefs  
>> wrote:
>> 
>>> On Dec 6, 2016, at 1:24 PM, David Duncan  wrote:
>>> 
>>> Your safest bets are to either clear the delegate of the layer at an 
>>> appropriate time (possibly in your view controller’s dealloc is all that is 
>>> necessary), or to use a UIView instead of a raw CALayer in this case. 
>>> Removing the layer would also suffice, as that would prevent UIKit from 
>>> seeing it at the time in question. Making the layer weak is probably 
>>> causing your reference to deallocate before it can be added to the layer 
>>> tree, which is why it doesn’t display in that case.
>> 
>> Thanks for this explanation, David! 
>> 
>> I've verified that using either of:
>>   [self.layer setDelegate:nil];
>> or
>>   [self.layer removeFromSuperlayer];
>> will prevent the crash. 
> 
> Followup: It turns out that the 'offending' line of code is:
> 
>  [self.layer setDelegate:self];
> 
> If I don't set this, everything still works correctly, and there's no crash 
> at dealloc time.
> 
> -Carl
> 
That sure looks like a circle until you remove something :)
___

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: Using floating point instructions

2016-12-06 Thread Greg Parker

> On Dec 6, 2016, at 7:27 AM, G 3  wrote:
> 
> I'm working on a program that calls PowerPC assembly floating point 
> instructions from C. It would have calls like this:
> 
> double inputA, inputB, answer;
> asm volatile("fadd %0, %1, %2" : "=f" (answer) : "f" (inputA), "f" (inputB)); 
>   // answer = inputA + inputB
> 
> The odd thing is it only works in the debug configuration in XCode. In 
> Release configuration, I see this error:
> error: output constraint 0 must specify a single register
> error: output operand 0 must use '&' constraint
> 
> Is there a way to fix this problem?

You'll get better answers from a clang list such as cfe-us...@lists.llvm.org. 
Most of the audience here probably does not have a copy of clang that can 
compile PowerPC code.

Why are you using constraint "f" here? I would expect you to use "d" with 
variables of type double.


-- 
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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread Carl Hoefs

> On Dec 6, 2016, at 1:33 PM, Carl Hoefs  wrote:
> 
>> On Dec 6, 2016, at 1:24 PM, David Duncan  wrote:
>> 
>> Your safest bets are to either clear the delegate of the layer at an 
>> appropriate time (possibly in your view controller’s dealloc is all that is 
>> necessary), or to use a UIView instead of a raw CALayer in this case. 
>> Removing the layer would also suffice, as that would prevent UIKit from 
>> seeing it at the time in question. Making the layer weak is probably causing 
>> your reference to deallocate before it can be added to the layer tree, which 
>> is why it doesn’t display in that case.
> 
> Thanks for this explanation, David! 
> 
> I've verified that using either of:
>[self.layer setDelegate:nil];
> or
>[self.layer removeFromSuperlayer];
> will prevent the crash. 

Followup: It turns out that the 'offending' line of code is:

  [self.layer setDelegate:self];

If I don't set this, everything still works correctly, and there's no crash at 
dealloc time.

-Carl


___

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: Using floating point instructions

2016-12-06 Thread Jonathan Mitchell

> On 6 Dec 2016, at 15:27, G 3  wrote:
> 
> Is there a way to fix this problem?
> 
Have you tried lowering the release build optimisation level to match the level 
used for debug build?.
It might get you on the right track.

J


___

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

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

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

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


Re: Drag UITableView up/down

2016-12-06 Thread Eric E. Dolecki
Well, not really. I'll try to explain a bit more.

I have a table and it takes up the bottom 1/2 of the screen. When a user
swipes up, instead of scrolling the cells, the table moves up the screen
until it's at 100px from the top - and at that point, the swipe scrolls the
cells up. When the table is scrolled down (the cells) to the point where
the 1st row is displayed, the swipe moves the whole table back down to a .y
of 1/2 of the screen.

The Penguins (Pittsburgh) app (powered by YinzCam) does this very well.

On Tue, Dec 6, 2016 at 3:26 PM Gary L. Wade 
wrote:

> It sounds like what you’re really wanting to do is emulate what Apple’s
> News app is doing, right?
>
> First, you set your navigation controller’s hidesBarsOnSwipe to true.  The
> next step is the more difficult one, but it depends on how you want your
> status bar to appear and if you want a mini-navigation bar rather than just
> the status bar:
>
> 1. Override your table view controller’s preferredStatusBarStyle to return
> the style that matches with your content or mini-navigation bar.  I chose
> light because I had an opaque mini-navigation bar that was dark.  You get
> the default setting if you don’t do this, and it may be difficult to see.
> 2. If you want your status bar opaque and/or a mini-navigation bar, you’ll
> need to add a subview to your table view controller’s view’s superview
> constrained to (top,left,trailing)=(0,0,0) and height=20.  If you want a
> mini-navigation bar, you’ll need to make that height what you need it to
> be.  I wanted my navigation bar to have three states like News: expanded,
> mini, collapsed.  In expanded mode, you get the normal navigation bar.  In
> mini, the height might be 40 (20 extra points for the condensed title or
> info), and 20 for collapsed.
>
> Based on my observations, News expands when you tap on the status bar in
> the collapsed mode, so you’ll need to override that operation, to provide
> that rather than jump to the top immediately.
>
> There’s some other navigation controller settings for the navigation bar
> that you may find useful around hidesBarsOnSwipe so check those out.
> --
> Gary L. Wade
> http://www.garywade.com/
>
> On Dec 6, 2016, at 11:38 AM, Eric E. Dolecki  wrote:
>
> I'm looking for a chunk of view controller code that allows for:
>
> A UITableView. You can drag the whole table up (not the cells) to a limit
> from the top of the VC, say like 100px. When you've reached that, the table
> will scroll up normally.
>
> When you scroll the table down (cells) and reach item 0, and continue to
> swipe down, the table will slide down with the gesture until a position
> from the bottom.
>
> Seems like this is a current trend in some applications. I have a lot of it
> in place, but the scrolling down until 1st row, then move table is elusive
> at the moment.
>
> A super-simple project or something to get me going would be appreciated.
>
> Thanks for your time & attention,
> Eric
>
>
>
___

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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread Carl Hoefs

> On Dec 6, 2016, at 1:24 PM, David Duncan  wrote:
> 
> Your safest bets are to either clear the delegate of the layer at an 
> appropriate time (possibly in your view controller’s dealloc is all that is 
> necessary), or to use a UIView instead of a raw CALayer in this case. 
> Removing the layer would also suffice, as that would prevent UIKit from 
> seeing it at the time in question. Making the layer weak is probably causing 
> your reference to deallocate before it can be added to the layer tree, which 
> is why it doesn’t display in that case.

Thanks for this explanation, David! 

I've verified that using either of:
[self.layer setDelegate:nil];
or
[self.layer removeFromSuperlayer];
will prevent the crash. It's just a bit
surprising to me that this is needed...

-Carl


___

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: Drag UITableView up/down

2016-12-06 Thread Gary L. Wade
It sounds like what you’re really wanting to do is emulate what Apple’s News 
app is doing, right?

First, you set your navigation controller’s hidesBarsOnSwipe to true.  The next 
step is the more difficult one, but it depends on how you want your status bar 
to appear and if you want a mini-navigation bar rather than just the status bar:

1. Override your table view controller’s preferredStatusBarStyle to return the 
style that matches with your content or mini-navigation bar.  I chose light 
because I had an opaque mini-navigation bar that was dark.  You get the default 
setting if you don’t do this, and it may be difficult to see.
2. If you want your status bar opaque and/or a mini-navigation bar, you’ll need 
to add a subview to your table view controller’s view’s superview constrained 
to (top,left,trailing)=(0,0,0) and height=20.  If you want a mini-navigation 
bar, you’ll need to make that height what you need it to be.  I wanted my 
navigation bar to have three states like News: expanded, mini, collapsed.  In 
expanded mode, you get the normal navigation bar.  In mini, the height might be 
40 (20 extra points for the condensed title or info), and 20 for collapsed.

Based on my observations, News expands when you tap on the status bar in the 
collapsed mode, so you’ll need to override that operation, to provide that 
rather than jump to the top immediately.

There’s some other navigation controller settings for the navigation bar that 
you may find useful around hidesBarsOnSwipe so check those out.
--
Gary L. Wade
http://www.garywade.com/ 
> On Dec 6, 2016, at 11:38 AM, Eric E. Dolecki  wrote:
> 
> I'm looking for a chunk of view controller code that allows for:
> 
> A UITableView. You can drag the whole table up (not the cells) to a limit
> from the top of the VC, say like 100px. When you've reached that, the table
> will scroll up normally.
> 
> When you scroll the table down (cells) and reach item 0, and continue to
> swipe down, the table will slide down with the gesture until a position
> from the bottom.
> 
> Seems like this is a current trend in some applications. I have a lot of it
> in place, but the scrolling down until 1st row, then move table is elusive
> at the moment.
> 
> A super-simple project or something to get me going would be appreciated.
> 
> Thanks for your time & attention,
> Eric

___

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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread David Duncan

> On Dec 6, 2016, at 11:51 AM, Doug Hill  wrote:
> 
> I've wondered about this before, but maybe some Objective-C runtime experts 
> know.
> 
> Does writing directly to the ivar backing a property bypass the ARC features 
> of the property. For example, will a strong property be retained if you write 
> directly to the ivar?

Yes, under ARC assigning to a strong ivar and assigning via a strong property 
are identical with respect to the resulting retain count semantics (otherwise 
typically constructed ARC-based setter methods wouldn’t work).

> 
> If not, that's your problem.
> 
> Doug
> 
>> On Dec 6, 2016, at 11:44 AM, Carl Hoefs > > wrote:
>> 
>> I get the following crash in my iOS 9 app simply by adding a CALayer to the 
>> current view controller's self.view.layer and then dismissing the current 
>> view controller. Simplified code:
>> 
>>   @property (strong,nonatomic) CALayer *layer;
>>   .  .  .
>>   _layer = [[CALayer alloc] init];
>>   [_layer setDelegate: self];
>>   [self.view.layer addSublayer:_layer];
>> 
>> Upon dismissing the VC:
>> 
>>   [self dismissViewControllerAnimated:YES completion:nil];
>> 
>> The following exception occurs:
>> 
>> (lldb) bt
>> * thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, 
>> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
>> address=0xb010)
>>   frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10
>>   frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330
>>   frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118
>>   frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630
>>   frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132
>>   frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) 
>> + 150
>>   frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous 
>> namespace)::AutoreleasePoolPage::pop(void*) + 388
>>   frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16
>>   frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598
>>   frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516
>>   frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108
>>   frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160
>>   frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144
>> * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at 
>> main.m:14
>> 
>> If I remove the CALayer first before the 
>> -dismissViewControllerAnimated:completion:, it doesn't crash:
>> 
>>   [layer removeFromSuperlayer];
>> 
>> Why do I need to explicitly remove my added CALayer before dismissing the 
>> VC? Note: If I declare layer as weak, the crash does not occur, but neither 
>> does the layer display onscreen.
>> -Carl
>> 
>> 
>> ___
>> 
>> 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/cocoadev%40breaqz.com 
>> 
>> 
>> This email sent to cocoa...@breaqz.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/david.duncan%40apple.com 
> 
> 
> This email sent to david.dun...@apple.com 
--
David Duncan

___

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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread David Duncan

> On Dec 6, 2016, at 11:44 AM, Carl Hoefs  
> wrote:
> 
> I get the following crash in my iOS 9 app simply by adding a CALayer to the 
> current view controller's self.view.layer and then dismissing the current 
> view controller. Simplified code:
> 
>@property (strong,nonatomic) CALayer *layer;
>.  .  .
>_layer = [[CALayer alloc] init];
>[_layer setDelegate: self];
>[self.view.layer addSublayer:_layer];
> 
> Upon dismissing the VC:
> 
>[self dismissViewControllerAnimated:YES completion:nil];
> 
> The following exception occurs:
> 
> (lldb) bt
> * thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, 
> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
> address=0xb010)
>frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10
>frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330
>frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118
>frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630
>frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132
>frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) 
> + 150
>frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous 
> namespace)::AutoreleasePoolPage::pop(void*) + 388
>frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16
>frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598
>frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516
>frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108
>frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160
>frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144
>  * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at 
> main.m:14

This is due to the confluence of a few UIKit implementation details. The bottom 
line is that UIKit is trying to iterate the subviews of your view controller’s 
view, encounters your layer, and tries to retain the layer’s delegate. Because 
the layer’s delegate is assign (not weak) and the view controller has already 
been deallocated, this explodes taking your app with it.

Your safest bets are to either clear the delegate of the layer at an 
appropriate time (possibly in your view controller’s dealloc is all that is 
necessary), or to use a UIView instead of a raw CALayer in this case. Removing 
the layer would also suffice, as that would prevent UIKit from seeing it at the 
time in question. Making the layer weak is probably causing your reference to 
deallocate before it can be added to the layer tree, which is why it doesn’t 
display in that case.

> 
> If I remove the CALayer first before the 
> -dismissViewControllerAnimated:completion:, it doesn't crash:
> 
>[layer removeFromSuperlayer];
> 
> Why do I need to explicitly remove my added CALayer before dismissing the VC? 
> Note: If I declare layer as weak, the crash does not occur, but neither does 
> the layer display onscreen.
> -Carl
> 
> 
> ___
> 
> 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

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: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread Carl Hoefs
FWIW, it still crashes if I change the code to use self.layer instead of _layer:

   @property (strong,nonatomic) CALayer *layer;
   .  .  .
   self.layer = [[CALayer alloc] init];
   [self.layer setDelegate: self];
   [self.view.layer addSublayer:self.layer];

-Carl

> On Dec 6, 2016, at 12:51 PM, Doug Hill  wrote:
> 
> I've wondered about this before, but maybe some Objective-C runtime experts 
> know.
> 
> Does writing directly to the ivar backing a property bypass the ARC features 
> of the property. For example, will a strong property be retained if you write 
> directly to the ivar?
> 
> If not, that's your problem.
> 
> Doug
> 
>> On Dec 6, 2016, at 11:44 AM, Carl Hoefs  
>> wrote:
>> 
>> I get the following crash in my iOS 9 app simply by adding a CALayer to the 
>> current view controller's self.view.layer and then dismissing the current 
>> view controller. Simplified code:
>> 
>>   @property (strong,nonatomic) CALayer *layer;
>>   .  .  .
>>   _layer = [[CALayer alloc] init];
>>   [_layer setDelegate: self];
>>   [self.view.layer addSublayer:_layer];
>> 
>> Upon dismissing the VC:
>> 
>>   [self dismissViewControllerAnimated:YES completion:nil];
>> 
>> The following exception occurs:
>> 
>> (lldb) bt
>> * thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, 
>> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
>> address=0xb010)
>>   frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10
>>   frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330
>>   frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118
>>   frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630
>>   frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132
>>   frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) 
>> + 150
>>   frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous 
>> namespace)::AutoreleasePoolPage::pop(void*) + 388
>>   frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16
>>   frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598
>>   frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516
>>   frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108
>>   frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160
>>   frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144
>> * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at 
>> main.m:14
>> 
>> If I remove the CALayer first before the 
>> -dismissViewControllerAnimated:completion:, it doesn't crash:
>> 
>>   [layer removeFromSuperlayer];
>> 
>> Why do I need to explicitly remove my added CALayer before dismissing the 
>> VC? Note: If I declare layer as weak, the crash does not occur, but neither 
>> does the layer display onscreen.
>> -Carl
>> 
>> 
>> ___
>> 
>> 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/cocoadev%40breaqz.com
>> 
>> This email sent to cocoa...@breaqz.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: iOS 9: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread Doug Hill
I've wondered about this before, but maybe some Objective-C runtime experts 
know.

Does writing directly to the ivar backing a property bypass the ARC features of 
the property. For example, will a strong property be retained if you write 
directly to the ivar?

If not, that's your problem.

Doug

> On Dec 6, 2016, at 11:44 AM, Carl Hoefs  
> wrote:
> 
> I get the following crash in my iOS 9 app simply by adding a CALayer to the 
> current view controller's self.view.layer and then dismissing the current 
> view controller. Simplified code:
> 
>@property (strong,nonatomic) CALayer *layer;
>.  .  .
>_layer = [[CALayer alloc] init];
>[_layer setDelegate: self];
>[self.view.layer addSublayer:_layer];
> 
> Upon dismissing the VC:
> 
>[self dismissViewControllerAnimated:YES completion:nil];
> 
> The following exception occurs:
> 
> (lldb) bt
> * thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, 
> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
> address=0xb010)
>frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10
>frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330
>frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118
>frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630
>frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132
>frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) 
> + 150
>frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous 
> namespace)::AutoreleasePoolPage::pop(void*) + 388
>frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16
>frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598
>frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516
>frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108
>frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160
>frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144
>  * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at 
> main.m:14
> 
> If I remove the CALayer first before the 
> -dismissViewControllerAnimated:completion:, it doesn't crash:
> 
>[layer removeFromSuperlayer];
> 
> Why do I need to explicitly remove my added CALayer before dismissing the VC? 
> Note: If I declare layer as weak, the crash does not occur, but neither does 
> the layer display onscreen.
> -Carl
> 
> 
> ___
> 
> 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/cocoadev%40breaqz.com
> 
> This email sent to cocoa...@breaqz.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

iOS 9: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS

2016-12-06 Thread Carl Hoefs
I get the following crash in my iOS 9 app simply by adding a CALayer to the 
current view controller's self.view.layer and then dismissing the current view 
controller. Simplified code:

@property (strong,nonatomic) CALayer *layer;
.  .  .
_layer = [[CALayer alloc] init];
[_layer setDelegate: self];
[self.view.layer addSublayer:_layer];

Upon dismissing the VC:

[self dismissViewControllerAnimated:YES completion:nil];

The following exception occurs:

(lldb) bt
* thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, queue 
= 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0xb010)
frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10
frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330
frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118
frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630
frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132
frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) + 
150
frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous 
namespace)::AutoreleasePoolPage::pop(void*) + 388
frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16
frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598
frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516
frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108
frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160
frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144
  * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at 
main.m:14

If I remove the CALayer first before the 
-dismissViewControllerAnimated:completion:, it doesn't crash:

[layer removeFromSuperlayer];

Why do I need to explicitly remove my added CALayer before dismissing the VC? 
Note: If I declare layer as weak, the crash does not occur, but neither does 
the layer display onscreen.
-Carl


___

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

Drag UITableView up/down

2016-12-06 Thread Eric E. Dolecki
I'm looking for a chunk of view controller code that allows for:

A UITableView. You can drag the whole table up (not the cells) to a limit
from the top of the VC, say like 100px. When you've reached that, the table
will scroll up normally.

When you scroll the table down (cells) and reach item 0, and continue to
swipe down, the table will slide down with the gesture until a position
from the bottom.

Seems like this is a current trend in some applications. I have a lot of it
in place, but the scrolling down until 1st row, then move table is elusive
at the moment.

A super-simple project or something to get me going would be appreciated.

Thanks for your time & attention,
Eric
___

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: radio button contrast

2016-12-06 Thread J.E. Schotsman

> On 05 Dec 2016, at 17:23, J.E. Schotsman  wrote:
> 
> Hello,
> 
> I intend to increase contrast of inactive radio buttons a little because they 
> are hardly legible.
> The idea is to draw to a bitmap, increase contrast, draw to screen.
> To my surprise this already increases contrast without any manipulation of 
> the bitmap.
> What is going on here?

To answer my own question, I forgot to clear the bitmap each time before 
drawing.
Also the bitmap itself needs to be renewed each time in order to force 
regeneration of its CGImage.

Jan E.
___

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: Large "Data" support

2016-12-06 Thread Jens Alfke

> On Dec 6, 2016, at 12:32 AM, Alastair Houghton  
> wrote:
> 
> 1. If you mmap() data, you don’t actually have to read all of it; it’s read 
> from disk on demand.

I was assuming Daryle wanted to create the Data from scratch, not read it from 
a file. If the data is read from a file, then I agree with you 100%.

—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

Using floating point instructions

2016-12-06 Thread G 3
I'm working on a program that calls PowerPC assembly floating point  
instructions from C. It would have calls like this:


double inputA, inputB, answer;
asm volatile("fadd %0, %1, %2" : "=f" (answer) : "f" (inputA),  
"f" (inputB));   // answer = inputA + inputB


The odd thing is it only works in the debug configuration in XCode.  
In Release configuration, I see this error:

error: output constraint 0 must specify a single register
error: output operand 0 must use '&' constraint

Is there a way to fix this problem?

___

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: Message from iOS to watchOS

2016-12-06 Thread J. Scott Tury
That is correct.  Local notifications only go to your local device - or the 
paired device (watch) associated with it.

If you want to be able to reach all iOS devices a user has, you would have to 
use a Remote notification service, and eventually talk to the APNS service. 

Notifications have always been application specific.  They were not built to 
allow applications to send information to another application.

Hopefully that was the information you were looking for.  :)

Scott Tury

> On Dec 6, 2016, at 4:01 AM, Gerriet M. Denkmann  wrote:
> 
> 
>> On 5 Dec 2016, at 21:27, J. Scott Tury  wrote:
>> 
>> Gerriet, 
>> 
>> Try setting a Local Notification to be delivered at a scheduled time in the 
>> future (like a minute later).  Then put your iPhone into lock mode, and turn 
>> off the display.  
>> 
>> This should force the OS to deliver your notification to your paired device. 
>>  
>> 
>> When the timer fires for the local notification, you should see it go to 
>> your watch first.  (It will also be delivered to your iPhone if you go to 
>> the lock screen.)
>> 
>> Keep experimenting.  :)
> 
> I followed your wise advice and found out that Local Notifications are not 
> delivered in these cases:
> • different Apps on same iOS Device   
> • same App on different iOS Devices
> which means the only case remaining is:
> • some App sends a Local Notification to itself.
> 
> If this sending iOS app is paired with a watchOS app and the iOS device is 
> locked and the watch is not locked then the Notification is sent also to the 
> watch (and the iOS does not get woken up).
> 
> Gerriet.
> 
>> 
>> Scott Tury
>> 
>>> On Dec 5, 2016, at 12:17 AM, Gerriet M. Denkmann  
>>> wrote:
>>> 
>>> 
 On 5 Dec 2016, at 02:34, J. Scott Tury  wrote:
 
 There are two concepts I think you are trying to ask in your email.  
 
 1. What are notifications?
 
 2. How can you communicate between your iPhone and your watch app?
 
 These are two fundamentally different questions.
>>> 
>>> Thanks for clearing this up.
>>> 
>>> Trying Notifications first (just for learning):
>>> 
>>> […]
>>> 
 Local Notifications allow you as a developer to not have to call a remote 
 server to deliver a notification to the device your app is currently 
 running on.  If you have a watch paired to the current device, the 
 notification will show up on the watch if you are not currently using your 
 iPhone.
 
 The following class allows you to generate Local notifications.
 https://developer.apple.com/reference/usernotifications/unnotificationrequest
>>> 
>>> Did this.
>>> 
 
 You might want to spend a bit of time looking over the Apple documentation 
 as to what Notifications are, and how they work:
 https://developer.apple.com/notifications/
>>> 
>>> Did this too; also watched WWDC 2016 - Session 707 - Introduction to 
>>> Notifications again.
>>> At 3:00 it is said that “ Local Notifications are the ones that are used by 
>>> applications that are on the device".
>>> 
>>> So there are 3 posssiblities for Local Notifications:
>>> A   local = inside local Wifi or Bluetooth network
>>> B   local to the device (as hinted by WWDC talk)
>>> C   local to the sending app
>>> 
>>> I can send notifications from an app to itself. 
>>> But the receiving apps UNNotificationContentExtension gets never called.
>>> I only see UNUserNotificationCenterDelegate methods being invoked.
>>> 
>>> I cannot do: 
>>> • notification from one app to another on the same device
>>> • notification from one app to another on a different device
>>> 
>>> The sending app does see its own notifications via 
>>> getPendingNotificationRequestsWithCompletionHandler.
>>> It sets the categoryIdentifier of the sent UNNotificationContent to “my 
>>> test category”.
>>> 
>>> The receiving app (same iOS device) never sees anything. Although it does 
>>> setNotificationCategories with a UNNotificationCategory with the same 
>>> category: “my test category”.
>>> 
>>> This might indicate possibility “C”: local notifications are local to the 
>>> sending app.
>>> Or it may just be a proof that I am doing it wrong.
>>> 
 
 Communicate between watchOS, and iPhone:
>>> 
>>> To be investigated later.
>>> 
 
 Scott
 
> On Dec 4, 2016, at 5:47 AM, Gerriet M. Denkmann  
> wrote:
> 
> 
>> On 4 Dec 2016, at 00:48, J. Scott Tury  wrote:
>> 
>> Notifications for iOS will show on whatever device you are using 
>> currently.  If you’re not using one, it will show up on your watch.  If 
>> you’re using a iPad, it’ll show up on your iPad.  If you’r using your 
>> phone - it’ll show up there.  
>> 
>> There is no API that sends a Notification to a particular device per se.
>> 
>> I would just send a notification:  Local or remote.  The behavior should 

Re: Message from iOS to watchOS

2016-12-06 Thread Gerriet M. Denkmann

> On 5 Dec 2016, at 21:27, J. Scott Tury  wrote:
> 
> Gerriet, 
> 
> Try setting a Local Notification to be delivered at a scheduled time in the 
> future (like a minute later).  Then put your iPhone into lock mode, and turn 
> off the display.  
> 
> This should force the OS to deliver your notification to your paired device.  
> 
> When the timer fires for the local notification, you should see it go to your 
> watch first.  (It will also be delivered to your iPhone if you go to the lock 
> screen.)
> 
> Keep experimenting.  :)

I followed your wise advice and found out that Local Notifications are not 
delivered in these cases:
• different Apps on same iOS Device 
• same App on different iOS Devices
which means the only case remaining is:
• some App sends a Local Notification to itself.

If this sending iOS app is paired with a watchOS app and the iOS device is 
locked and the watch is not locked then the Notification is sent also to the 
watch (and the iOS does not get woken up).

Gerriet.

> 
> Scott Tury
> 
>> On Dec 5, 2016, at 12:17 AM, Gerriet M. Denkmann  wrote:
>> 
>> 
>>> On 5 Dec 2016, at 02:34, J. Scott Tury  wrote:
>>> 
>>> There are two concepts I think you are trying to ask in your email.  
>>> 
>>> 1. What are notifications?
>>> 
>>> 2. How can you communicate between your iPhone and your watch app?
>>> 
>>> These are two fundamentally different questions.
>> 
>> Thanks for clearing this up.
>> 
>> Trying Notifications first (just for learning):
>> 
>> […]
>> 
>>> Local Notifications allow you as a developer to not have to call a remote 
>>> server to deliver a notification to the device your app is currently 
>>> running on.  If you have a watch paired to the current device, the 
>>> notification will show up on the watch if you are not currently using your 
>>> iPhone.
>>> 
>>> The following class allows you to generate Local notifications.
>>> https://developer.apple.com/reference/usernotifications/unnotificationrequest
>> 
>> Did this.
>> 
>>> 
>>> You might want to spend a bit of time looking over the Apple documentation 
>>> as to what Notifications are, and how they work:
>>> https://developer.apple.com/notifications/
>> 
>> Did this too; also watched WWDC 2016 - Session 707 - Introduction to 
>> Notifications again.
>> At 3:00 it is said that “ Local Notifications are the ones that are used by 
>> applications that are on the device".
>> 
>> So there are 3 posssiblities for Local Notifications:
>> Alocal = inside local Wifi or Bluetooth network
>> Blocal to the device (as hinted by WWDC talk)
>> Clocal to the sending app
>> 
>> I can send notifications from an app to itself. 
>> But the receiving apps UNNotificationContentExtension gets never called.
>> I only see UNUserNotificationCenterDelegate methods being invoked.
>> 
>> I cannot do: 
>> • notification from one app to another on the same device
>> • notification from one app to another on a different device
>> 
>> The sending app does see its own notifications via 
>> getPendingNotificationRequestsWithCompletionHandler.
>> It sets the categoryIdentifier of the sent UNNotificationContent to “my test 
>> category”.
>> 
>> The receiving app (same iOS device) never sees anything. Although it does 
>> setNotificationCategories with a UNNotificationCategory with the same 
>> category: “my test category”.
>> 
>> This might indicate possibility “C”: local notifications are local to the 
>> sending app.
>> Or it may just be a proof that I am doing it wrong.
>> 
>>> 
>>> Communicate between watchOS, and iPhone:
>> 
>> To be investigated later.
>> 
>>> 
>>> Scott
>>> 
 On Dec 4, 2016, at 5:47 AM, Gerriet M. Denkmann  
 wrote:
 
 
> On 4 Dec 2016, at 00:48, J. Scott Tury  wrote:
> 
> Notifications for iOS will show on whatever device you are using 
> currently.  If you’re not using one, it will show up on your watch.  If 
> you’re using a iPad, it’ll show up on your iPad.  If you’r using your 
> phone - it’ll show up there.  
> 
> There is no API that sends a Notification to a particular device per se.
> 
> I would just send a notification:  Local or remote.  The behavior should 
> be essentially the same.  Send the title and message in the notification. 
>  You can add in any actions you would like your user to be able to have.
> 
> Scott
 
 One fundamental question: what does “local” in Local Notification mean?
 
 A: “local” as in local Wlan 
i.e. a local Notification gets sent to all iOS and watchOS devices in 
 the local Wlan
 
 B: “local” as inside the same app
i.e. i.e. a local Notification gets sent just to the sending app.
 
 I want to communicate between iOS app and watchOS app without using Apples 
 servers.
 If (as some tests seem to indicate) B is true, then this would be useless 
 for my 

Re: Large "Data" support

2016-12-06 Thread Alastair Houghton
On 6 Dec 2016, at 01:15, Jens Alfke  wrote:
> 
>> On Dec 5, 2016, at 4:12 PM, Daryle Walker  wrote:
>> 
>> For the Swift 3 "Data" type, if I want to represent a multi-gigabyte file, 
>> it won't try to do it all in memory, would it?  
> 
> The Data type specifically represents in-memory data, so yeah, it would. 
> (Where by “memory” I mean “address space”, which is not at all the same thing 
> as physical RAM on macOS, though it is on iOS. You haven’t specified which 
> platform you’re interested in.)
> 
>> Or would I have to manage a memory-mapped NSData and somehow connect it to a 
>> Data object?
> 
> On Mac this would be of limited use; all it changes is that when your data 
> gets paged out it will be written to your custom file instead of the OS’s 
> usual swap file. It probably won’t improve performance although it would help 
> keep the swap file from growing as much.

Strictly speaking, it may well improve performance, for two reasons:

1. If you mmap() data, you don’t actually have to read all of it; it’s read 
from disk on demand.

2. If the system needs to page your data out and you haven’t dirtied it, if 
it’s mmapped() it can just dispose of the pages; no need to hit the disk.

Compare with malloc()ing a buffer and reading a file into it (which NSData will 
do if you just read a file into it):

1. You need to read all the data from disk into your buffer.

2. If it’s too large to fit in memory, or some of it needs to be paged out, it 
will need to be written to the swap file.

Note that these are mainly advantages for large data sets, particularly those 
that are sparsely accessed and/or written to.  If you’re dealing with small 
files, mmap() may well be slower because of the overhead of page fault handling.

(Aside: a historical irony here is that on 32-bit platforms, software that 
dealt with exactly those kinds of data sets often couldn’t use mmap() because 
there wasn’t enough address space, but on 64-bit systems that’s unlikely to be 
true for most files most people care about.)

Kind regards,

Alastair

--
http://alastairs-place.net


___

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