Re: WatchKit Baby Apps

2018-03-01 Thread J. Scott Tury
Creating a WatchKit app with Timers should be fairly easy.  There’s a nice 
interface object called WKInterfaceTimer which should  do the trick - at least 
for the UI interface. Here’s a link to the documentation:

https://developer.apple.com/documentation/watchkit/wkinterfacetimer 
 

You might also be interested in reading the WatchKit Programming Guide.  It 
explains that WatchKit apps, are quite different from iOS applications.  The 
Interface is running in a separate process from your actual code - which is 
running in a watch extension.  

https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/index.html
 


Your extension does not run for very long.  Apple is extremely aggressive about 
how much time a watch extension will run.  Running for a long period of time is 
useful if you are collecting biometric data (heart rate, etc).  

A simple Timer application should be doable.  One of the challenges will be how 
to tell your user that the timer has finished.  The simplest thing I can think 
of is to schedule a Local Notification. That should be able to get your user’s 
attention!

Hopefully this helps you move in the right direction.

Scott
___

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

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

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

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


Re: Cocoa-dev Digest, Vol 14, Issue 154

2017-05-02 Thread J. Scott Tury
Hi Steve, 

I recently moved an iOs project over the macOS.  We had the exact same though 
at first.  

After analyzing what was happening in the app using Instruments, I was able to 
pin point performance issues within our own iOS engine, which caused the 
performance issues I was seeing on macOS.  Since macOS is reliant on Coca 
Bindings, you want to make sure you are not  abusing the system by setting 
properties to values which they are already set to.  Any modification of a 
property will cause KVO and binding callbacks to redraw your cells.

Also be careful how you use CoreData to fetch your data on macOS.  Certain 
settings on the controller will cause you to load the entire database into 
memory - making your product potentially unusable.  For instance on an 
ArrayController, setting the automaticallyRearrangesObjects to true, may cause 
a fault that winds up loading in all of your data from the database!  Let your 
predicate arrange the objects correctly for you.  Don’t force the 
arrayController, to then do more work that’s unnecessary.

In short, use Instruments to see what your app is really processing for your 
collectionView.  You may be surprised at what is happening.  Once those 
interactions are cleaned up, performance should be good.

Good luck!

Scott Tury

> On May 2, 2017, at 3:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
> Has anybody written something better than NSCollectionView to display a 
> scrolling matrix of cells that has good performance with thousands of items 
> and works with an array controller? NSCollectionView is a complete mess. 
> Everything I do is met with crummy behavior.
> 
> --
> Steve Mills
> Drummer, Mac geek

___

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 <gerri...@icloud.com> wrote:
> 
> 
>> On 5 Dec 2016, at 21:27, J. Scott Tury <st...@mac.com> 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 <gerri...@icloud.com> 
>>> wrote:
>>> 
>>> 
>>>> On 5 Dec 2016, at 02:34, J. Scott Tury <st...@mac.com> 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

Re: Message from iOS to watchOS

2016-12-05 Thread J. Scott Tury
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.  :)

Scott Tury

> On Dec 5, 2016, at 12:17 AM, Gerriet M. Denkmann <gerri...@icloud.com> wrote:
> 
> 
>> On 5 Dec 2016, at 02:34, J. Scott Tury <st...@mac.com> 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 <gerri...@icloud.com> wrote:
>>> 
>>> 
>>>> On 4 Dec 2016, at 00:48, J. Scott Tury <st...@mac.com> 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 purpose.
>>> How could one then 

Re: Message from iOS to watchOS

2016-12-04 Thread J. Scott Tury
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.

Notifications:

Notifications are a way for you to deliver messages of something important to 
your user, and have them displayed in the OS - on the lock screen, or on a 
watch.  You can se these with notifications that someone has sent you a 
Message.  The OS will determine which of your devices actually displays the 
message.

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

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/

Communicate between watchOS, and iPhone:

Use the Watch Connectivity framework to communicate between your WatchKit 
extension and iOS app.  This allows you to send data to your companion 
application, and receive data from your companion application.  You can see the 
basic information about how this works at 
https://developer.apple.com/library/prerelease/content/documentation/General/Conceptual/WatchKitProgrammingGuide/SharingData.html
 . 

For class documentation you can reference:

https://developer.apple.com/reference/watchconnectivity

Hope this helps!

Scott

> On Dec 4, 2016, at 5:47 AM, Gerriet M. Denkmann <gerri...@icloud.com> wrote:
> 
> 
>> On 4 Dec 2016, at 00:48, J. Scott Tury <st...@mac.com> 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 purpose.
> How could one then communicate between iOS app and watchOS app?
> 
> Gerriet.
> 
>> 
>>> Date: Sat, 03 Dec 2016 13:48:31 +0700
>>> From: "Gerriet M. Denkmann" <gerri...@icloud.com>
>>> To: cocoa-dev <cocoa-dev@lists.apple.com>
>>> Subject: Message from iOS to watchOS
>>> Message-ID: <2001a5e8-10f8-4b30-86c4-9dfee6198...@icloud.com>
>>> Content-Type: text/plain; charset=us-ascii
>>> 
>>> I have a pair of apps: iOS + watchOS.
>>> 
>>> The iOS app would like (e.g. when the user taps a button) to send some 
>>> (short) info to the watchOS app.
>>> The watchOS app probably should show something like a Notification 
>>> Controller Scene:
>>> Message from iOS (title)
>>> Something was done  (body)
>>> Accept / Refuse (buttons)
>>> 
>>> I looked at UNUserNotificationCenter, but did not see any way to specify 
>>> the recipient of the notification.
>>> 
>>> And I am not interested in Push Notifications.  
>>> 
>>> Gerriet.
>>> 
>>> P.S. This is my first watch app, so I am more than usual clueless.
>>> 
> 


___

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-03 Thread J. Scott Tury
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

> Date: Sat, 03 Dec 2016 13:48:31 +0700
> From: "Gerriet M. Denkmann" >
> To: cocoa-dev >
> Subject: Message from iOS to watchOS
> Message-ID: <2001a5e8-10f8-4b30-86c4-9dfee6198...@icloud.com 
> >
> Content-Type: text/plain; charset=us-ascii
> 
> I have a pair of apps: iOS + watchOS.
> 
> The iOS app would like (e.g. when the user taps a button) to send some 
> (short) info to the watchOS app.
> The watchOS app probably should show something like a Notification Controller 
> Scene:
>   Message from iOS (title)
>   Something was done  (body)
>   Accept / Refuse (buttons)
> 
> I looked at UNUserNotificationCenter, but did not see any way to specify the 
> recipient of the notification.
> 
> And I am not interested in Push Notifications.  
> 
> Gerriet.
> 
> P.S. This is my first watch app, so I am more than usual clueless.
> 
___

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: NSURLRequest and NSOperationQueue

2010-01-17 Thread J. Scott Tury
Dave, 

If you are setting up NSURLConnection on an NSOperation, I would suggest you 
keep the operation around as you get the data back.  The symptom you describe, 
sounds like you are starting the NSURLConnection, but then you leave your main 
method in the NSOperation you created.  This essentially orphans the thread 
that the NSURLConnection needs to report back progress to your delegate.  If 
that Thread no longer exists, the NSURLConnection will never report back.

Solution 1 would be to have you do a synchronous NSURLConnection in your main 
method.  This will show you everything is working in that thread and that you 
do indeed get data back from your server.

Solution 2 would be to change your NSOperation main method such that you start 
the NSURLConnection asynchronously, and you will need to loop until either you 
receive the connection:didFailWithError: delegate callback or you receive the 
connectionDidFinishLoading: delegate method callback.

Since you're creating a NSOperation anyway, you probably want threaded access 
to your data. So I would work on solution #2.  Your main method in your 
NSOperation subclass should be something simple like the following:

NSAutoreleasePool*  pool = [[NSAutoreleasePool alloc] init];

NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop];
if ( currentRunLoop )
{
// 1. Start the URLConnection!
mURLConnection = [NSURLConnection connectionWithRequest:mURLRequest 
delegate:self];
[mURLConnection start];

// 2. We have a run Loop, so wait until the connection is finished
while ( !done  ![self isCancelled] )
{
// Run the RunLoop!
NSDate* dateLimit = [[NSDate date] addTimeInterval:0.1];
[currentRunLoop runUntilDate:dateLimit];
}

// 3. Report your results to your main thread!
...
}


Scott Tury

On Jan 17, 2010, at 12:08 AM, cocoa-dev-requ...@lists.apple.com wrote:

 Subject: NSURLRequest and NSOperationQueue
 
 Hi everyone,
 
 I'm building an object that communicates with a server.  For various reasons, 
 I'd like to queue up all the NSURLRequests in an NSOperationQueue so that I 
 never have more than one connection open at a time.
 
 However, I'm running into a weird issue.  If I create my NSURLRequest and 
 open an NSURLConnection directly, then the connection works and everything 
 proceeds as expected.  However, if I create an NSInvocationOperation to delay 
 the creation of the connection until the queue is idle, then the connection 
 is created (and is non-nil), but the URLRequest never triggers any of its 
 delegate methods.
 
 After some investigation, I realized that the operation was executing on a 
 different thread, so I scheduled the URLConnection on the mainRunLoop in the 
 default mode (after unscheduling from the currentRunLoop).  I'm also 
 retaining the URLConnection in an ivar, but it's still not firing any 
 delegate methods (on any thread).
 
 Any ideas why my URL connection isn't working?
 
 Thanks,
 
 Dave DeLong



___

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

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


Re: NSURLRequest and NSOperationQueue

2010-01-17 Thread J. Scott Tury
The issue that Dave has run into is that when you call the asynchronous 
NSURLConnection call, NSURLConnection looks to see what thread you are calling 
it on, and it will only call your delegate back on that Thread (if it exists).  
If you exit your NSOperation main method, your thread is going to be cleaned 
up, and you will never get the delegate callbacks you want.

Re-reading Dave's original email, I think what's probably happening to him is 
that he may be switching the runLoops of ht eNSURLConnection BEFORE it has 
actually started.  Here's the comment from the documentation:

You may call these methods after the connection has started. However, if the 
connection is scheduled on multiple threads or if you are not calling these 
methods from the thread where the connection is scheduled, there is a race 
between these methods and the delivery of delegate methods on the other 
threads. The caller must either be prepared for additional delegation messages 
on the other threads, or must halt the run loops on the other threads before 
calling these methods to guarantee that no further callbacks will occur.

Scott

___

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

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


Re: Can NSURLConnection use Proxy Server?

2008-10-31 Thread J. Scott Tury


On Oct 31, 2008, at 8:42 PM, Nick Zitzmann [EMAIL PROTECTED] wrote:


On Oct 31, 2008, at 10:05 AM, malcom wrote:


I'm using NSURLConnection and NSURLRequest to make connection to a
server. Now I would to implement Proxy server connection but I
cannot find something about it inside the docs. Anyone can point to
me to the right way?



NSURLConnection does this automatically if you have a proxy server set
up in your network preferences.



While this is correct that the NSURLConnection will handle proxy  
settings set for the system as a whole, I do not believe that this  
was the question malcom was asking.


If you have one type of connection you need to make through an HTTP  
proxy, the default NSURLConnection does not provide an interface to  
do this.  Underneath its using the lower level C-based  
CFURLConnection classes, and if you can parse through the API's  
enough you'll see that you can get the data blob BEFORE it's actually  
sent out the wire, and modify it into an HTTP Proxy request.  (Please  
see the RFC on how to make an HTTP Proxy request if you don't know.)


But it's not a trivial task, but you can do it.

Scott
___

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

This email sent to [EMAIL PROTECTED]


Re: Which framework for Wifi?

2008-05-27 Thread J. Scott Tury

There is a private command line utility at the path:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/
Current/Resources/airport


One word of warning about using this utility:  it's output seems to  
change between OS builds (at least major ones)...  So be prepared to  
update this code, and test it on different OS versions.


I've noticed the output is actually different for certain values  
between 10.4 and 10.5.  And in 10.5.2 the -x command line option does  
not work at all, so you'll have to write a parser for the output.   
But then again it's probably the most supported utility you have  
available to you at this point in time.


If this utility isn't enough for you, you can try the alternative,  
which is to see what other projects use to get this information.  One  
good project to lookup would be MacStumbler.  They have a header  
(Apple80211.h) which may prove useful to you.


Scott Tury



___

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

This email sent to [EMAIL PROTECTED]