Slow Keyboard in iOS 9.0

2015-09-19 Thread Gerriet M. Denkmann
Master-Detail app for iPhone

Master has a TableView with words and a SearchField.
DetailView has info about selected word.

Hitting the Back-Button in the DetailView shows the MasterView and then (after 
what feels like a second) the Keyboard slides up.
This is not what I want.

Before iOS 9.0 the DetailView did (before segueing back to the MasterView):
[ masterView.searchController.searchBar becomeFirstResponder ]
This had the result that the MasterView did appear with the Keyboard already 
displayed.
Just what I wanted.

But now in iOS 9.0 I get:

18:17:15.478  -[MasterViewController viewWillAppear:] 
18:17:15.666— UIKeyboardWillShowNotification
— view appears with Keyboard —
18:17:16.330— UIKeyboardWillHideNotification
— keyboard disappears —
18:17:16.357  -[MasterViewController viewDidAppear:]
18:17:16.431— UIKeyboardWillShowNotification
— keyboard comes back —

So this way no longer works.

How can I make the  MasterView appear with the Keyboard already displayed in 
iOS 9?

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

How to get remote metadata

2015-09-27 Thread Gerriet M. Denkmann
I want to get some metadata for a remote file.
I tried:

NSString *path = @"/Public/UNIDATA/Blocks.txt";
NSURL *icuBlocksUrl = [ [ NSURL alloc ] initWithScheme: @"http"  host: 
@"unicode.org"  path: path ];
NSArray *keys = @[ NSURLContentModificationDateKey, NSURLCreationDateKey, 
NSURLFileSizeKey ];
NSError *outError;
NSDictionary *icuDict = [ icuBlocksUrl resourceValuesForKeys: keys  error: 
&outError ];

Now icuDict is non-nil but empty.

What am I doing wrong?

Gerriet.

P.S.

Just seen in small print: “This method applies only to URLs that represent file 
system resources.”

So this is not expected to work. What else can I do?



___

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 get remote metadata

2015-09-27 Thread Gerriet M. Denkmann

> On 28 Sep 2015, at 00:31, Mike Abdullah  wrote:
> 
> 
>> On 27 Sep 2015, at 18:08, Gerriet M. Denkmann  wrote:
>> 
>> I want to get some metadata for a remote file.
>>  
>> Just seen in small print: “This method applies only to URLs that represent 
>> file system resources.”
>> 
>> So this is not expected to work. What else can I do?
> 
> Probably the best thing to do is to use NSURLSession to send a HEAD request 
> to the server, and pick the information you want out of the response headers.

Excellent. Just what I needed. Thanks a lot!

One question though:
The NSHTTPURLResponse allHeaderFields dictionary contains keys like: 
“Content-Length” and “Last-Modified”.
Are these standardized or might other sites use other keys like 
“Modification-Date” or “Nbr-of-Bytes” ?

Kind regards,

Gerriet.


___

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

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

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

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

Where did NSSession put my file ?

2015-09-28 Thread Gerriet M. Denkmann
OS X 10.10.5
Trying to download a file with:

session = [ NSURLSessionsessionWithConfiguration:   
defaultSessionConfiguration
delegate:   
self
delegateQueue:  
nil 
];
dataTask = [ self.session dataTaskWithRequest: request ];
[ dataTask resume ];

The problem:
NSURLSessionDelegate and NSURLSessionTaskDelegate methods get called (as 
expected) but none of the NSURLSessionDownloadDelegate methods ever get called.

And these are the only ones (namely …didFinishDownloadingToURL:(NSURL 
*)location) which would tell me, where my file did end up.

URLSession:task:didCompleteWithError:
tells me that all went well: 
<__NSCFLocalDataTask: 0x107d00de0>{ taskIdentifier: 1 } { completed }

What am I doing wrong?

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

Where did NSSession put my file ?

2015-09-28 Thread Gerriet M. Denkmann
OS X 10.10.5
Trying to download a file with:

session = [ NSURLSessionsessionWithConfiguration:   
defaultSessionConfiguration
delegate:   
self
delegateQueue:  
nil 
];
dataTask = [ self.session dataTaskWithRequest: request ];
[ dataTask resume ];

The problem:
NSURLSessionDelegate and NSURLSessionTaskDelegate methods get called (as 
expected) but none of the NSURLSessionDownloadDelegate methods ever get called.

And these are the only ones (namely …didFinishDownloadingToURL:(NSURL 
*)location) which would tell me, where my file did end up.

URLSession:task:didCompleteWithError:
tells me that all went well: 
<__NSCFLocalDataTask: 0x107d00de0>{ taskIdentifier: 1 } { completed }

What am I doing wrong?

5 seconds after senden this I noticed that I should use downloadTaskWithRequest 
instead of dataTaskWithRequest.
Silly mistake.
Sorry for the noise.

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

How to specify Volume to NSURLSession ?

2015-09-28 Thread Gerriet M. Denkmann
When I download a file using NSURLSession downloadTaskWithRequest the file ends 
up in exactly the wrong volume.
Which means: I have to copy it to the right one, which, for really big files, 
can take some non-trivial time.

Is it possible to advise NSURLSession which volume to use?

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

How to install 10.11 ?

2015-10-01 Thread Gerriet M. Denkmann
Just tried 3 times to install 10.11. Always the same result:

First there is lots of talk like:
… Language Chooser[441:6816] TSplicedFont failed creating descriptor for:
[…]
 ".LastResort” is used instead.

Then, at about line 18 000:

Oct  1 00:10:55 MacBook-Pro OSInstaller[458]: Path enumeration error: Error 
Domain=NSPOSIXErrorDomain Code=20 “Not a directory" (/Volumes/10.11 + 
เม่น/Users/gerriet2)
True: it is not a directory, but a symbolic link to a directory. Almost 
as good. And it is the home directory of a user:
lrwxr-xr-x  1 root  wheel  27  6 Aug  2012 /Volumes/10.11 + เม่น/Users@ -> 
/Volumes/เม่น/Users
lrwxr-xr-x  1 root  admin  35  6 Aug  2012 /Volumes/เม่น/Users/gerriet2@ -> 
/Volumes/เม่น/Users/gerriet

Anyway, it gets worse:
Oct  1 00:10:55 MacBook-Pro Unknown[442]: 2015-10-01 00:10:55.826 OS X 
Installer[458:17253] An uncaught exception was raised
Oct  1 00:10:55 MacBook-Pro Unknown[442]: 2015-10-01 00:10:55.826 OS X 
Installer[458:17253] *** -[__NSCFString substringFromIndex:]: Index 34 out of 
bounds; string length 33

And then it crashes:

Oct  1 00:11:09 MacBook-Pro ReportCrash[510]: Thread 5 Crashed:: Dispatch 
queue: Filesystem Classifier (User Homes)
 0   libsystem_kernel.dylib 0x000110f0d0ae __pthread_kill + 10
 1   libsystem_pthread.dylib0x00011107a500 pthread_kill + 90
 2   libsystem_c.dylib  0x000110e0941b __abort + 145
 3   libsystem_c.dylib  0x000110e0938a abort + 144
 4   libc++abi.dylib0x000110badf81 abort_message + 257
 5   libc++abi.dylib0x000110bd3a47 
default_terminate_handler() + 267
 6   libobjc.A.dylib0x00010bfc208d _objc_terminate() + 
103
 7   libc++abi.dylib0x000110bd119e 
std::__terminate(void (*)()) + 8
 8   libc++abi.dylib0x000110bd1213 std::terminate() + 51
 9   libdispatch.dylib  0x000110cd2467 
_dispatch_client_callout + 28
 10  libdispatch.dylib  0x000110cd3a3a 
_dispatch_barrier_sync_f_invoke + 74
 11  com.apple.SystemMigration  0x0001175ffecc -[SMPaths 
ensureUserHomesAreProcessed] + 110
 12  com.apple.SystemMigration  0x0001175fed1f -[SMPaths 
enumerateFilesystem] + 75
 13  libdispatch.dylib  0x000110cd2453 
_dispatch_client_callout + 8
 14  libdispatch.dylib  0x000110cd3a3a 
_dispatch_barrier_sync_f_invoke + 74
 15  com.apple.SystemMigration  0x0001175ffc83 -[SMPaths 
ensureFilesystemIsClassified] + 110
 16  com.apple.SystemMigration  0x0001175fdc61 -[SMPaths 
totalSizeOfReaperPaths] + 37
 17  com.apple.OSInstaller  0x00010b5e02dc 
-[OSIReapableSpaceChecker _calculateSystemPathsAndSize] + 272
 18  com.apple.OSInstaller  0x00010b5e04d9 
-[OSIReapableSpaceChecker reapableFiles] + 83
 19  com.apple.OSInstaller  0x00010b5defcd 
-[OSIReapPreviousSystem _pathsToBackup] + 62
 20  com.apple.OSInstaller  0x00010b5df289 
-[OSIReapPreviousSystem createRecoveredItems] + 175
 21  com.apple.OSInstaller  0x00010b5dd7e2 
-[OSIReapPreviousSystem runReturningError:] + 635
 22  com.apple.OSInstaller  0x00010b5d18f9 
__35-[OSInstallController startInstall]_block_invoke + 1612
 23  libdispatch.dylib  0x000110cdd8ff 
_dispatch_call_block_and_release + 12
 24  libdispatch.dylib  0x000110cd2453 
_dispatch_client_callout + 8
 25  libdispatch.dylib  0x000110cd62e3 
_dispatch_root_queue_drain + 1890
 26  libdispatch.dylib  0x000110cd5b48 
_dispatch_worker_thread3 + 91
 27  libsystem_pthread.dylib0x0001110774f2 _pthread_wqthread + 
1129
 28  libsystem_pthread.dylib0x000111075375 start_wqthread + 13


Any ideas how I could proceed from here?
I filed a bug already - but waiting for a response might take months.

The full logfile is available on request - 65kB compressed.

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

How to override properties

2015-10-01 Thread Gerriet M. Denkmann
I inherited some code with:

@interface BaseThing : NSObject 

@property (nonatomic) SomeDataClass *stuff;

@end


@interface SubThing : BaseThing

@property (nonatomic) SubDataClass* stuff;  //  SubDataClass is a 
subclass of SomeDataClass

@end


@implementation SubThing

// nothing about stuff here

@end


Xcode 7.0 tells me:
warning: auto property synthesis will not synthesize property ‘stuff’; it will 
be implemented by its superclass, use @dynamic to acknowledge intention.

I don’t think that I want ’stuff’ to be implemented by its superclass. Rather I 
want it to be overridden. So I am not sure, whether @dynamic is the right thing 
to do.

How to make the compiler happy?

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: How to override properties

2015-10-01 Thread Gerriet M. Denkmann

> On 2 Oct 2015, at 12:40, Quincey Morris  
> wrote:
> 
> On Oct 1, 2015, at 22:18 , Graham Cox  wrote:
>> 
>> It’s not really about making the compiler happy, it’s about making your code 
>> clear and bug-free.
> 
>> The compiler is telling you your design is probably faulty, but the correct 
>> solution depends on your true intentions. What are they? You’ve slightly 
>> obfuscated the problem using pseudocode, so there’s no way to tell what’s 
>> the correct solution unless more info is provided.
> 
> I agree with what you say, but there is a bigger pitfall to avoid. If the 
> subclass provides a second implementation of ‘stuff’, then it also provides a 
> second ‘stuff’ instance variable. That probably causes BaseThing to break 
> horribly — if it ever refers to its own instance variable directly. Is that 
> likely to happen? Of course. Recommended practice is for a class to refer to 
> the instance variable in its init methods, instead of using the corresponding 
> property.
> 
> If the intention is merely to change the ‘stuff’ return type in the subclass, 
> then @dynamic is the correct way to go. If the intention is to have two 
> property implementations, then the subclass ‘stuff’ should be called 
> something else.

I guess the inherited code just wants to change the ‘stuff’ return type in the 
subclass.
So I added  @dynamic to the subclass, and all seems to be ok.

Thanks for clearing this up.

Kind regards,

Gerriet.


___

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

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

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

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

CNCopySupportedInterfaces

2015-10-02 Thread Gerriet M. Denkmann
I am trying to update some source code which does every second:

CNCopySupportedInterfaces and CNCopyCurrentNetworkInfo and extracts the values 
of kCNNetworkInfoKeySSID and kCNNetworkInfoKeyBSSID.

All this is deprecated in iOS 9.0.

Xcode 7.0 tells me:
'CNCopySupportedInterfaces' is deprecated: first deprecated in iOS 9.0 - For 
captive network applications, this has been completely replaced by 
. For other applications, there is no 
direct replacement. Please file a bug describing your use of this API to that 
we can consider your requirements as this situation evolves.

“The NEHotspotHelper interface allows an application to participate in the 
process of joining Wi-Fi/hotspot networks.”

I have no idea, whether this app is a “captive network application”. It 
certainly has nothing to do with Hotspots.
It is just an app which tries to communicate with a light bulb.

Any ideas, what to do?

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

iOS Keyboard Woes

2015-10-08 Thread Gerriet M. Denkmann
A simple app with iOS 9.0.2:
MasterView has TableView + SearchBar
DetailView has other stuff.

Two things I am trying to do (and failing miserably)

Scenario A:
Back from DetailView to MasterView with keyboard already in place.
What I get (and don’t like) is: MasterView slides in from left (but without 
keyboard), then the keyboard slides in from below.

The obvious solution: activate the keyboard in viewWillAppear. This worked fine 
in 8.0, but 9.0 has a new behaviour:
MasterView slides in from left with keyboard (good!), keyboard disappears 
(sigh), keyboard slides in from below.

Scenario B:
Back from DetailView to MasterView without keyboard (but with SearchBar active).
I tried to do [ self.searchController.searchBar resignFirstResponder] in 
viewDidAppear, but this seems to have no effect. 


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

TableView Segue

2015-10-08 Thread Gerriet M. Denkmann
I just created a new project with Xcode 7.0: iOS Master-Detail App.

The TableView in one of the Master Scenes has a Cell, which in Utilities → 
Connections inspector displays (under Triggered Segues):
selection → Navigation Controller show detail.
The same Scene has a UIStoryboardSegue called “showDetail”.

How can I set this from inside my program?
Can’t find anything looking like this in: UINavigationController, 
UIViewController, UITableView or UITableViewCell.

I am looking for a property like: UIStoryboardSegue 
*segueToUseWhenTableRowIsTapped

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

How to make UISplitViewController behave ?

2015-10-11 Thread Gerriet M. Denkmann
iPad / iPhone Master-Detail app. iOS 9.0, Xcode 7.0

Rotating the iPad to Portrait my AppDelegate will receive a 
UIDeviceOrientationDidChangeNotification:

12:23:01.182 -[AppDelegate iPadHasTurned:] 
and does:
UISplitViewControllerDisplayMode newMode = PrimaryOverlay
splitViewController.preferredDisplayMode = newMode;
[ self performSelector: @selector(delayedSetMode:) withObject: 
@(newMode) afterDelay: 0 ];  //  see below

12:23:01.183-[AppDelegate splitViewController:willChangeToDisplayMode:] 
PrimaryOverlay 
good, that's what I just have told it to do. 

12:23:01.196-[MasterViewController viewDidAppear:]   
12:23:01.198 -[AppDelegate iPadHasTurned:] done

So far so good.

But now the pesky SplitViewController decides it knows best, and does:

12:23:01.199 -[AppDelegate splitViewController:willChangeToDisplayMode:] 
AllVisible 

here my delayedSetMode will come to the rescue:
12:23:01.212 -[AppDelegate delayedSetMode:] displayMode → PrimaryOverlay

does:   splitViewController.preferredDisplayMode = newMode;
12:23:01.223-[MasterViewController viewDidAppear:]   
12:23:01.224 -[AppDelegate delayedSetMode:] done 

Is there a better way than this hack with delayedSetMode ?

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: How to make UISplitViewController behave ?

2015-10-12 Thread Gerriet M. Denkmann

> On 13 Oct 2015, at 04:49, David Duncan  wrote:
> 
> 
>> On Oct 11, 2015, at 11:21 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> iPad / iPhone Master-Detail app. iOS 9.0, Xcode 7.0
>> 
>> Rotating the iPad to Portrait my AppDelegate will receive a 
>> UIDeviceOrientationDidChangeNotification:
>> 
>> 12:23:01.182 -[AppDelegate iPadHasTurned:] 
>>  and does:
>>  UISplitViewControllerDisplayMode newMode = PrimaryOverlay
>>  splitViewController.preferredDisplayMode = newMode;
>>  [ self performSelector: @selector(delayedSetMode:) withObject: 
>> @(newMode) afterDelay: 0 ];  //  see below
>>  
>> 12:23:01.183 -[AppDelegate 
>> splitViewController:willChangeToDisplayMode:] PrimaryOverlay 
>>  good, that's what I just have told it to do. 
>>  
>> 12:23:01.196 -[MasterViewController viewDidAppear:]   
>> 12:23:01.198 -[AppDelegate iPadHasTurned:] done
>> 
>> So far so good.
>> 
>> But now the pesky SplitViewController decides it knows best, and does:
>> 
>> 12:23:01.199 -[AppDelegate splitViewController:willChangeToDisplayMode:] 
>> AllVisible  
>> 
>> here my delayedSetMode will come to the rescue:
>> 12:23:01.212 -[AppDelegate delayedSetMode:] displayMode → PrimaryOverlay 
>> 
>>  does:   splitViewController.preferredDisplayMode = newMode;
>> 12:23:01.223 -[MasterViewController viewDidAppear:]   
>> 12:23:01.224 -[AppDelegate delayedSetMode:] done 
>> 
>> Is there a better way than this hack with delayedSetMode ?
> 
> Why are you doing this?

I have defined two new displayModes, let’s call them 
UISplitViewControllerDisplayMode_FocusOnPrimary and 
UISplitViewControllerDisplayMode_FocusOnSecondary, or FocusOnPrimary and 
FocusOnSecondary for short.

They should work like this on iPad:
• Landscape: both Primary (Master) and Secondary (Detail) should be visible. 
Automatic works fine in this case.
• Portrait with FocusOnPrimary: Primary (Master) should be visible, leaving the 
Secondary (Detail) partly obscured. Like PrimaryOverlay.
• Portrait with FocusOnSecondary: Secondary (Detail) should be visible, 
completely hiding Primary. Like PrimaryHidden.

The use case is as follows:
• If the user shifts focus to Detail - e.g. by clicking on a row in the 
TableView of Master (which makes some info about this row show up in Detail), 
the Detail or Secondary should be completely visible (and remain visible), 
regardless of orientation of iPad.

• Similarly if the user clicks the “< Master” Back-Button (or goes back to 
Master by some other means) then the focus should be on Master; and Master 
should remain visible, regardless of orientation of iPad.

I have implemented these two new displayModes via 
UIDeviceOrientationDidChangeNotification.


When I just set PrimaryOverlay in Portrait (while shifting focus to Main), all 
is fine (for the time being). But when I then rotate iPad to Landscape only the 
Detail view is shown, which is wrong. 


Kind regards,

Gerriet.


___

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

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

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

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

UILabel is maiming my Character

2015-10-14 Thread Gerriet M. Denkmann
I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
All have Clip Subviews = off, font size 96 with a coloured background, text 
plain = “ฟี้กุฎุมพี”.

The difference is the font:

System: ok (but is too bold for my taste)
Thonburi and Thonburi Light: bottom get cut off 
System Light: bottom gets cut off rather much

System also uses Thonburi as font substitution.

With Clip Subviews = on the characters get clipped to the coloured background, 
which is even worse.
Note: some characters go well beyond the descender line (as specified by the 
font) and also above the line height.

How can I get a UILabel which does not maim my characters?
(Another question would be: how to get a background which covers all of the 
characters. But this is not important to me right now)

These UILabels are ultimately meant to go into UITableViewCells (without 
coloured background).

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: UILabel is maiming my Character

2015-10-14 Thread Gerriet M. Denkmann

> On 15 Oct 2015, at 00:03, David Duncan  wrote:
> 
> 
>> On Oct 14, 2015, at 4:02 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
>> All have Clip Subviews = off, font size 96 with a coloured background, text 
>> plain = “ฟี้กุฎุมพี”.
>> 
>> The difference is the font:
>> 
>> System: ok (but is too bold for my taste)
>> Thonburi and Thonburi Light: bottom get cut off 
>> System Light: bottom gets cut off rather much
>> 
>> System also uses Thonburi as font substitution.
>> 
>> With Clip Subviews = on the characters get clipped to the coloured 
>> background, which is even worse.
>> Note: some characters go well beyond the descender line (as specified by the 
>> font) and also above the line height.
>> 
>> How can I get a UILabel which does not maim my characters?
>> (Another question would be: how to get a background which covers all of the 
>> characters. But this is not important to me right now)
>> 
>> These UILabels are ultimately meant to go into UITableViewCells (without 
>> coloured background).
> 
> You will probably need to use an attributed string that specifies a taller 
> line height than normal. This happens automatically when the system language 
> is set to languages such as Thai, but not for other languages, as it would 
> apply to all text strings.

Thanks for this hint.
And thanks a lot to Alex for his very helpful code example!

Moving the baseLine up by about 8 % and increasing the LineHeight by 5 %  
finally (after lots of fiddling) gives me an acceptable UILabel with SystemFont 
Light.

CGFloat baseChangePercent = +8; 
CGFloat lineChangePercent = +5; 

CGFloat baselineOffset = fontSize * baseChangePercent / 100 ;
CGFloat lineHeightMultiple = 1 + lineChangePercent / 100;

NSMutableParagraphStyle *paragraph = [ [ NSMutableParagraphStyle alloc ] init ];
paragraph.lineHeightMultiple = lineHeightMultiple;

attributes =@{  NSBaselineOffsetAttributeName:  @(baselineOffset),
NSFontAttributeName:
font,
NSParagraphStyleAttributeName:  
paragraph,
 };
But of course these values are heavily dependent on the font (and maybe even on 
fontSize).

How to compute these numbers directly (as opposed to trial and error)?


Kind regards,

Gerriet.


___

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

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

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

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

Why no scroll-to-top gesture?

2015-10-16 Thread Gerriet M. Denkmann
Master-Detail iOS 9 app; Xcode 7.
Master has a TableView with UISearchController.

When I scroll the Master TableView and then use the scroll-to-top gesture (a 
tap on the status bar) the expected thing happens.

But when I do the same with the SearchResultsTableView, nothing happens at all.
I have an old version of this app (build with SDK 8) which works as expected.

I tried to build the current version with SDK 8, but Xcode told me that I can 
only choose between Latest iOS (iOS 9.0) and iOS 9.0.

There is this TableSearchwithUISearchController Sample Code from Apple, which 
has the same (wrong?) behaviour.

Is this a new feature? Or a bug?
I fixed this by subclassing UIApplication and overriding sendEvent:. Is there a 
better solution?

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

Inverse of SMJobBless

2015-11-30 Thread Gerriet M. Denkmann
I have a program which talks via NSXPCConnection to a privileged helper tool.

It also can install the helper tool, using SMJobBless().

The problem: When I change the helper tool, the only way to get the new version 
running is to remove:
/Library/LaunchDaemons/myHelperTool.plist
/Library/PrivilegedHelperTools/myHelperTool
and restart the computer.

There must be a better way.

There is SMJobRemove, but this is deprecated.
Maybe some launchctl commands?
But doing it from the App would be the preferred way.


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: Inverse of SMJobBless

2015-11-30 Thread Gerriet M. Denkmann

> On 30 Nov 2015, at 19:59, Pierre Molinaro  wrote:
> 
> Hi,
> 
> Just increment the Bundle Version setting in the Info.plist of your 
> privileged helper tool, the new version will be automatically installed on 
> launch.
> 
> Pierre

Thanks a lot. This is a very helpful hint.

But:
After doing SMJobBless twice, the third time I get kSMErrorInternalFailure.
Any cure for this (other than reboot)?

But anyway, this reduces the number of necessary reboots to one third.

Kind regards,

Gerriet.

> 
>> Le 30 nov. 2015 à 12:28, Gerriet M. Denkmann  a écrit :
>> 
>> I have a program which talks via NSXPCConnection to a privileged helper tool.
>> 
>> It also can install the helper tool, using SMJobBless().
>> 
>> The problem: When I change the helper tool, the only way to get the new 
>> version running is to remove:
>>  /Library/LaunchDaemons/myHelperTool.plist
>>  /Library/PrivilegedHelperTools/myHelperTool
>> and restart the computer.
>> 
>> There must be a better way.
>> 
>> There is SMJobRemove, but this is deprecated.
>> Maybe some launchctl commands?
>> But doing it from the App would be the preferred way.
>> 
>> 
>> 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

How to import a Framework

2015-12-01 Thread Gerriet M. Denkmann
I just made a Framework (Xcode 7.1), called ProcArgFramework.
I copied it into /Library/Frameworks.

In some other Project I added:

@import ProcArgFramework

But Xcode says: “Module ProcArgFramework not found”.

I tried all sorts of variations of this import-line. But all to no avail.

How can I import my framework?

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: How to import a Framework

2015-12-01 Thread Gerriet M. Denkmann

> On 2 Dec 2015, at 09:51, Roland King  wrote:
> 
> 
>> On 2 Dec 2015, at 10:39, Gerriet M. Denkmann  wrote:
>> 
>> I just made a Framework (Xcode 7.1), called ProcArgFramework.
>> I copied it into /Library/Frameworks.
>> 
>> In some other Project I added:
>> 
>> @import ProcArgFramework 
>> 
>> But Xcode says: “Module ProcArgFramework not found”.
>> 
>> I tried all sorts of variations of this import-line. But all to no avail.
>> 
>> How can I import my framework?
>> 
>> Gerriet.
>> 
> 
> What makes you think Xcode looks in /Library/Frameworks for framework imports?

“When you build an application or other executable, the compiler looks for 
frameworks in/System/Library/Frameworks as well as any other location specified 
to the compiler.”


> I’d assume there’s a build setting somewhere with a framework search path, 
> perhaps finding and setting that might help. 
> 
> Or just drag the thing onto your project from the finder and see if Xcode 
> does the right thing, it occasionally does. 
> 
> If it’s your own framework you can just add the project as a sub project in 
> your build and have it build it locally, unless you particularly want to link 
> with the system-installed one.

I ended up with adding my ProcArgFramework to: Build Phases → Link Binary With 
Libraries.
I should have thought about this before. 
But thanks for pushing me in the right direction. Very much appreciated. I did 
spend hours trying all sort of #import variations.

Kind regards,

Gerriet.


___

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

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

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

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

Launchd never stops my HelperTool

2015-12-04 Thread Gerriet M. Denkmann
I have a HelperTool (installed via SMJobBless). 

The HelperTool does:

NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName: 
bundleId ];
listener.delegate = myNSXPCListenerDelegate;
[listener resume];
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop]; 
[ currentRunLoop run ]; 


“Daemons and Services Programming Guide” → “Creating XPC Services” → 
"Understanding the Structure and Behavior" says:
"XPC services are managed by launchd, which launches them on demand, restarts 
them if they crash, 
and terminates them (by sending SIGKILL) when they are idle.”

“launches them on demand” works fine.

But: “terminates them when they are idle”  never happens.

What to do:

(a) Just trust launchd; it probably has decided that relaunching is more 
costly than keeping the process running.

(b) launchd has no idea that the HelperTool is idle, because the RunLoop is 
still running. The HelperTool should quit the RunLoop when there are no more 
active NSXPCConnections.

If (b) what should the HelperTool do if it decides there is no more work to do:
(b1) just exit(EXIT_SUCCESS)
(b2) [listener invalidate], followed by exit(EXIT_SUCCESS).

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: Can an NSArray ever have a count of -1?

2016-02-19 Thread Gerriet M. Denkmann

> On 20 Feb 2016, at 06:32,Charles Srstka  wrote:
> 
> 
> 
>> On Feb 19, 2016, at 4:29 PM, Jens Alfke  wrote:
>> 
>> NSInteger is a typedef of ‘long’ in 64-bit, and ‘int’ in 32-bit.
>> You’re correct that %d should be used for NSInteger in 32-bit.
> 
> The recommended way to use an NSInteger, as per Apple documentation, is to 
> use %ld and explicitly cast it to long.
> 
> NSLog(@“foo is %ld”, (long)foo);
> 
> This will work regardless of platform.
> 
> For NSUInteger, you use %lu and cast to unsigned long.

I use Other C Flags: -DNS_BUILD_32_LIKE_64=1
with this:
NSLog(@“array size %lu”, someArray.size )
works fine both for 32 and 64 bit; no warnings or errors.


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: Can an NSArray ever have a count of -1?

2016-02-19 Thread Gerriet M. Denkmann

> On 20 Feb 2016, at 11:24, Quincey Morris 
>  wrote:
> 
> On Feb 19, 2016, at 19:00 , Gerriet M. Denkmann  wrote:
>> 
>> I use Other C Flags: -DNS_BUILD_32_LIKE_64=1
> 
> AFAIK this is a Mac-only thing. I don’t believe it works on a 32-bit iOS 
> platform, in particular because I don’t believe there are any 64-bit system 
> frameworks on such a system. There’d be an ABI mismatch.

This:
UIDevice *theDevice = [UIDevice currentDevice]; 
NSLog(@“%s NSUInteger %lu bytes on %@“,__FUNCTION__, 
sizeof(NSUInteger), theDevice.localizedModel);

prints:
-[AppDelegate application:didFinishLaunchingWithOptions:] NSUInteger 4 
bytes on iPhone (iPone 4s in Simulator)
-[AppDelegate application:didFinishLaunchingWithOptions:] NSUInteger 8 
bytes on iPad (iPad Air in Simulator)


> 
> Also (I could be wrong but) I don’t think it was ever in the iOS SDK.
> 
> The point about Apple’s %ld/(long) recommendation was that it replaced a 
> source code construct that was correct only via knowledge of the architecture 
> it was compiled for, with a construct that was correct for all platforms.

With DNS_BUILD_32_LIKE_64 NSUInteger is long on all platforms, so %lu works in 
all cases.


Kind regards,

Gerriet.



___

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

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

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

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

Re: Can an NSArray ever have a count of -1?

2016-02-19 Thread Gerriet M. Denkmann

> On 20 Feb 2016, at 11:59, Quincey Morris 
>  wrote:
> 
> On Feb 19, 2016, at 20:43 , Gerriet M. Denkmann  wrote:
>> 
>> This:
>>  UIDevice *theDevice = [UIDevice currentDevice]; 
>>  NSLog(@“%s NSUInteger %lu bytes on %@“,__FUNCTION__, 
>> sizeof(NSUInteger), theDevice.localizedModel);
>> 
>> prints:
>>  -[AppDelegate application:didFinishLaunchingWithOptions:] NSUInteger 4 
>> bytes on iPhone (iPone 4s in Simulator)
>>  -[AppDelegate application:didFinishLaunchingWithOptions:] NSUInteger 8 
>> bytes on iPad (iPad Air in Simulator)
> 
> I’m not sure what that proves. Yes, NSUInteger is different sizes for 
> different iOS architectures. What I said was that if you could force 
> NSUInteger to be 8 bytes instead of 4 bytes on iOS (using 
> NS_BUILD_32_LIKE_64), then the app would crash on an architecture where 
> system frameworks knew NSUInteger to be 4 bytes.


Sorry about being not very clear. One can NOT force NSUInteger to be different 
sizes. It will always be 4 bytes on 32 bit systems, and 8 bytes on 64 bit ones.

32 bit without DNS_BUILD_32_LIKE_64 
NSUInteger = int; 
32 bit with DNS_BUILD_32_LIKE_64 
NSUInteger = long (but long = int)

64 bit (regardless of DNS_BUILD_32_LIKE_64)
NSUInteger = long (but long > int)
> 
>> With DNS_BUILD_32_LIKE_64 NSUInteger is long on all platforms, so %lu works 
>> in all cases.
> 
> Can you demonstrate NS_BUILD_32_LIKE_64 making NSUInteger 8 bytes for the 
> iPhone 4s?

Sorry, as I said above, this cannot be done.

> 
> You also need to be careful about demonstrating architectural claims on a 
> simulator. It’s an iOS simulator, but it’s an OS X platform, which is why you 
> can’t [legally] lipo together simulator and device dylibs into a single 
> framework, to the annoyance of many 3rd-party framework developers.

Without the complication of Simulators:
NSUInteger 4 bytes on “พาย" = iPad 3rd Generation (iPad); iOS 9.2.1
NSUInteger 8 bytes on "โพยม" = iPad Air(Wifi) (iPad); iOS 9.2.1


Kind regards,

Gerriet.


___

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

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

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

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

Re: Can an NSArray ever have a count of -1?

2016-02-19 Thread Gerriet M. Denkmann

> On 20 Feb 2016, at 13:02, Quincey Morris 
>  wrote:
> 
> On Feb 19, 2016, at 21:30 , Gerriet M. Denkmann  wrote:
> 
>  Now that I code almost exclusively in Swift, the problem has largely 
> disappeared, because ‘“\(someValue)"' is a lot easier*** than ‘[NSString 
> stringWithFormat: "%lu", (someCast) someValue]’.

Is there (yet) a Swift version of ‘[NSString stringWithFormat: “%08lx”, 
(someCast) someValue]’ ?
Last time I checked, this was the only way to print formatted strings.

Kind regards,

Gerriet.


___

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

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

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

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

Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann
I have a file “Some Font.ttf” and I want to know the displayName of this font, 
which might be “Some-Font” or “Nice Font” or anything else.
Or nil if this is not a well-formatted font file.
I do NOT want to install the font nor do anything with it.

Short of reverse-engeneering the ttf format (which probably would be rather too 
much): is there a way to get this?

Ideally I would line to do:
NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
NSString *displayName = font.displayName;   //  font.fontName would 
probably also do

but this seems not to exist.

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: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 26 Feb 2016, at 17:33, Ken Thomases  wrote:
> 
> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  wrote:
>> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//  font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
> 
> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
> descriptor, CTFontDescriptorCopyAttribute() with kCTFontDisplayNameAttribute.
> 
> Keep in mind that you may get multiple descriptors because a font file may 
> include multiple fonts.  Consequently, there may be multiple display names.

Thanks a lot. Works perfectly.
But did not find any font file which contains more than one descriptor. Any 
examples (for testing)?

Kind regards,

Gerriet.


___

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

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

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

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

Re: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 00:31, Jens Alfke  wrote:
> 
> If this functionality exists it would probably be down in the CoreText 
> framework. Take a look there. 
> 
> —Jens 

As Ken Thomases kindly told me it does exist exactly there: 
CTFontManagerCreateFontDescriptorsFromURL.

Kind regards,

Gerriet.

> 
>> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
>> 
>> 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: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 00:37, Alex Kac  wrote:
> 
> Are you wanting this for any arbitrary font? I believe you can “install” a 
> font just for your application - and then use the NSFont methods to get it.
> 
> http://stackoverflow.com/questions/5283572/custom-font-in-a-cocoa-application

I do not want a fixed set of fonts to be included into my app. Rather I want my 
app to do things (to be precise: install them on my iOS devices) for any 
arbitrary font.
The solution suggested by Ken Thomases 
(CTFontManagerCreateFontDescriptorsFromURL ) works perfectly for me.

But thanks for the link - this might come in handy some other time.


Kind regards

Gerriet.

> 
>> On Feb 26, 2016, at 10:31 AM, Jens Alfke  wrote:
>> 
>> If this functionality exists it would probably be down in the CoreText 
>> framework. Take a look there. 
>> 
>> —Jens 
>> 
>>> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  
>>> wrote:
>>> 
>>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>>> font, which might be “Some-Font” or “Nice Font” or anything else.
>>> Or nil if this is not a well-formatted font file.
>>> I do NOT want to install the font nor do anything with it.
>>> 
>>> Short of reverse-engeneering the ttf format (which probably would be rather 
>>> too much): is there a way to get this?
>>> 
>>> Ideally I would line to do:
>>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>>> NSString *displayName = font.displayName;//font.fontName would 
>>> probably also do
>>> 
>>> but this seems not to exist.
> 
> Alex Kac - El capitán
> 


___

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: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 09:54, Ken Thomases  wrote:
> 
> On Feb 26, 2016, at 7:17 AM, Gerriet M. Denkmann  wrote:
>> 
>> On 26 Feb 2016, at 17:33, Ken Thomases  wrote:
>>> 
>>> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  
>>> wrote:
>>>> 
>>>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>>>> font, which might be “Some-Font” or “Nice Font” or anything else.
>>>> Or nil if this is not a well-formatted font file.
>>>> I do NOT want to install the font nor do anything with it.
>>>> 
>>>> Short of reverse-engeneering the ttf format (which probably would be 
>>>> rather too much): is there a way to get this?
>>>> 
>>>> Ideally I would line to do:
>>>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>>>> NSString *displayName = font.displayName;  //  font.fontName would 
>>>> probably also do
>>>> 
>>>> but this seems not to exist.
>>> 
>>> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
>>> descriptor, CTFontDescriptorCopyAttribute() with 
>>> kCTFontDisplayNameAttribute.
>>> 
>>> Keep in mind that you may get multiple descriptors because a font file may 
>>> include multiple fonts.  Consequently, there may be multiple display names.
>> 
>> Thanks a lot. Works perfectly.
>> But did not find any font file which contains more than one descriptor. Any 
>> examples (for testing)?
> 
> Well, the very first thing I found in Font Book was the American Typewriter 
> font family, which is in /Library/Fonts/AmericanTypewriter.ttc.  That's a 
> TrueType font collection file, which contains various weights of the font.
> 
> There are also font suitcase files such as /System/Library/Fonts/Times.dfont.

Of the about 380 font files on my computer, slightly more than 100 contain 
multiple fonts; all .ttc or .dfont.
And there is just one .ttf font file (/Library/Fonts/Skia.ttf) which contains 
10 fonts (regular, bold, …).

Thanks very much for your help!


Kind regards,

Gerriet.


___

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

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

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

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

Setting the Null Placeholder for bindings

2016-03-09 Thread Gerriet M. Denkmann
I have a TextField bound to Shared User Defaults Controller.
The Null Placeholder is set to “default”.

When the window comes up, it shows the value from NSUserDefaults 
registerDefaults:. Ok
When I remove the string from the TextField, I see a grey value “default”. Also 
to be expected.
The actual value of the UserDefaults seems to come in this case from 
registerDefaults. Also good.

But how can I replace “default” with the actual string? 
Yes, I can do this in Xcode, but I would like to do this from inside my program.

Can this be done? If yes, how?

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

$-prefixed archiving keys in 10.11?

2016-03-11 Thread Gerriet M. Denkmann
In 10.10.5 using a $-prefixed archiving key does NOT work.

Does it work in 10.11?

If not, I will file a bug.

Gerriet.

This is my test code:

#import "AppDelegate.h"

static NSString *const kArchivingKey = @"$my archiving key";//  no bug 
without leading '$'

@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@property (strong) NSString *myName;

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{
/*  Archives and Serializations Programming Guide →
Encoding and Decoding Objects → Performance Considerations says:

"Avoid using “$” as a prefix for your keys. 
The keyed archiver and unarchiver use keys prefixed with “$” 
for internal values. 
Although they test for and mangle user-defined keys that have a 
“$” prefix, this overhead makes 
archiving slower."

Note: this cleary implies: using “$” as a prefix for keys is 
allowed, albeit slow.
Fact: In 10.10.5 using “$” as a prefix for keys does NOT work.
**/

self.myName = @"สิงโต"; //  use anything ≠ nil; If "สิงโต" seems 
too scary, use "pussycat" instead.
NSData *data = [ NSKeyedArchiver archivedDataWithRootObject: self ];
AppDelegate *selfCopy = [ NSKeyedUnarchiver  unarchiveObjectWithData: 
data ];   
NSLog(@"%s selfCopy = %@",__FUNCTION__, selfCopy);
}



- (NSString *)description
{
NSString *s = [ NSString stringWithFormat: @"[%@ name: %@]", [self 
class], self.myName ];
return s;
}


- (void)encodeWithCoder:(NSCoder *)coder
{
[ coder encodeObject: self.myName  forKey: kArchivingKey ];
}



- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if ( self == nil ) return nil;

_myName = [ decoder decodeObjectForKey: kArchivingKey ];

if ( _myName == nil )   //  error → try badKey instead
{
NSLog(@"%s Error: got nil for kArchivingKey = 
\"%@\"",__FUNCTION__, kArchivingKey);
NSString *badKey = [ @"$$" stringByAppendingString: 
kArchivingKey ];
_myName = [ decoder decodeObjectForKey: badKey ];

if ( _myName == nil )   //  ok
{
NSLog(@"%s Ok got nil for badKey = \"$$\" + 
kArchivingKey",__FUNCTION__);
}
else//  error
{
NSLog(@"%s Error: badKey = \"$$\" + kArchivingKey → 
%@",__FUNCTION__, _myName);
};
}
else//  ok
{
NSLog(@"%s Ok kArchivingKey = \"%@\" → %@",__FUNCTION__, 
kArchivingKey, _myName);
};

return self;
}

@end


___

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

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

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

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

How to set a TextField

2016-03-13 Thread Gerriet M. Denkmann
I have a String message1, bound to TextField textField1. (OS X 10.10.5).

- (void)computeSomething
{
self.message1 = @“Start computing”;
//  some seconds of computations
self.message1 = @“Result = 42”;
}

This never shows “Start computing”.
(same problem with self. textField1.stringValue = @“Start computing”;)

This rather ugly hack works:

self.message1 = @“Start computing”;
//  0.01 ok; 0.001 mostly ok; 0.0001 too small
[ self performSelector: @selector(computeSomething) withObject: nil afterDelay: 
0.01 ]; 

Is there a better way (without this rather arbitrary delay)?

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: How to set a TextField

2016-03-14 Thread Gerriet M. Denkmann

> On 14 Mar 2016, at 14:17, Quincey Morris 
>  wrote:
> 
> On Mar 13, 2016, at 23:50 , Gerriet M. Denkmann  wrote:
>> 
>> - (void)computeSomething
>> {
>>  self.message1 = @“Start computing”;
>>  //  some seconds of computations
>>  self.message1 = @“Result = 42”;
>> }
> 
> Assume, conceptually, that drawing only takes place asynchronously (that is 
> to say, setting a new value on the string invokes setNeedsDisplay, that’s 
> all), and it’s obvious why this isn’t going to work.
> 
> But the real issue is not that the text field won’t update, it’s that you’re 
> blocking the main thread with computation. You should move the computation 
> off the main thread — using dispatch_async to a default queue. At the end of 
> the computation, go back to the main thread (dispatch_async again, specifying 
> the main queue this time) and put the result in the text field.
> 
> This is, of course, going to introduce threading issues into your design. If 
> the background thread keeps its results private (within the thread) until you 
> switch back to the main thread, you can actually update any permanent data 
> structures on the main thread, avoiding the need for locks or other 
> synchronization techniques. However, you have to arrange for the main thread 
> to avoid trying to use the results before the background computation is done, 
> or to start any new computations, until the old ones are done, as far as such 
> safety checks are necessary for your app.
> 
> (You can use NSOperationQueue instead of GCD, but I don’t see a lot of 
> advantage in that. The consequences are the same.)

You are absolutely right that a background would be the right thing.
But this is just a small tool for testing, and it will not take more than a few 
seconds, so I am trying to avoid this.

But I have found a solution (you mentioning setNeedsDisplay was a great help):

- (void)computeSomething
{
self.textField1.stringValue = @“Start computing”;
[self.textField1 display];
//  some seconds of computations
self.textField1.stringValue = @“Result = 42”;
}

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

iOS - how to make documents visible in iTunes

2016-03-19 Thread Gerriet M. Denkmann
I have an iOS app (9.2.1) (not document based) which contains stuff in:
/private/var/mobile/Containers/Data/Application/55…F0/Documents, which is the 
NSDocumentDirectory in NSUserDomainMask. 

I want to see these files in iTunes → my iOS Device → Apps → File Sharing
But my app does not even make it to this list of Apps.

Is there any magic needed in Info.plist (or where else)?

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: iOS - how to make documents visible in iTunes

2016-03-19 Thread Gerriet M. Denkmann

> On 20 Mar 2016, at 02:21, Quincey Morris 
>  wrote:
> 
> On Mar 19, 2016, at 11:24 , Gerriet M. Denkmann  wrote:
>> 
>> I have an iOS app (9.2.1) (not document based) which contains stuff in:
>> /private/var/mobile/Containers/Data/Application/55…F0/Documents, which is 
>> the NSDocumentDirectory in NSUserDomainMask. 
>> 
>> I want to see these files in iTunes → my iOS Device → Apps → File Sharing
>> But my app does not even make it to this list of Apps.
>> 
>> Is there any magic needed in Info.plist (or where else)?
> 
> If you want to see those files that way, then you’re going to have to declare 
> the document types in your info.plist like any UIDocument-based app.

Turns out this is not necessary.
But what is needed is: UIFileSharingEnabled = Application supports iTunes file 
sharing = YES
> 
> If you want to examine the container for debugging purposes, you can go to 
> the Xcode Devices window, select your app and choose (e.g.) Download 
> Container from the utility popup menu.

A very helpful hint. I did not know this before.

Thanks for your help!

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

Why is the first of March a Tuesday

2016-03-25 Thread Gerriet M. Denkmann
In my calendar 2016/3/1 is a Friday, but:

- (NSString *)timerStringFor: (NSDate *)date
{
NSDateFormatter *dateFormatter = [ [ NSDateFormatter alloc ] init];
dateFormatter.dateFormat = @"EEE dd MMM  HH:mm:ss ZZZ";
NSString *un = [ dateFormatter stringFromDate: date ];
NSLog(@"%s %@",__FUNCTION__, un);   //  Tue 01 Mar 2016 
01:00:00 +0700
return un;
}

prints “Tue 01 Mar 2016 01:00:00 +0700”

What am I doing wrong?

Gerriet.

Mac OS X 10.10.5



___

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

adding days

2016-03-25 Thread Gerriet M. Denkmann
Please ignore previous post.

NSDate *nextTh =[ currentCalendar   dateByAddingUnit:   
NSCalendarUnitDay
  value: 7
toDate: now
options:NSCalendarWrapComponents
];
NSLog(@“%s now + %zd days = %@",__FUNCTION__, addDay, [self timerStringFor: 
nextTh]);

prints:
now + 7 days = Tue 01 Mar 2016 22:35:33 +0700 (which is indeed a Tuesday)

But I expected now ( 25. Mar 2016) + 7 days = 1st of April (which is a Friday).

How to make NSCalendar work as intended?

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: Why is the first of March a Tuesday

2016-03-25 Thread Gerriet M. Denkmann

> On 25 Mar 2016, at 23:01, Clark Cox  wrote:
> 
>> 
>> On Mar 25, 2016, at 08:43, Gerriet M. Denkmann  wrote:
>> 
>> In my calendar 2016/3/1 is a Friday, but:
> 
> 
> Something's wrong with your calendar then :). March 1, 2016 *is* a Tuesday:

Yes, sorry for the noise.
I was adding 7 days to today and got 1. of March but expected 1. of April. (see 
my post about adding days).

Turns out that NSCalendarWrapComponents = “Specifies that the operation should 
use arithmetic for calendar addition.” is the wrong choice.
Without using “arithmetic" (instead using divination ?) I get the expected 
result.

Kind regards

Gerriet.

> 
> % cal
>  March 2016
> Su Mo Tu We Th Fr Sa
>1  2  3  4  5
>  6  7  8  9 10 11 12
> 13 14 15 16 17 18 19
> 20 21 22 23 24 25 26
> 27 28 29 30 31
> 
> 
>> 
>> - (NSString *)timerStringFor: (NSDate *)date
>> {
>>  NSDateFormatter *dateFormatter = [ [ NSDateFormatter alloc ] init];
>>  dateFormatter.dateFormat = @"EEE dd MMM  HH:mm:ss ZZZ";
>>  NSString *un = [ dateFormatter stringFromDate: date ];
>>  NSLog(@"%s %@",__FUNCTION__, un);   //  Tue 01 Mar 2016 
>> 01:00:00 +0700
>>  return un;
>> }
>> 
>> prints “Tue 01 Mar 2016 01:00:00 +0700”
>> 
>> What am I doing wrong?
>> 
>> Gerriet.
>> 
>> Mac OS X 10.10.5
>> 
>> 
>> 
>> ___
>> 
>> 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/clarkcox3%40gmail.com
>> 
>> This email sent to clarkc...@gmail.com


___

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

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

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

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

Strange Delay

2016-03-29 Thread Gerriet M. Denkmann
This is done once (OS X 10.10.5):
commonSendQueue = dispatch_queue_create( “common socket queue", 
DISPATCH_QUEUE_SERIAL);

Several objects do this quite often:

NSDate *dax0 = [ NSDate date ];
dispatch_async(commonSendQueue, ^{ @autoreleasepool { [ someOtherObject 
doSomethingwithDate: dax0]; }});

double delay1 = 50 msec
NSDate *dax1 = [ NSDate dateWithTimeInterval: delay1  sinceDate: dax0 ];
dispatch_time_t disTim1 = dispatch_time(DISPATCH_TIME_NOW, (int64_t)( delay1 * 
NSEC_PER_SEC));
dispatch_after(disTim1, commonSendQueue, ^{ @autoreleasepool  { [ 
someOtherObject doSomethingwithDate: dax1]; }});


someOtherObject does:
- (void) doSomethingwithDate: (NSDate *)date
{
NSTimeInterval inDelay = -date.timeIntervalSinceNow * 1e3;
if ( inDelay > 12 ) NSLog(@"%s  in-delay %9.3f msec",__FUNCTION__, 
inDelay);
}

The in-delay is usually less than a dozen milliseconds.

But in the call with dispatch_after (never with dispatch_async) the in-daly is 
sometimes is 10 seconds - sometimes even 20 or 30 seconds - mostly (but not 
always) near an integral multiple of 10 seconds.

Why this delay of 10 seconds, and how can I find out, what is the cause of it?

A breakpoint in doSomethingwithDate shows:

* thread #12: tid = 0x341eb, 0x000100012a43 gLifx`-[GCDAsyncUdpSocket 
doSomethingwithDate:](self=0x6180001e7300, _cmd=“ doSomethingwithDate:", 
date=2016-03-30 06:34:00 UTC) + 179 at GCDAsyncUdpSocket.m:1851, queue = 
'common socket queue', stop reason = breakpoint 1.1
— 
  * frame #0: 0x000100012a43 gLifx`-[GCDAsyncUdpSocket 
doSomethingwithDate:](self=0x6180001e7300, _cmd="doSomethingwithDate:", 
date=2016-03-30 06:34:00 UTC) + 179 at GCDAsyncUdpSocket.m:1851
frame #1: 0x0001000830ea gLifx`__52-[LFXUDPGatewayConnection 
sendNextMessageFromOutbox]_block_invoke186(.block_descriptor=0x600852d0)
 + 138 at LFXUDPGatewayConnection.m:359
frame #2: 0x00010018c989 
libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #3: 0x000100187fc3 libdispatch.dylib`_dispatch_client_callout + 8
frame #4: 0x00010019cd40 
libdispatch.dylib`_dispatch_after_timer_callback + 322
frame #5: 0x000100187fc3 libdispatch.dylib`_dispatch_client_callout + 8
frame #6: 0x000100196b20 
libdispatch.dylib`_dispatch_source_latch_and_call + 1239
frame #7: 0x00010018df1c libdispatch.dylib`_dispatch_source_invoke + 425
frame #8: 0x00010018c471 libdispatch.dylib`_dispatch_queue_drain + 1002
frame #9: 0x00010018bf28 libdispatch.dylib`_dispatch_queue_invoke + 223
frame #10: 0x00010018b9de libdispatch.dylib`_dispatch_root_queue_drain 
+ 666
frame #11: 0x00010018b73c libdispatch.dylib`_dispatch_worker_thread3 + 
106
frame #12: 0x7fff91241a9d libsystem_pthread.dylib`_pthread_wqthread + 
729
frame #13: 0x7fff9123f3dd libsystem_pthread.dylib`start_wqthread + 13
(lldb) 


Gerriet.

P.S. instead of dispatch_after I tried NSTimer and nanosleep. Same problem.
I also removed the autorelasepool - made no difference.



___

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: Strange Delay

2016-03-30 Thread Gerriet M. Denkmann

> On 30 Mar 2016, at 18:35, Ken Thomases  wrote:
> 
> On Mar 30, 2016, at 1:44 AM, Gerriet M. Denkmann  wrote:
>> 
>> This is done once (OS X 10.10.5):
>> commonSendQueue = dispatch_queue_create( “common socket queue", 
>> DISPATCH_QUEUE_SERIAL);
>> 
>> Several objects do this quite often:
>>  
>> NSDate *dax0 = [ NSDate date ];
>> dispatch_async(commonSendQueue, ^{ @autoreleasepool { [ someOtherObject 
>> doSomethingwithDate: dax0]; }});
>> 
>> double delay1 = 50 msec
> 
> What does this mean?  That's not valid code.  What’s the "msec" doing in 
> there?

Sorry about this confusing pseudo code. The actual code is:

double delay1 = 50 * 1e-3;  //  50 msec in units of second


>> dispatch_after(disTim1, commonSendQueue, ^{ @autoreleasepool  { [ 
>> someOtherObject doSomethingwithDate: dax1]; }});
>> 
>> 
>> someOtherObject does:
>> - (void) doSomethingwithDate: (NSDate *)date
>> {
>>  NSTimeInterval inDelay = -date.timeIntervalSinceNow * 1e3;
>>  if ( inDelay > 12 ) NSLog(@"%s  in-delay %9.3f msec",__FUNCTION__, 
>> inDelay);
>> }
>> 
>> The in-delay is usually less than a dozen milliseconds.
>> 
>> But in the call with dispatch_after (never with dispatch_async) the in-daly 
>> is sometimes is 10 seconds - sometimes even 20 or 30 seconds - mostly (but 
>> not always) near an integral multiple of 10 seconds.
>> 
>> Why this delay of 10 seconds, and how can I find out, what is the cause of 
>> it?
> 
>> P.S. instead of dispatch_after I tried NSTimer and nanosleep. Same problem.
> 
> This may have something to do with App Nap or timer coalescing.  

Well, this might explain a shift in a timer doing its stuff by a small amount. 
Seems unlikely to explain a delay of several 10s of seconds. 

> Is your app otherwise active during those delays?

It is constantly sending messages to someOtherObjects and these 
someOtherObjects send back messages.

Each someOtherObject creates (at init) a sequential queue (socketQueue) and two 
socket descriptors (socket4FD  and socket6FD for ipv4 and ipv6 respectively) 
and binds these to some host/port; then does:
dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, socket4FD, 0, socketQueue);
same for DISPATCH_SOURCE_TYPE_READ;
then adds dispatch_source_set_event_handlers for each dispatch_source.
Same for socket6FD.

But all activity of these someOtherObjects (which b.t.w. are a modified version 
of GCDAsyncUdpSocket) is done on its own sequential queue (socketQueue), which 
is ≠ commonSendQueue.
In sending back massages someOtherObject uses the main queue.
 
So it really should not have anything to do with the delay in commonSendQueue.

I just checked: same problem with 10.11.4.

Kind regards,

Gerriet.
___

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

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

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

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

Re: Strange Delay

2016-03-31 Thread Gerriet M. Denkmann

> On 30 Mar 2016, at 18:35, Ken Thomases  wrote:
> 
> On Mar 30, 2016, at 1:44 AM, Gerriet M. Denkmann  wrote:
> 
> This may have something to do with App Nap or timer coalescing.  

I made a small test app (available on request) which exhibits the same problem.

For the first few minutes Xcode shows App Nap Prevention and Idle Prevention 
both gray.
Then it starts napping and things go awry: timers get delayed by 10 seconds etc.

So you were absolutely right with “App Nap or timer coalescing”.

Kind regards,

Gerriet.



___

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

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

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

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

AirDropping Folders to iOS Device

2016-04-02 Thread Gerriet M. Denkmann
I am trying to teach my iOS app to accept AirDroppings.
I added two Document Types: public.plain-text and public.folder, (no Additional 
document type properties) and implemented application:openURL:options:

Dropping plain text files works fine.

But with folders: the iOS Device shows (shortly) “Air Drop is sharing ”, then appears a list of apps accepting folders (including mine), I 
select my app and nothing further happens.
My app is NOT activated, application:openURL:options: is NOT called and the 
folder does NOT show up in my apps …/Documents/Inbox.

Other iOS apps can accept folders, so it must be possible.
IOS 9.3.1, and my app does not use iCloud.

What am I missing?

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

NSFileWrapper serializedRepresentation

2016-04-04 Thread Gerriet M. Denkmann
NSFileWrapper  *fileWrapper = … some Folder …
NSData *dataRaw = fileWrapper.serializedRepresentation;
NSDate *dataCompressed = … COMPRESSION_LZFSE …

When I do this in OS X 10.11.4 dataRaw = 30380898, dataCompressed = 5638680 ( 
18.6 %)
But in the iOS Simulator 9.3.1: dataRaw = 28206422, dataCompressed = 4282602 ( 
15.2 %)

That is OS X (10.11.4) makes an 8 % bigger FileWrapper compared to iOS (9.3.1), 
which also compresses less well → 32% overhead.

Is there a method like: serializedRepresentationInTheNeatAndLean_iOS_way ?

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

UTI

2016-04-04 Thread Gerriet M. Denkmann
I have an OS X app, which creates a file like: SomeName.zapmax
This file has:
ContentType:  dyn.ad6s….j67df
Extended Attribut: com.apple.metadata:kMDLabel_u37…wqm = some unrecognisable 
data
ContentTypeTree: public.data ← public.item

This file gets sent via AirDrop to an iOS Device.

On this iOS Device is another app of mine, which accepts public.data as 
Document Type.

When this file arrives on the iOS Device, quite a few app (besides my app) 
declare to accept this file, which makes no sense, as it has a proprietary 
format.

I would like to give this file some special UTI, which only my iOS App does 
understand.
How can this be done?
That is, how to associate a special UTI with the file?

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: NSFileWrapper serializedRepresentation

2016-04-04 Thread Gerriet M. Denkmann

> On 4 Apr 2016, at 23:49, Jens Alfke  wrote:
> 
> 
>> On Apr 4, 2016, at 1:18 AM, Gerriet M. Denkmann  wrote:
>> 
>> When I do this in OS X 10.11.4 dataRaw = 30380898, dataCompressed = 5638680 
>> ( 18.6 %)
>> But in the iOS Simulator 9.3.1: dataRaw = 28206422, dataCompressed = 4282602 
>> ( 15.2 %)
>> 
>> That is OS X (10.11.4) makes an 8 % bigger FileWrapper compared to iOS 
>> (9.3.1), which also compresses less well → 32% overhead.
> 
> You’re compressing different data, so the compression level is going to be 
> different. Try compressing exactly the same data on both platforms, if you 
> really want a comparison.

Both the Simulator and the OS X App compress the same folder (which resides on 
OS X).

Kind regards,

Gerriet.


___

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

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

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

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

Re: NSFileWrapper serializedRepresentation

2016-04-04 Thread Gerriet M. Denkmann

> On 5 Apr 2016, at 00:35, Quincey Morris  
> wrote:
> 
> On Apr 4, 2016, at 09:59 , Gerriet M. Denkmann  wrote:
>> 
>> Both the Simulator and the OS X App compress the same folder (which resides 
>> on OS X).

> Incidentally, the OS X documentation for NSFileContentsPboardType, 
> serializedRepresentation’s data format, on says not to use it after 10.6.
I am not putting the data to a Pasteboard.


> It really sounds like you need to construct your own data representation, 
> optimized for size if that’s what’s important to you. Or is 
> NSFileContentsPboardType being demanded by something else?

What I need is just:
Folder → Data  and
Data → Folder

NSFileWrappers serializedRepresentation and initWithSerializedRepresentation 
looked like the obvious choice.

What are the alternatives?

Kind regards,

Gerriet.


___

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

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

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

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

Re: UTI

2016-04-04 Thread Gerriet M. Denkmann

> On 4 Apr 2016, at 23:48, Quincey Morris  
> wrote:
> 
> On Apr 4, 2016, at 08:30 , Gerriet M. Denkmann  wrote:
>> 
>> That is, how to associate a special UTI with the file?
> 
> You first need to *define* your own UTI. Add an entry to the Exported UTIs 
> section of the Info pane of the OS X app target in Xcode. For the UTI 
> identifier, enter a unique name using reverse-DNS format, similar to your 
> app’s bundle ID. You’ll also want a description (shows in Finder Info 
> windows), an extension, an icon, and specify conformance to public.data 
> (assuming it’s a pure data file, not a package).

Done this. Finder recognises my file.
> 
> If the app is document-based, you’ll also want to create (or modify) an entry 
> in the Document Types, so that you can save in this format. 
Not done. The exporting OS X app has no interest to read this file. It is 
purely for export.

> 
> If the iOS app is document-based, you’ll do the same thing (Exported UTI and 
> Document Type that uses it) in that app target.

The importing iOS app has both exported and imported UTI defined (not sure what 
is really needed).

But when the Document Types is only “my.private.uti”, then I am not asked to 
open in which app (good) but no data is received (bad).
If Document Types is only “public.data”, I get several apps to choose from. 
Choosing my app, the data is delivered.

The magic is to have 2 Document Types:  “my.private.uti” +  “public.data”. Now 
on receiving the data I get not asked to choose an app (as there is only one: 
mine) and the data arrives safely and is processed.

Bit confusing. But seems to be working now.

Thanks for your help!

Kind regards,

Gerriet.




___

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

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

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

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

Re: NSFileWrapper serializedRepresentation

2016-04-04 Thread Gerriet M. Denkmann

> On 5 Apr 2016, at 08:17, Graham Cox  wrote:
> 
>> On 5 Apr 2016, at 10:41 AM, Gerriet M. Denkmann  wrote:
>> 
>> What are the alternatives?
> 
> file paths or NSURL?

Not really. If I send file paths or NSURLs (pointing to files on OS X) to my 
iOS Devices, these would not be very useful.
I really need to send the data.

Kind regards,

Gerriet.


___

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

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

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

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

Re: NSFileWrapper serializedRepresentation

2016-04-04 Thread Gerriet M. Denkmann

> On 5 Apr 2016, at 08:30, Jens Alfke  wrote:
> 
> 
>> On Apr 4, 2016, at 9:59 AM, Gerriet M. Denkmann  wrote:
>> 
>> Both the Simulator and the OS X App compress the same folder (which resides 
>> on OS X).
> 
> OK, but the raw data size is significantly different, so they must be zipping 
> different data. I don’t know why that would be; maybe the file paths are 
> different from the simulated app’s POV? But I don’t think the algorithm being 
> used is any different across platforms. It’s just that the input data is 
> different, for whatever reason.
> 
>> What I need is just:
>> Folder → Data  and
>> Data → Folder
> 
> NSFileWrapper is reasonable, I guess. Just don’t obsess over the details of 
> the data size. Why does it matter, anyway?
Sending an additional 1.5 MB over (WiFi, Bluetooth - whatever is used by 
AirDrop) takes some additional time (probably an extra fraction of a second).
And you are right: it does not really matter (it might, if the files to be sent 
would be much bigger).


Kind regards,

Gerriet.


___

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

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

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

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

Re: UTI

2016-04-04 Thread Gerriet M. Denkmann

> On 4 Apr 2016, at 23:48, Quincey Morris  
> wrote:
> 
> On Apr 4, 2016, at 08:30 , Gerriet M. Denkmann  wrote:
>> 
>> That is, how to associate a special UTI with the file?

A quick follow-up:

Everything works even when the importing iOS app does NOT declare exported or 
imported UTIs.
The only thing needed for AirDrop to work are two Document Types: 
“my.private.uti” and “public.data” (where the former conforms to the latter).

Kind regards,

Gerriet.


___

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

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

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

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

Re: UTI

2016-04-04 Thread Gerriet M. Denkmann

> On 5 Apr 2016, at 10:19, Quincey Morris  
> wrote:
> 
> On Apr 4, 2016, at 18:16 , Gerriet M. Denkmann  wrote:
>> 
>> The importing iOS app has both exported and imported UTI defined (not sure 
>> what is really needed).
>> 
>> But when the Document Types is only “my.private.uti”, then I am not asked to 
>> open in which app (good) but no data is received (bad).
>> If Document Types is only “public.data”, I get several apps to choose from. 
>> Choosing my app, the data is delivered.
>> 
>> The magic is to have 2 Document Types:  “my.private.uti” +  “public.data”. 
>> Now on receiving the data I get not asked to choose an app (as there is only 
>> one: mine) and the data arrives safely and is processed.
> 
> This sounds wrong.
> 
> First, do NOT define the same UTI identifier in both the Imported UTIs and 
> Exported UTIs section of the plist. Note that “import” and “export” here 
> don’t refer to the documents or data, but to the UTI itself. An exported UTI 
> is one that the app owns/defines, and the Exported UTI definition *is* the 
> definition. An imported UTI is one that’s owned/defined by another app, but 
> this app *uses*, and provides details in case the owner is not installed. In 
> your case, you want to export the definition, because your app owns the 
> custom UTI. However, I doubt that this in itself is causing any strange 
> behavior, assuming the import and export definition are identical.

As I wrote in a follow up: declaring UTIs is not necessary for the importing 
iOS app at all.
> 
> Second, the idea that your custom UTI can trigger your iOS app, but not 
> supply it with data is bizarre. It actually sounds like there is something 
> wrong with one of your definitions, as if conformance to public.data isn’t 
> specified in the Exported UTI on iOS.
> 
> Are you following all the guidelines laid out in 
> https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
>  under heading “Supporting AirDrop” and subheading "Receiving Files and Data 
> Sent to Your App”?

Almost. I did not: “Be prepared to look for files in your app’s Documents/Inbox 
directory and move them out of that directory as needed.”
I just rely on  application:openURL:options: being called. 
(application:openURL:sourceApplication:annotation: is deprecated).

Well I did look (just for fun):
With one Document Type = “my.own.uti” air-dropping the file shows “Air Drop  is sharing  Cancel”, but then my app does NOT get activated, and 
when I activate it myself, there is nothing in the Inbox.

With both  “my.own.uti” and “public.data” my app DOES get activated and 
application:openURL:options: is being called (as it should).

This behaviour might rightly be called “bizarre”; it did not find it documented 
anywhere, but still: this is what my tests show.

Kind regards,

Gerriet.


___

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

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

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

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

NSTimer after Sleep

2016-04-29 Thread Gerriet M. Denkmann
OS X 10.11.4; Xcode Version 7.3 (7D175).

self.timer = [ NSTimer scheduledTimerWithTimeInterval: 900 … repeats: YES ];
self.timer.fireDate = [ NSDate dateWithTimeIntervalSinceNow:  ];

works fine without sleep.

But:
fireDate: Fri 29 Apr 2016 15:06:14 +0700 in 37.03 min +900 sec

Fri 29 Apr 2016 14:38:39 +0700 Wake. 
fireDate: Fri 29 Apr 2016 15:06:14 +0700 in 27.57 min +900 sec

Fri 29 Apr 2016 14:55:10 +0700 Wake. 
fireDate: Fri 29 Apr 2016 15:06:14 +0700 in 11.05 min +900 sec

Fri 29 Apr 2016 15:08:35 +0700 Wake. 
fireDate: Fri 29 Apr 2016 15:06:14 +0700 LATE 141.8 sec +900 sec

Fri 29 Apr 2016 15:26:31 +0700 Check. 
fireDate: Fri 29 Apr 2016 15:06:14 +0700 LATE 1217.8 sec +900 sec

I would expect the timer to fire rather soon now, but it never does.
The timer is not nil, is not invalid and has the correct fire time.

What am I doing wrong?

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

Where are my bytes hiding?

2016-05-04 Thread Gerriet M. Denkmann
I just did:
> cd 
> /Applications/Xcode.app/Contents/Developer/Documentation/DocSets/com.apple.adc.documentation.watchOS.docset/Contents/Resources/Tokens/C/tag/-
>  
> ls -skl

There are 8 files. Finder → File → Get Info → Size: has for each: xxx bytes 
(Zero bytes on disk), where “xxx” is the same number as reported by “ls -skl”.

First question: 
How does one achieve this phenomenal compression: 0 bytes on disk - but can 
expand to several thousand bytes? If this is not a creatio ex nihilo, then: 
where are these bytes hiding?

Second question:
Finder says about the containing folder: 11,239 bytes (33 KB on disk) for 9 
items
11,239 = sum of TotalFileSizes of the 8 files in this folder.
But where do the “33 KB on disk” come from? 8 times “Zero bytes on disk” should 
be zero, shouldn’t it?

The reason for these questions:
I want to write an app, which counts (for a given folder) the number of bytes 
stored on disk.

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: Where are my bytes hiding?

2016-05-05 Thread Gerriet M. Denkmann

> On 5 May 2016, at 13:13, Stephen J. Butler  wrote:
> 
> Those files are compressed by the filesystem. In HFS+/MacOS Extended that 
> means that the data fork is empty and the file contents are stored in the 
> resource fork or extended attributes structure.
> 
> http://wiki.sleuthkit.org/index.php?title=HFS#HFS.2B_File_Compression
> 
> If it's in the extended attributes, then it's part of the file metadata (like 
> name, timestamps, etc), whereas Finder is probably using the size of the 
> datafork to arrive at 0 bytes. If you get the afsctool (from MacPorts for 
> example) then you can get all sorts of detailed info:

/Applications/Xcode.app/Contents/Developer/Documentation/DocSets/com.apple.adc.documentation.watchOS.docset/Contents/Resources/Tokens/C/tag/-/objc_cache.xml
has indeed 2 extended attributes: com.apple.quarantine and com.apple.decmpfs.

The problem: xattr refuses to show com.apple.decmpfs - even shamelessly lies: 
“No such xattr: com.apple.decmpfs”.

Good news:  listxattr,getxattr do not lie (with XATTR_SHOWCOMPRESSION).

My own tool shows: 
com.apple.decmpfs = 895 bytes inline starting with: ‘cmpf’, 3, 0x7d5 = 2005 = 
uncompressed size, … (small endian ints).

The sum of all decmpfs in the folder is 4057 bytes - still no idea how Finder 
gets its: “29 KB on disk” .


Kind regards,

Gerriet.


___

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

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

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

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

How to keep things alive in Arc?

2016-05-08 Thread Gerriet M. Denkmann
Thing *aThing = [ Thing new ];

void *thingData = [ aThing data ];  //  pointer to a buffer owned by 
aThing

… never use aThing after this point → Arc might release aThing right now
… but do lots of things with thingData

… no more need for thingData
[ aThing release];

How to prevent Arc to release aThing before I have done with thingData?

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: How to keep things alive in Arc?

2016-05-08 Thread Gerriet M. Denkmann

> On 9 May 2016, at 09:25, Roland King  wrote:
> 
> 
>> On 9 May 2016, at 10:11, Gerriet M. Denkmann  wrote:
>> 
>> Thing *aThing = [ Thing new ];
>> 
>> void *thingData = [ aThing data ];   //  pointer to a buffer owned by 
>> aThing
>> 
>> … never use aThing after this point → Arc might release aThing right now
>> … but do lots of things with thingData
>> 
>> … no more need for thingData
>> [ aThing release];
>> 
>> How to prevent Arc to release aThing before I have done with thingData?
>> 
>> Gerriet.
>> 
> 
> 
> well [ aThing release ] won’t work in ARC, I assume you really mean aThing = 
> nil, or just letting aThing fall out of the bottom of the local scope
I meant: this was the code before I converted to Arc.

> either mark [ Thing data ] with NS_RETURNS_INNER_POINTER which is equivalent 
> to __attribute__((objc_returns_inner_pointer))

I did this, and now the app behaves again as it did before converting to Arc. 
No more data mutating behind my back and other strange effects.
Thanks a lot!

The only mention of this, which Xcode could find for me, was: Foundation 
Release Notes for OS X v10.8 and Earlier.
Is there any other documentation (e.g. with a list of all __attribute__s and 
their respective meaning)?


> or mark aThing with __attribute__((objc_precise_lifetime))
I think that NS_RETURNS_INNER_POINTER is more self explaining.


Kind regards,

Gerriet.


___

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

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

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

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

debugging AirDrop

2016-05-26 Thread Gerriet M. Denkmann
I have an OS X app (10.11.5) which has a button called AirDrop, which does:

- (IBAction)airDrop: (NSButton *)sender 
{
NSArray *shareItems = list of one or more urls of pdf files
NSSharingService *service = [ NSSharingService sharingServiceNamed: 
NSSharingServiceNameSendViaAirDrop];
service.delegate = self;//  probably not needed
[service performWithItems:shareItems];
}

Usually this just works:
I click the AirDrop button, a Panel slides down with a picture of the pdf (or a 
symbol for multiple files if more than one).
I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
The AirDrop panel on the Mac shows (after a few seconds) my Mac Login picture, 
I click it, and all is well.

Sometimes it does not work correctly:
In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
picture will appear on the Mac and it will still work.

But sometimes it does not work at all: 
I can do whatever (like restarting the iPad; restarting the Mac) but still no 
picture of a recipient will appear in the Mac AirDrop Panel. 

How can I debug this?

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

debugging AirDrop (update)

2016-05-26 Thread Gerriet M. Denkmann
I have an OS X app (10.11.5) which has a button called AirDrop, which does:

- (IBAction)airDrop: (NSButton *)sender 
{
NSArray *shareItems = list of one or more urls of pdf files
NSSharingService *service = [ NSSharingService sharingServiceNamed: 
NSSharingServiceNameSendViaAirDrop];
service.delegate = self;//  probably not needed
[service performWithItems:shareItems];
}

Usually this just works:
I click the AirDrop button, a Panel slides down with a picture of the pdf (or a 
symbol for multiple files if more than one).
I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
The AirDrop panel on the Mac shows (after a few seconds) my Mac Login picture, 
I click it, and all is well.

Sometimes it does not work correctly:
In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
picture will appear on the Mac and it will still work.

But sometimes it does not work at all: 
I can do whatever (like restarting the iPad; restarting the Mac) but still no 
picture of a recipient will appear in the Mac AirDrop Panel. 

How can I debug this?

Gerriet.

Found some log messages, which seem to be related:

Clicking my AirDrop button:

27/05/2016 12:17:41.630 sharingd[17313]: 12:17:41.629 : Bonjour discovery 
started
27/05/2016 12:17:41.662 sharingd[17313]: 12:17:41.662 : BTLE advertiser Powered 
On
27/05/2016 12:17:41.664 sharingd[17313]: 12:17:41.663 : BTLE advertising hashes 
<01ca38ce b5742b51 4900>
27/05/2016 12:17:41.667 sharingd[17313]: 12:17:41.666 : 
SDBonjourBrowser::failedToStartAdvertisingWithError Error 
Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at this 
time.}
27/05/2016 12:17:43.720 sharingd[17313]: 12:17:43.719 : 
SDBonjourBrowser::failedToStartAdvertisingWithError Error 
Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at this 
time.}

Clicking “Cancel" in the AirDrop Panel:

27/05/2016 12:19:46.595 AirDrop[17426]: Error in CoreDragRemoveTrackingHandler: 
-1856
27/05/2016 12:19:46.595 AirDrop[17426]: Error in CoreDragRemoveReceiveHandler: 
-1856
27/05/2016 12:19:46.658 sharingd[17313]: 12:19:46.657 : Bonjour discovery 
stopped
27/05/2016 12:19:46.671 sharingd[17313]: 12:19:46.671 : BTLE advertising stopped

But still don’t know what to do.

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: debugging AirDrop (update)

2016-05-27 Thread Gerriet M. Denkmann

> On 27 May 2016, at 23:18, Steve Christensen  wrote:
> 
> I haven't worked with AirDrop, but I just looked at the docs and one of the 
> delegate methods is -sharingService:didFailToShareItems:error:. Maybe if you 
> implement that you can at least see what the specific error is?
> 

Well, it does not tell anything. Never gets called. The problem: if there is 
no-one found to share things with, then there can be no sharing, and thus no 
errors while sharing.

“Invoked when the sharing service encountered an error when sharing items.”

But thanks for the suggestion. It is better to have this delegate method 
implemented.

Kind regards,

Gerriet.


> 
> 
>> On May 26, 2016, at 10:23 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I have an OS X app (10.11.5) which has a button called AirDrop, which does:
>> 
>> - (IBAction)airDrop: (NSButton *)sender  
>> {
>>  NSArray *shareItems = list of one or more urls of pdf files
>>  NSSharingService *service = [ NSSharingService sharingServiceNamed: 
>> NSSharingServiceNameSendViaAirDrop];
>>  service.delegate = self;//  probably not needed
>>  [service performWithItems:shareItems];
>> }
>> 
>> Usually this just works:
>> I click the AirDrop button, a Panel slides down with a picture of the pdf 
>> (or a symbol for multiple files if more than one).
>> I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
>> The AirDrop panel on the Mac shows (after a few seconds) my Mac Login 
>> picture, I click it, and all is well.
>> 
>> Sometimes it does not work correctly:
>> In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
>> picture will appear on the Mac and it will still work.
>> 
>> But sometimes it does not work at all: 
>> I can do whatever (like restarting the iPad; restarting the Mac) but still 
>> no picture of a recipient will appear in the Mac AirDrop Panel. 
>> 
>> How can I debug this?
>> 
>> Gerriet.
>> 
>> Found some log messages, which seem to be related:
>> 
>> Clicking my AirDrop button:
>> 
>> 27/05/2016 12:17:41.630 sharingd[17313]: 12:17:41.629 : Bonjour discovery 
>> started
>> 27/05/2016 12:17:41.662 sharingd[17313]: 12:17:41.662 : BTLE advertiser 
>> Powered On
>> 27/05/2016 12:17:41.664 sharingd[17313]: 12:17:41.663 : BTLE advertising 
>> hashes <01ca38ce b5742b51 4900>
>> 27/05/2016 12:17:41.667 sharingd[17313]: 12:17:41.666 : 
>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>> this time.}
>> 27/05/2016 12:17:43.720 sharingd[17313]: 12:17:43.719 : 
>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>> this time.}
>> 
>> Clicking “Cancel" in the AirDrop Panel:
>> 
>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>> CoreDragRemoveTrackingHandler: -1856
>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>> CoreDragRemoveReceiveHandler: -1856
>> 27/05/2016 12:19:46.658 sharingd[17313]: 12:19:46.657 : Bonjour discovery 
>> stopped
>> 27/05/2016 12:19:46.671 sharingd[17313]: 12:19:46.671 : BTLE advertising 
>> stopped
>> 
>> But still don’t know what to do.
>> 
>> 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: debugging AirDrop (update)

2016-05-27 Thread Gerriet M. Denkmann

> On 28 May 2016, at 02:06, Jens Alfke  wrote:
> 
> File a bug report with Apple!

Just done.

> 
> —Jens (who has intermittent troubles with AirDrop too)
> 
>> On May 27, 2016, at 10:47 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> 
>>> On 27 May 2016, at 23:18, Steve Christensen  wrote:
>>> 
>>> I haven't worked with AirDrop, but I just looked at the docs and one of the 
>>> delegate methods is -sharingService:didFailToShareItems:error:. Maybe if 
>>> you implement that you can at least see what the specific error is?
>>> 
>> 
>> Well, it does not tell anything. Never gets called. The problem: if there is 
>> no-one found to share things with, then there can be no sharing, and thus no 
>> errors while sharing.
>> 
>> “Invoked when the sharing service encountered an error when sharing items.”
>> 
>> But thanks for the suggestion. It is better to have this delegate method 
>> implemented.
>> 
>> Kind regards,
>> 
>> Gerriet.
>> 
>> 
>>> 
>>> 
>>>> On May 26, 2016, at 10:23 PM, Gerriet M. Denkmann  
>>>> wrote:
>>>> 
>>>> I have an OS X app (10.11.5) which has a button called AirDrop, which does:
>>>> 
>>>> - (IBAction)airDrop: (NSButton *)sender
>>>> {
>>>>NSArray *shareItems = list of one or more urls of pdf files
>>>>NSSharingService *service = [ NSSharingService sharingServiceNamed: 
>>>> NSSharingServiceNameSendViaAirDrop];
>>>>service.delegate = self;//  probably not needed
>>>>[service performWithItems:shareItems];
>>>> }
>>>> 
>>>> Usually this just works:
>>>> I click the AirDrop button, a Panel slides down with a picture of the pdf 
>>>> (or a symbol for multiple files if more than one).
>>>> I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
>>>> The AirDrop panel on the Mac shows (after a few seconds) my Mac Login 
>>>> picture, I click it, and all is well.
>>>> 
>>>> Sometimes it does not work correctly:
>>>> In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
>>>> picture will appear on the Mac and it will still work.
>>>> 
>>>> But sometimes it does not work at all: 
>>>> I can do whatever (like restarting the iPad; restarting the Mac) but still 
>>>> no picture of a recipient will appear in the Mac AirDrop Panel. 
>>>> 
>>>> How can I debug this?
>>>> 
>>>> Gerriet.
>>>> 
>>>> Found some log messages, which seem to be related:
>>>> 
>>>> Clicking my AirDrop button:
>>>> 
>>>> 27/05/2016 12:17:41.630 sharingd[17313]: 12:17:41.629 : Bonjour discovery 
>>>> started
>>>> 27/05/2016 12:17:41.662 sharingd[17313]: 12:17:41.662 : BTLE advertiser 
>>>> Powered On
>>>> 27/05/2016 12:17:41.664 sharingd[17313]: 12:17:41.663 : BTLE advertising 
>>>> hashes <01ca38ce b5742b51 4900>
>>>> 27/05/2016 12:17:41.667 sharingd[17313]: 12:17:41.666 : 
>>>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>>>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>>>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>>>> this time.}
>>>> 27/05/2016 12:17:43.720 sharingd[17313]: 12:17:43.719 : 
>>>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>>>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>>>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>>>> this time.}
>>>> 
>>>> Clicking “Cancel" in the AirDrop Panel:
>>>> 
>>>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>>>> CoreDragRemoveTrackingHandler: -1856
>>>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>>>> CoreDragRemoveReceiveHandler: -1856
>>>> 27/05/2016 12:19:46.658 sharingd[17313]: 12:19:46.657 : Bonjour discovery 
>>>> stopped
>>>> 27/05/2016 12:19:46.671 sharingd[17313]: 12:19:46.671 : BTLE advertising 
>>>> stopped
>>>> 
>>>> But still don’t know what to do.
>>>> 
>>>> 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/jens%40mooseyard.com
>> 
>> This email sent to j...@mooseyard.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: debugging AirDrop (update)

2016-06-01 Thread Gerriet M. Denkmann
Some Apple engineer asked me to do 3 to 5 reboots.
This sounded like voodoo to me, but I duly did 3 reboots.
Now my iPad gets discovered again (was undiscovered for a week, a reboot did 
not change anything).

Can anybody explain why 3 reboots ≠ 1 reboot?

Gerriet.


> On 28 May 2016, at 02:06, Jens Alfke  wrote:
> 
> File a bug report with Apple!
> 
> —Jens (who has intermittent troubles with AirDrop too)
> 
>> On May 27, 2016, at 10:47 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> 
>>> On 27 May 2016, at 23:18, Steve Christensen  wrote:
>>> 
>>> I haven't worked with AirDrop, but I just looked at the docs and one of the 
>>> delegate methods is -sharingService:didFailToShareItems:error:. Maybe if 
>>> you implement that you can at least see what the specific error is?
>>> 
>> 
>> Well, it does not tell anything. Never gets called. The problem: if there is 
>> no-one found to share things with, then there can be no sharing, and thus no 
>> errors while sharing.
>> 
>> “Invoked when the sharing service encountered an error when sharing items.”
>> 
>> But thanks for the suggestion. It is better to have this delegate method 
>> implemented.
>> 
>> Kind regards,
>> 
>> Gerriet.
>> 
>> 
>>> 
>>> 
>>>> On May 26, 2016, at 10:23 PM, Gerriet M. Denkmann  
>>>> wrote:
>>>> 
>>>> I have an OS X app (10.11.5) which has a button called AirDrop, which does:
>>>> 
>>>> - (IBAction)airDrop: (NSButton *)sender
>>>> {
>>>>NSArray *shareItems = list of one or more urls of pdf files
>>>>NSSharingService *service = [ NSSharingService sharingServiceNamed: 
>>>> NSSharingServiceNameSendViaAirDrop];
>>>>service.delegate = self;//  probably not needed
>>>>[service performWithItems:shareItems];
>>>> }
>>>> 
>>>> Usually this just works:
>>>> I click the AirDrop button, a Panel slides down with a picture of the pdf 
>>>> (or a symbol for multiple files if more than one).
>>>> I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
>>>> The AirDrop panel on the Mac shows (after a few seconds) my Mac Login 
>>>> picture, I click it, and all is well.
>>>> 
>>>> Sometimes it does not work correctly:
>>>> In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
>>>> picture will appear on the Mac and it will still work.
>>>> 
>>>> But sometimes it does not work at all: 
>>>> I can do whatever (like restarting the iPad; restarting the Mac) but still 
>>>> no picture of a recipient will appear in the Mac AirDrop Panel. 
>>>> 
>>>> How can I debug this?
>>>> 
>>>> Gerriet.
>>>> 
>>>> Found some log messages, which seem to be related:
>>>> 
>>>> Clicking my AirDrop button:
>>>> 
>>>> 27/05/2016 12:17:41.630 sharingd[17313]: 12:17:41.629 : Bonjour discovery 
>>>> started
>>>> 27/05/2016 12:17:41.662 sharingd[17313]: 12:17:41.662 : BTLE advertiser 
>>>> Powered On
>>>> 27/05/2016 12:17:41.664 sharingd[17313]: 12:17:41.663 : BTLE advertising 
>>>> hashes <01ca38ce b5742b51 4900>
>>>> 27/05/2016 12:17:41.667 sharingd[17313]: 12:17:41.666 : 
>>>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>>>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>>>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>>>> this time.}
>>>> 27/05/2016 12:17:43.720 sharingd[17313]: 12:17:43.719 : 
>>>> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
>>>> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
>>>> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
>>>> this time.}
>>>> 
>>>> Clicking “Cancel" in the AirDrop Panel:
>>>> 
>>>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>>>> CoreDragRemoveTrackingHandler: -1856
>>>> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
>>>> CoreDragRemoveReceiveHandler: -1856
>>>> 27/05/2016 12:19:46.658 sharingd[17313]: 12:19:46.657 : Bonjour discovery 
>>>> stopped
>>>> 27/05/2016 12:19:46.671 sharingd[17313]: 12:19:46.671 : BTLE advertising 
>>>> stopped
>>>> 
>>>> But still don’t know what to do.
>>>> 
>>>> 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/jens%40mooseyard.com
>> 
>> This email sent to j...@mooseyard.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

TableView crash with Delegate

2016-06-12 Thread Gerriet M. Denkmann
OS X 10.11.5, Xcode Version 7.3.1 (7D1014).

App with TableView (View based). Works fine. 
But when I give the TableView a delegate (even without implementing any 
NSTableViewDelegate methods) it crashes (see below).

How to debug this?
Tried a symbolic breakpoint in  -[__NSArrayM objectAtIndex:] - but it crashes 
before reaching breakpoint.


2016-06-12 15:26:36.172 Echo App[24004:2898793] *** -[__NSArrayM 
objectAtIndex:]: index 0 beyond bounds for empty array
2016-06-12 15:26:36.175 Echo App[24004:2898793] (
0   CoreFoundation  0x7fff8a3904f2 
__exceptionPreprocess + 178
1   libobjc.A.dylib 0x7fff880d873c 
objc_exception_throw + 48
2   CoreFoundation  0x7fff8a2a77c5 -[__NSArrayM 
objectAtIndex:] + 245
3   AppKit  0x7fff9a3dad31 
-[NSTableRowData _addViewToRowView:atColumn:row:] + 535
4   AppKit  0x7fff9a3da98e 
-[NSTableRowData _addViewsToRowView:atRow:] + 184
5   AppKit  0x7fff9a3d91a7 
-[NSTableRowData _initializeRowView:atRow:] + 390
6   AppKit  0x7fff9a3d7907 
-[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 416
7   AppKit  0x7fff9a3d769b 
-[NSTableRowData 
_addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 299
8   AppKit  0x7fff9a3d6461 
-[NSTableRowData _unsafeUpdateVisibleRowEntries] + 1697
9   AppKit  0x7fff9a3d5d22 
-[NSTableRowData updateVisibleRowViews] + 233
10  AppKit  0x7fff9a3d569b 
-[NSTableView layout] + 178
11  AppKit  0x7fff9a3743e7 -[NSView 
_doLayout] + 53
12  AppKit  0x7fff9a37409f -[NSView 
_layoutSubtreeWithOldSize:] + 324
13  AppKit  0x7fff9a3742fb -[NSView 
_layoutSubtreeWithOldSize:] + 928
14  AppKit  0x7fff9a3742fb -[NSView 
_layoutSubtreeWithOldSize:] + 928
15  AppKit  0x7fff9a3742fb -[NSView 
_layoutSubtreeWithOldSize:] + 928
16  AppKit  0x7fff9a3742fb -[NSView 
_layoutSubtreeWithOldSize:] + 928
17  AppKit  0x7fff9a3735d8 -[NSView 
layoutSubtreeIfNeeded] + 950
18  AppKit  0x7fff9a392f21 
-[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 82
19  AppKit  0x7fff9a4054ff 
-[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 244
20  AppKit  0x7fff9aa9c155 
___NSWindowGetDisplayCycleObserver_block_invoke6358 + 218
21  AppKit  0x7fff9a4174f8 
__37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 719
22  QuartzCore  0x7fff8f413f71 
_ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85
23  QuartzCore  0x7fff8f41342c 
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160
24  QuartzCore  0x7fff8f4130ec 
_ZN2CA11Transaction6commitEv + 508
25  QuartzCore  0x7fff8f41e977 
_ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 71
26  CoreFoundation  0x7fff8a325067 
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
27  CoreFoundation  0x7fff8a324fd7 
__CFRunLoopDoObservers + 391
28  CoreFoundation  0x7fff8a303ef8 
CFRunLoopRunSpecific + 328
29  HIToolbox   0x7fff97834935 
RunCurrentEventLoopInMode + 235
30  HIToolbox   0x7fff97834677 
ReceiveNextEventCommon + 184
31  HIToolbox   0x7fff978345af 
_BlockUntilNextEventMatchingListInModeWithFilter + 71
32  AppKit  0x7fff9a2bfdf6 
_DPSNextEvent + 1067
33  AppKit  0x7fff9a2bf226 
-[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
34  AppKit  0x7fff9a2b3d80 
-[NSApplication run] + 682
35  AppKit  0x7fff9a27d368 
NSApplicationMain + 1176
36  Echo App0x00013202 main + 34
37  libdyld.dylib   0x7fff887695ad start + 1
)
2016-06-12 15:26:36.314 Echo App[24004:2898793] -[NSApplication 
runModalForWindow:] may not be invoked inside of transaction commit (usually 
this means it was invoked inside of a view's -drawRect: method.)

Re: TableView crash with Delegate

2016-06-13 Thread Gerriet M. Denkmann

> On 13 Jun 2016, at 21:43, Alastair Houghton  
> wrote:
> 
> On 12 Jun 2016, at 10:10, Gerriet M. Denkmann  wrote:
>> 
>> OS X 10.11.5, Xcode Version 7.3.1 (7D1014).
>> 
>> App with TableView (View based). Works fine. 
>> But when I give the TableView a delegate (even without implementing any 
>> NSTableViewDelegate methods) it crashes (see below).
>> 
>> How to debug this?
>> Tried a symbolic breakpoint in  -[__NSArrayM objectAtIndex:] - but it 
>> crashes before reaching breakpoint.
> 
> Set it to break on exceptions (or put a breakpoint on objc_exception_throw), 
> then go back up the call stack?

This ultimately let me to the root of the problem:

My app has only one TableView, which is bound to Array Controller.
Array Controller binds its Content Array to AppDelegate with Model Key Path 
self.someUniqueObject.aMutableArray.
When the app starts a unique someUniqueObject gets created.

But I had:
- (void)awakeFromNib 
{
self.someUniqueObject = [ [ UniqueObject alloc ] init ];
}

The problem: awakeFromNib gets called twice: once before 
applicationDidFinishLaunching:, once after.
This obviously created a total mess.

Solution: move the creation of someUniqueObject to 
applicationDidFinishLaunching:


Thanks for your help!

Kind regards,

Gerriet.


___

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

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

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

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

Re: TableView crash with Delegate

2016-06-14 Thread Gerriet M. Denkmann

> On 14 Jun 2016, at 16:03, Alastair Houghton  
> wrote:
> 
> On 14 Jun 2016, at 05:33, Gerriet M. Denkmann  wrote:
>> 
>> But I had:
>> - (void)awakeFromNib 
>> {
>>  self.someUniqueObject = [ [ UniqueObject alloc ] init ];
>> }
>> 
>> The problem: awakeFromNib gets called twice: once before 
>> applicationDidFinishLaunching:, once after.
>> This obviously created a total mess.
> 
> It’s worth highlighting this, actually; -awakeFromNib gets called for the 
> “File’s Owner” object in the nib file, which means if your object has 
> multiple nib files associated with it, it can get called many times.  It’s 
> best (IMO) to always write your -awakeFromNib methods with that in mind 
> (though the documentation recommends trying to maintain a 1:1 correspondence 
> between owners and nib files).

There is just one nib file, owned by (“File’s Owner”) NSApplication.
It contains (among other things) an AppDelegate, referenced as “File’s 
Owner”.delegate and a (view based) TableView.

AppDelegate is not the “File’s Owner” of any nib.

awakeFromNib in AppDelegate is first called (as one of the topLevelObjects in 
the nib) via:
NSApplicationMain → … loadNib … → [NSSet makeObjectsPerform:]

After applicationDidFinishLaunching awakeFromNib is called again, this time 
via: 
NSApplicationMain → [NSApplication run] → [NSWindow layoutIfNeeded] … → 
[NSTableView layout] …→[NSTableRowData unarchiveView…] → [NSNib 
instantiateWithOwner] …

The documentation says: “You might also want to implement [awakeFromNib] for 
any other classes you instantiate directly in your nib file“, which probably 
means the topLevelObjects, like my AppDelegate.

But it does not mention whether these topLevelObjects get awakeFromNib sent 
only once or not.

But no problem, as long one keeps in mind (as you recommended) that 
awakeFromNib “can get called many times”.


Kind regards,

Gerriet.


___

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

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

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

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

Security with Streams

2016-06-17 Thread Gerriet M. Denkmann
I have a server macOS app which publishes a service via NSNetService.
And a client iOS app which finds this service via NSNetServiceBrowser.

Then the client sends commands to the server via NSOutputStream and receives 
data from the server via NSInputStream.

All this works fine - but there is currently no security at all.

I would like to achieve these goals:

1. (important) the client really wants to know that:
(1a) it is talking to the right server and not to some evil entity 
masquerading as the real server.
(1b) the data it receives has not been tampered with on the way.

2. (less important) the server might want to know that the client connecting to 
it is a valid client.
This might help if there are thousands of fake clients overwhelming the 
server with fake requests.
But this is a kind of unlikely scenario.

3. (hardly important at all) no one can read the data exchanged.
The data exchanged it really not sensitive.

I have no experience with security.
Can anybody point me in the right direction?

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

NSService (aka. Bonjour) outside local network

2016-06-24 Thread Gerriet M. Denkmann
Is it possible to create an NSService (OS X 10.11.45) which is discoverable 
(via NSServiceBrowser) outside of the local WiFi network?
What should be used for domain in this case?
If not: what is the use of domain ≠ “local.” , e.g. domain = “” ?

Also: I noticed that includesPeerToPeer = YES makes the kernel_task, which 
usually takes about 1% of my Cpu, go up to 11%. Back to 1% one minute after the 
app with NSService quits.

Is this normal and to be expected?

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: Security with Streams

2016-06-25 Thread Gerriet M. Denkmann

> On 26 Jun 2016, at 05:12, Jens Alfke  wrote:
> 
> 
>> On Jun 18, 2016, at 2:34 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> 1. (important) the client really wants to know that:
>>  (1a) it is talking to the right server and not to some evil entity 
>> masquerading as the real server.
>>  (1b) the data it receives has not been tampered with on the way.
> 
> You want an SSL (aka TLS) connection, with the server providing a certificate 
> (the typical setup.)
> 
>> 2. (less important) the server might want to know that the client connecting 
>> to it is a valid client.
>>  This might help if there are thousands of fake clients overwhelming the 
>> server with fake requests.
>>  But this is a kind of unlikely scenario.
> 
> For that you’d need the SSL client to provide a certificate too. This is 
> supported by the CFStream APIs.
> 
>> 3. (hardly important at all) no one can read the data exchanged.
>>  The data exchanged it really not sensitive.
> 
> Well, you get that for free with SSL anyway :)
> 
> Accomplishing (1b) and (3) is straightforward, I think. The doc-comment for 
> NSNetService says how to enable SSL/TLS for the sockets by setting the stream 
> properties:


Following TN2326 I created a (self signed) Certificate Authority and a Digital 
Identity called "MyServerId".

The server gets MyServerId from my keychain:
 
- (void)netService:(NSNetService *)sender 
didAcceptConnectionWithInputStream:(NSInputStream *)inputStream 
outputStream:(NSOutputStream *)outputStream
{
NSString *certificateName = @"MyServerId";
NSDictionary *d =   @{  (__bridge id) kSecClass:
(__bridge id) kSecClassIdentity,
(__bridge id) 
kSecReturnRef:@YES, 
(__bridge id) 
kSecMatchSubjectWholeString:  certificateName,
 };  
CFArrayRef copyMatchingResult;
OSStatus status = SecItemCopyMatching( (__bridge CFDictionaryRef)di, 
(CFTypeRef *)©MatchingResult );
if (status != errSecSuccess)...

id mySecIdentityRef = (__bridge id)copyMatchingResult;
NSArray *certs = @[ mySecIdentityRef ];
NSDictionary *settings =@{  (__bridge NSString 
*)kCFStreamSSLValidatesCertificateChain: @NO,

(__bridge NSString *)kCFStreamSSLIsServer:  
@YES,

(__bridge NSString *)kCFStreamSSLCertificates:  certs,
 };
BOOL ok = [ inputStream setProperty: settings  forKey: (__bridge 
NSString *)kCFStreamPropertySSLSettings ];
if ( !ok )  ...

... for both streams: scheduleInRunLoop, open
}


The client has a copy of MyServerId.cer (exported from my keychain) in its 
bundle.

- (void)netService:(NSNetService *)sender 
didAcceptConnectionWithInputStream:(NSInputStream *)inputStream 
outputStream:(NSOutputStream *)outputStream
{
NSDictionary *settings = @{ (__bridge NSString 
*)kCFStreamSSLValidatesCertificateChain: @NO };
BOOL ok = [ inputStream setProperty: settings  forKey: (__bridge 
NSString *)kCFStreamPropertySSLSettings ];
if ( !ok )  ...

... for both streams: scheduleInRunLoop, open
}

The NSStreamDelegate of the client compares the certificate in inputStream with 
the certificate in its bundle:

- (void)stream:(NSStream *)aStream  handleEvent: (NSStreamEvent)streamEvent 
{
if ( streamEvent & NSStreamEventHasSpaceAvailable ) 
{
if ( firstTimeHere )
{
firstTimeHere = NO;

NSString *kSSLPeerTrust = (__bridge NSString 
*)kCFStreamPropertySSLPeerTrust;
id trusT = [ inputStream propertyForKey: kSSLPeerTrust 
];   
if ( trusT == nil ) … error badServer

SecTrustRef trust = (__bridge SecTrustRef)trusT;
SecTrustResultType  trustResult;//  will 
be: recoverable trust failure; probably because certificate is based on self 
signed Certificate Authority 
OSStatus err = SecTrustEvaluate(trust, &trustResult);
if (err != errSecSuccess)   … error badServer

if trustResult ≠ kSecTrustResultProceed, 
kSecTrustResultUnspecified, kSecTrustResultRecoverableTrustFailure ... 
error badServer

 

Re: Security with Streams

2016-06-26 Thread Gerriet M. Denkmann

> On 27 Jun 2016, at 06:11, Jens Alfke  wrote:
> 
>> On Jun 25, 2016, at 7:44 PM, Gerriet M. Denkmann  
>> wrote:
> 
>> Absolutely not sure whether the code above is correct, but it seems to be 
>> working.

> It’s fine; the certificate is public and intended to be shared. It’s the 
> private key that’s sensitive. What you’re describing is called “key-pinning”: 
> restricting a client to connect only with a server with a known public key.

That is very reassuring to know. Thanks for the confirmation.

> That was fast! This is frustrating stuff to implement. Or maybe the docs have 
> gotten a lot better recently ;-)

I am great, am I not? (Well, to be honest, I have been struggling with this for 
weeks, and also borrowed heavily from the Apple sample code TLSTool)

> If every instance of the server has its own key, then embedding a cert in the 
> client app doesn’t work.

This project is for my own personal use. So there is just one server.

> The situation you want to watch out for is where the client connects to a 
> server it’s already connected to, but the cert’s public key doesn’t match the 
> previous one. 

In this case the client will close the connection immediately.


Kind regards,

Gerriet.


___

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

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

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

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

Re: Security with Streams

2016-06-26 Thread Gerriet M. Denkmann

> On 26 Jun 2016, at 21:59, Keary Suska  wrote:
> 
> 
>> On Jun 25, 2016, at 8:44 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> Following TN2326 I created a (self signed) Certificate Authority and a 
>> Digital Identity called "MyServerId".
>> 
> 
> 
>>> We are now falling into the rabbit hole that is peer-to-peer trust & 
>>> identity. How is your server going to identify it so that a client will 
>>> know that it’s the server it expects? I don’t know whether you’ve given any 
>>> thought to this; the answer affects how you’d implement this part of the 
>>> app.
>> 
>> I have thought about this, but I am not at all sure that my thoughts are 
>> correct.
>> Currently (as indicated in the code above) my client has a copy of the real 
>> server certificate and compares it with the certificate obtained from its 
>> inputStream.
>> I am not sure whether putting the server certificate into the client is ok 
>> or a breach of security. 
>> 
>> That is: the client will accept any server which has signed with the server 
>> certificate.
> 
> Self-signed certificates can only offer encryption, but cannot offer trust 
> because they are not verifiable. You can’t use the server certificate as a 
> key since you pass that key out to anyone who wants it (in your app), and 
> anyone who gets it can impersonate the server.

Assume that an evil entity has got hold of “MyServerCertificate.cer”, but has 
no access to my keychain and thus to the private key of MyServerCertificate. 
Could they use this certificate to open a secure stream to a client? Or do they 
need the private key to sign?


> I am unclear to me whether you are after a client-server (i.e. all servers 
> are under your control) or peer-to-peer (i.e. every client is a server and 
> every server is a client)) model? 

There is just one server, which is under my control.


Kind regards,

Gerriet.


___

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

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

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

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

Re: Security with Streams

2016-06-26 Thread Gerriet M. Denkmann

> On 27 Jun 2016, at 12:57, Jens Alfke  wrote:
> 
>> On Jun 26, 2016, at 8:13 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> Assume that an evil entity has got hold of “MyServerCertificate.cer”, but 
>> has no access to my keychain and thus to the private key of 
>> MyServerCertificate. 
>> Could they use this certificate to open a secure stream to a client? Or do 
>> they need the private key to sign?
> 
> — Servers don’t open connections to clients; it’s the other way around.

Sorry, I was speaking rather too loosely.

I meant: when the server accepts a connection from a client via 
netService:didAcceptConnectionWithInputStream:outputStream: 
it does:
[ inputStream setProperty: settings  forKey: kCFStreamPropertySSLSettings ]

where settings has: kCFStreamSSLCertificates = array with a SecIdentityRef 
obtained via SecItemCopyMatching().

Could it, instead of getting the SecIdentityRef from the keychain, just use 
MyServerCertificate.cer instead?


> — A certificate contains only the public key, not the private key. It can’t 
> be used to sign anything, only to verify signatures.

So this probably answers my question: It could not. (Correct ?).

So the evil server has to use its own EvilServerCertificate from its own 
keychain. 
And then the client would compare the certificate it receives with 
MyServerCertificate.cer and notice that these are different, thus closing the 
connection. (Correct ?)


Kind regards,

Gerriet.


___

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

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

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

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

Sharing to Notes in iOS obscured by Keyboard

2016-07-01 Thread Gerriet M. Denkmann
iOS 9.3.2

I have an app with a UISearchBar.
I type something in the SearchBar. Keyboard appears.
I press a long time in the SearchBar.
I get a black thingy “Select | Select All | Paste” and select “Select All”
I get another black thingy: “Cut | Copy | … | Share” and select “Share".
Keyboard disappears and I get a colourful Panel with, among others, “Add to 
Notes”. I select this.

I get a Notes-Panel, which has at the bottom something to choose which Note to 
use.
The problem: the keyboard has just reappeared and is obscuring the lower part 
of the Notes-Panel.

So: is there any notification like: “A share extention panel is going to 
appear”, which I could use to hide the keyboard.
Or what else can I do?

As it is now, sharing a selection to the Notes app is just not usable.

Oh, I just noticed: when I press the Home button and then reactivate my app, 
the Notes-Panel has magically moved up so that it is no longer obscured by the 
keyboard.

Also: this happens with all apps: type; then trigger the Notes-Panel → Panel 
obscured by keyboard.
Looks like an iOS bug.
But still: is there a work-around?

More: no problem on iPad (Keyboard goes when Notes-Panel comes); only with 
iPhone 5se.
Did not test with Simulartor, because it has no Notes app.


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

NSStream and Threads

2016-07-03 Thread Gerriet M. Denkmann
When I get an NSStream I do:

aStream.delegate = myStreamDelegate;
[ aStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode: 
NSDefaultRunLoopMode];
[ aStream open];

myStreamDelegate then receives stream:handleEvent: messages.

The documentation says: “The message is sent on the stream object’s thread."

Actually it is sent on the main thread.

How can I set the “stream object’s thread” ?

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: NSStream and Threads

2016-07-03 Thread Gerriet M. Denkmann

> On 4 Jul 2016, at 12:00, Charles Srstka  wrote:
> 
>> On Jul 3, 2016, at 11:35 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> When I get an NSStream I do:
>> 
>> aStream.delegate = myStreamDelegate;
>> [ aStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode: 
>> NSDefaultRunLoopMode];
>> [ aStream open];
>> 
>> myStreamDelegate then receives stream:handleEvent: messages.
>> 
>> The documentation says: “The message is sent on the stream object’s thread."
>> 
>> Actually it is sent on the main thread.
>> 
>> How can I set the “stream object’s thread” ?
>> 
>> Gerriet.
> 
> What thread is the run loop on?

Well, seems like the main thread?

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

Threads

2016-07-10 Thread Gerriet M. Denkmann
I have a subclass of NSThread (called MyThread), which runs a RunLoop in main.
When it gets cancelled, it leaves the RunLoop and main will exit.

Some other thread does:

if ( myThread.isCancelled )
{
//  probably the RunLoop of myThread is no longer running
//  adding stuff to a non-running RunLoop would result in [myThread 
dealloc] never called (some retain circle)
}
else
{
[ myThread  performSelector:@selector(someMethod) 
onThread:   myThread
withObject: nil
waitUntilDone:  NO 
];
}

But what if:
“Some other thread” tests for isCancelled and sees: “not cancelled”
Now yet another thread takes over and cancels myThread.
Then “Some other thread” runs again and does performSelector… (bad)

How to avoid this scenario?

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

2016-07-11 Thread Gerriet M. Denkmann

> On 11 Jul 2016, at 16:00, Alastair Houghton  
> wrote:
> 
> On 11 Jul 2016, at 06:35, Gerriet M. Denkmann  wrote:
>> 
>> I have a subclass of NSThread (called MyThread), which runs a RunLoop in 
>> main.
>> When it gets cancelled, it leaves the RunLoop and main will exit.
> 
> One further thought on this: it looks like you might be duplicating the 
> functionality of NSOperationQueue and/or GCD, in which case you might 
> consider using those instead?

Yes. I liked the idea of GCD better than NSLocks.

I created a serial queue for MyThread called serialQueue.

Then I overrode cancel in MyThread:

- (void)cancel
{
dispatch_async( self.serialQueue, ^void{ [ super cancel ] } );
}

And added to MyThread:

- (void)performSelector: (SEL)aSelector  withObject: object;
{
dispatch_async( self.serialQueue, ^void
{ 
if ( self.isCancelled ) return;

[ self  performSelector:aSelector
onThread:   self  
withObject: object 
waitUntilDone:  NO 
];  
} 
);
}

I think this solves my problem.

Thanks a lot for your help!

Kind regards,

Gerriet.


___

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

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

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

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

kCFStreamPropertySSLSettings

2016-07-22 Thread Gerriet M. Denkmann
I have an app (macOS 11.6) which uses kCFStreamPropertySSLSettings.

When it gets some streams it will show a panel:

“MyApp wants to sign using key “something” in your keychain” / “Allow” “Deny”

When I click “Deny” the streams get NSOSStatusErrorDomain errSecAuthFailed.
Else (clicked “Allow”) the app proceeds normally.
So far so good.

The problem: sometimes I do NOT get this panel, and the app behaves as if I had 
clicked “Deny”.
Before (11.5) quitting/restarting the app fixed this problem.

But in 11.6 I sometimes have to quit/restart a lot.

Where is this info: < “MyApp is allowed to use key “something”> stored? 
How to reset this (to force the app show the panel)?

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

2016-07-24 Thread Gerriet M. Denkmann

> On 23 Jul 2016, at 06:41, Jens Alfke  wrote:
> 
> 
>> On Jul 22, 2016, at 2:46 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> When it gets some streams it will show a panel:
>> “MyApp wants to sign using key “something” in your keychain” / “Allow” “Deny”
> 
> Presumably this app is either acting as an SSL server, or is sending SSL 
> clients.
It is acting as a server using NSStreams with TLS Security.

> Either of those roles involves signing data using the private key associated 
> with the certificate, to prove you own it.  If the app hasn’t previously used 
> that private key, the Keychain will ask your permission to let the app use 
> it. That’s the alert. Then it updates the key’s access control list to 
> remember your app has access. But this access is (usually) invalidated when 
> the app binary is modified, so you’ll (usually) see the alert again if you 
> modify the app and run it again.

This might be a problem: in another app (using another certificate) I once 
clicked “Always Allow” and have since then rebuild and modified the server 
countless times, and never seen this panel again.

> 
>> The problem: sometimes I do NOT get this panel, and the app behaves as if I 
>> had clicked “Deny”.
> 
> Huh. Had you previously denied the alert?
I may have done so once (a long time ago) to see what the result would be. But 
since then, I always click on “Always Allow”.

> Maybe the security framework hasn’t noticed that the app changed and is still 
> using the old Deny permission set before.

As I said: before 11.6 just quitting and rerunning the app fixed this issue. 
Now I have to go through some contortions: like running the debug version, then 
the release version; make some modifications; run it again; until it finally 
decides the show the magic panel.

> 
>> Where is this info: < “MyApp is allowed to use key “something”> stored? 
> 
> In the Keychain item for that key. You can look at and modify the permissions 
> in the Keychain Access app.

I looked at the certificate in the Keychain Access app: it tells me (under 
“Trust”) that:
When using this certificate: “Use System Defaults"
all other points: “no value specified”

But I cannot find any mention, which app has been allowed or denied access to 
this certificate.
Oh, I just found under Keys → Access Control:
“Confirm before allowing access” is checked.
“Always allow access by these applications:” lists:
Application-Group   ???
racoon  “racoon is used to setup and maintain an IPSec tunnel or 
transport channel, between two devices, over which network traffic is conveyed 
securely. “ maybe needed - I don’t know
Certificate Assitant.app(twice) looks reasonable (but why twice?)
Mail.app(what has Mail to do with my Streams? This does not look right)
My app  several dozen times - hovering over an item one sees the path: 
DerivedData…Release (several)  DerivedData…Debug (some), /Applications (ca. 10)

I copied my app to /tmp and ran it from there. It asked for permission to use 
the keychain (ok - “Always Allow”).
But I can find no mention of this copy of my app in the Keychain Access app.
Quit/Restart Keychain Access app fixed this.

Then copied my app to /tmp/Test and ran it. It did NOT ask for permission (but 
works fine).

Removed /tmp/MyApp from the list in Keychain app.
Restarted /tmp/Test/MyApp - now it asks for permission.

Removed all mentions of MyApp from the list in Keychain app (left just one with 
/Applications).
Started my app - it asked for permission - now Keychain app has two: MyApp 
(both in /Applications).

Something seems to be messed up.

Thanks for your help!


Kind regards,

Gerriet.



___

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

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

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

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

Re: kCFStreamPropertySSLSettingC

2016-07-25 Thread Gerriet M. Denkmann

> On 25 Jul 2016, at 15:30, Alastair Houghton  
> wrote:
> 
> 
>> On 23 Jul 2016, at 00:41, Jens Alfke  wrote:
>> 
>> 
>>> On Jul 22, 2016, at 2:46 AM, Gerriet M. Denkmann  
>>> wrote:
>>> 
>>> When it gets some streams it will show a panel:
>>> “MyApp wants to sign using key “something” in your keychain” / “Allow” 
>>> “Deny”
>> 
>> Presumably this app is either acting as an SSL server, or is sending SSL 
>> clients. Either of those roles involves signing data using the private key 
>> associated with the certificate, to prove you own it.  If the app hasn’t 
>> previously used that private key, the Keychain will ask your permission to 
>> let the app use it. That’s the alert. Then it updates the key’s access 
>> control list to remember your app has access. But this access is (usually) 
>> invalidated when the app binary is modified, so you’ll (usually) see the 
>> alert again if you modify the app and run it again.
> 
> Unless, of course, the application is signed with a suitable certificate, in 
> which case the access will be maintained, *provided* the application’s 
> signature remains valid (which it won’t on some subset of machines because of 
> people using badly written language stripping software that breaks the 
> signature on your bundle by tampering with it---particularly MacKeeper’s 
> implementation which appears to be automatic).
> 
> I’d make sure that your application is code signed.  It makes it very much 
> less tedious to develop or use.

This sounds like very good advice.

I looked at “Code Signing Identity” and found the following choices:

Don’t Code Sign (currently selected)
Automatic
Mac Developer
Mac Distribution
Developer ID: *
Identities in Keychain
Gerriet M. Denkmann
iPhone Developer Gerriet …. (Zxyz…)
Mac Developer Gerriet…(Zxyz…)
Other…

What would be the right thing to choose?

Kind regards,

Gerriet.


___

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

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

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

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

Handoff from macOS to iOS

2016-07-30 Thread Gerriet M. Denkmann
I have an iOS app and a macOS app - both implement handoff (NSUserActivity).

Handoff works between iOS devices and from iOS to macOS.

But never from macOS to iOS device.

The macOS app is document based, the iOS app is not.

In the macOS app the subclass of NSDocument implements updateUserActivityState: 
which gets called and fills the userInfo dictionary.

Any ideas how to debug this?

Gerriet.

P.S. macOS 10.11.6; iOS 9.3.3


___

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

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

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

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

How to Open Dictionary

2016-09-01 Thread Gerriet M. Denkmann
I have an iOS app (9.3.5) which has an UITextView where the following is done 
often:

User long presses first word
(User clicks “Select” - only needed if Keyboard is visible)
User clicks “Define”
→  the definition of the first word is displayed (e.g. in Oxford Dictionary of 
English).

I want to add a button, called “Show Definition of First Word” which does all 
these steps.
Selecting the first word is no problem.

But how to simulate the click on “Define” in the action method of my new 
button? I cannot find anything in UITextView or UITextViewDelegate.

In macOS I would use [NSView showDefinitionForAttributedString:atPoint: ].
But I could find no such thing in UIView.

Where to look for this?


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: How to Open Dictionary

2016-09-02 Thread Gerriet M. Denkmann

> On 2 Sep 2016, at 13:46, Igor Ranieri  wrote:
> 
> You might want to look into UIReferenceLibraryViewController. That’s the 
> class that presents the dictionary view for you, you can instantiate it with 
> a term and present it to the user.
> 

Thanks a lot! Exactly what I was trying to find.

Kind regards,

Gerriet.


>> 
>> In macOS I would use [NSView showDefinitionForAttributedString:atPoint: ].
>> But I could find no such thing in UIView.
>> 
>> Where to look for this?
>> 
>> 
>> 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

Substring in Swift

2016-09-02 Thread Gerriet M. Denkmann
How to translate this into Swift (current version, i.e. the one before 3.0):

UITextView *uitv = …
NSRange selectedRange = uitv.selectedRange;
NSString *textString = uitv.string;
NSString *selectedString = [ textString substringWithRange: selectedRange ];

Looks simple, but I have now tried for more than one hour.

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: Substring in Swift

2016-09-02 Thread Gerriet M. Denkmann

> On 2 Sep 2016, at 20:00, Jim Adams  wrote:
> 
> 
>> On Sep 2, 2016, at 5:17 AM, Gerriet M. Denkmann  wrote:
>> 
>> How to translate this into Swift (current version, i.e. the one before 3.0):
>> 
>> UITextView *uitv = …
>> NSRange selectedRange = uitv.selectedRange;
>> NSString *textString = uitv.string;
>> NSString *selectedString = [ textString substringWithRange: selectedRange ];
>> 
>> Looks simple, but I have now tried for more than one hour.

The solution in Swift I have found uses NSString to cope with NSRange:

// uitv is UITextView
let swiftString = uitv.text 
let nsString = swiftString as NSString
let selectedNSRange = uitv.selectedRange
let selectedText = nsString.substringWithRange( selectedNSRange )

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: Substring in Swift

2016-09-02 Thread Gerriet M. Denkmann

> On 3 Sep 2016, at 00:23, Quincey Morris  
> wrote:

[…]

> My only quibble would be the double bridging:
> 
>> let swiftString = uitv.text  // bridging from 
>> NSString to String
>> let nsString = swiftString as NSString   // bridging from String 
>> to NSString
> 
> Technically, bridging is a value conversion, though in practice the 
> underlying concrete NSString subclass likely survives the “conversion". The 
> danger is that there’s no API contract that prevents the generated code from 
> *really* converting the underlying representation, and that might lead you 
> back into the non-uniqueness-of-representation problem. So, I’d suggest:
> 
>> let nsString = uitv.text as NSString
> 
> which keeps you in the NSString domain.

I did not know this. Thanks for telling me.
I have fixed my code accordingly.


Kind regards,

Gerriet.


___

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

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

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

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

formatted strings in Swift

2016-09-02 Thread Gerriet M. Denkmann
Did in a playground:

let s = String(format: "%2s → %2s", "a", "b")   
print(“formatted = \"\(s)\"")

But this prints random garbage (e.g.: formatted = “‡“S → ‡“S”)  (no error 
message or compiler warning).

Why?
How to create a formatted string?

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: formatted strings in Swift

2016-09-03 Thread Gerriet M. Denkmann

> On 3 Sep 2016, at 12:22, Quincey Morris  
> wrote:
> 
> On Sep 2, 2016, at 22:02 , Gerriet M. Denkmann  wrote:
>> 
>> Did in a playground:
>> 
>> let s = String(format: "%2s → %2s", "a", "b")
>> 
>> print(“formatted = \"\(s)\"")
>> 
>> But this prints random garbage (e.g.: formatted = “‡“S → ‡“S”)  (no 
>> error message or compiler warning).
>> 
>> Why?
> 
> Because %s is the specifier for a C-string, and “a", "b" are Swift strings.

Sorry. This I should have known.

But:
let scom3 = String(format: "%9@", "a")  
print(“formatted %9@ = \”\(scom3)\"")   → formatted %9@ = "a"
I.e. the size parameter 9 seems to be ignored. (I kind of remember having the 
same problem in Objective-C).

> 
>> How to create a formatted string?

[…]

> If you absolutely must use %2s, the following works too (in a playground):
> 
>   let s = String(format: "%2s → %2s", ("a" as NSString).utf8String!, ("b" 
> as NSString).utf8String!)
> 
> but that’s a lot of ugly.

Ugly, but better than all the other work-arounds I have tried:

let scom1 = String(format: "%9s", ("a" as NSString).UTF8String) 
print(“formatted %9s = \”\(scom1)\”")   → formatted %9s = "a"


Kind regards,

Gerriet.




___

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

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

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

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

Re: formatted strings in Swift

2016-09-03 Thread Gerriet M. Denkmann

> On 3 Sep 2016, at 14:52, Quincey Morris  
> wrote:
> 
> The other issue I can think of would be how to interpret the field width, 
> since “real” strings can be counted in different ways. Would %9@ mean 9 
> UTF-16 code units? 9 Unicode code points? 9 grapheme clusters?
> 
> There’s probably a similar ambiguity with %9s. It apparently means 9 bytes 
> from/including a C-string, which is not necessarily 9 of anything in a UTF-8 
> string. Since you work with non-Roman character sets, you’ll probably run 
> into this eventually, if you’re padding strings with spaces.

I tried:
let a = “ü” //(u with Umlaut)
print(“\(a) has \(a.characters.count) characters, \(a.unicodeScalars.count) 
unicodeScalars, \(a.utf16.count) utf16")
→ ü has 1 characters, 1 unicodeScalars, 1 utf16

let nsa = a as NSString
print(“\(a) as NSString = \”\(nsa)\” with length \(nsa.length)") → ü as 
NSString = "ü" with length 1

let scom1 = String(format: "%9s", nsa.UTF8String)   
print(“\(a) formatted %9s = \"\(scom1)\" with  \(scom1.characters.count) 
characters, \(scom1.unicodeScalars.count) unicodeScalars, \(scom1.utf16.count) 
utf16")
→ ü formatted %9s = "   √º" with  9 characters, 9 unicodeScalars, 9 utf16

That is: even for Roman scripts (but not plain Ascii) UTF8String does not work 
in Swift.
I seem to remember that this used to work ok in Objective-C.

Just tried it: 
NSString *str = @“ü”; 
NSLog(@"NSLog \"%9s\"", str.UTF8String);→  NSLog “   √º”
(same garbage as in Swift)
fprintf(stderr,"fprintf = \"%9s\"\n", str.UTF8String);  → fprintf = “   ü”  
(correct)

[NSString stringWithFormat: str.UTF8String] has the same garbage.
This is kind of worrying.


By the way: what I really wanted to do is:
let s = String(format: “%9d”, someString.endIndex )
but:   error: argument type 'Index' (aka 'String.CharacterView.Index') does not 
conform to expected type 'CVarArgType'

So I came up with 
let s = String( someString.endIndex )
and print this with %9s, which works ok as “s” is plain Ascii.





___

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: formatted strings in Swift

2016-09-03 Thread Gerriet M. Denkmann

> On 3 Sep 2016, at 16:23, Quincey Morris  
> wrote:
> 
> On Sep 3, 2016, at 02:06 , Gerriet M. Denkmann  wrote:
>> 
>> By the way: what I really wanted to do is:
>> let s = String(format: “%9d”, someString.endIndex )
> 
> I don’t understand this. Is %9d a typo for %9s? Or are we now talking about 
> numbers instead of strings? I don’t get how endIndex suddenly came into this.

I wanted to print some index with a format. 
let someIndex = someString.endIndex
let indexAsFormattedString = String(format: “%9d", someIndex )
But was told: error: argument type ‘Index' (aka 'String.CharacterView.Index’) 
does not conform to expected type 'CVarArgType'

So I did:
let indexAsString = String(someIndex)   //  ok
and tried to print indexAsString with a format.
This you helped me to do via:
let indexAsFormattedString = String(format: “%9s”, (indexAsString as 
NSString).utf8String )
Which works, because numbers are plain Ascii.


> Also, what are you expecting String (someString.endIndex) to be and/or mean?

It has the type ’String’ and contains a number in 0…someString.utf16.count .
It seems to be an index into the utf16 representation of the string. 
Which probably is an implementation detail not to be relied on, but somewhat 
useful for debugging.


But was really worries me is that fprintf can handle utf8String correctly even 
with non-Ascii, whereas [NSString stringWithFormat:] can not.


Kind regards,

Gerriet.


___

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

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

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

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

Init in Swift

2016-09-04 Thread Gerriet M. Denkmann
I have a SuperClass with several Subclasses.
The SuperClass will never be instantiated. It just contains code common to all 
subclasses.

Here an example:
I really want “onlyKnownBySubclass” to be a constant (i.e. let instead of var). 
But cannot figure out  how to do this.

class SuperClass
{
let knownBySuperclass: Int
var onlyKnownBySubclass: Int//  this is a constant, only set in 
SubClass.init

init(some: Int)
{
knownBySuperclass = some * 2
onlyKnownBySubclass = 0 //  this value will never be used
}

final func someFunction() -> Void
{
print("Should never be zero: \(onlyKnownBySubclass)")
}
}

final class SubClass: SuperClass
{
override init(some: Int)
{
super.init(some: some)

//  depends on knownBySuperclass:
onlyKnownBySubclass = knownBySuperclass + 5 //  
constant - will never change after this
}
}

let a = SubClass(some:11)
a.someFunction()//  prints: “Should never be zero: 27”

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: Init in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 5 Sep 2016, at 13:29, Quincey Morris  
> wrote:
> 
> On Sep 4, 2016, at 22:50 , Gerriet M. Denkmann  wrote:
> 
> If you can’t do that, you can do it with a closure, assuming the places of 
> definition aren’t more complicated than in your code. Something like this:
> 
>> class SuperClass
>> {
>>  let knownBySuperclass: Int
>>  let onlyKnownBySubclass: Int
>>  
>>  init(some: Int, calc: (known: Int) -> Int)
>>  {
>>  knownBySuperclass = some * 2
>>  onlyKnownBySubclass = calc (known: knownBySuperclass)
>>  }
>>  
>>  final func someFunction() -> Void
>>  {
>>  print("Should never be zero: \(onlyKnownBySubclass)")
>>  }
>> }
>> 
>> final class SubClass: SuperClass
>> {
var localConstantDependingOnSuper: Int  //  should really 
be a constant
>>  init(some: Int)
>>  {
localConstantDependingOnSuper = 0   //  all 
must be set before calling super
>>  super.init(some: some) { $0 + 5 }

localConstantDependingOnSuper = knownBySuperclass + 27
> 
>>  }
>> }
>> 
>> let a = SubClass(some:11)
>> a.someFunction() //  prints: “Should never be zero: 27”

This trick with the closure is rather neat. I would never have come up with it. 
Thanks for telling me!
But what to do about localConstantDependingOnSuper?


> More globally, this sort of thing is not terribly idiomatic for Swift, 
> because you’re trying to hide things that could get exposed other ways, for 
> example, by “hostile” subclassing. The Swift-ier way would be to use a 
> protocol instead of (or in addition to, but preferably instead of) the 
> superclass. The protocol would “force” the subclass to define its own 
> “onlyKnownBySubclass” locally.

I do not think this would work for me. There are several subclasses and the 
superclass contains lots of functions (some of which are overwritten by 
subclasses).
If the superclass becomes a protocol then all this code had to be duplicated in 
each subclass.


Another problem:
Super → SubA and SubB.
SubA → SubA1 and SubA2
SubB → SubB1 and SubB2

Both SubA1 and SubB1 have identical functions. As have  SubA2 and SubB2.
Multiple inheritance would be a solution here; but neither Objective-C nor 
Swift can do this (and I don’t like C++).

Current solution: cut and paste and trying to keep both versions in sync.
Anything better?

Kind regards,

Gerriet.



___

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

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

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

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

slicing in Swift

2016-09-06 Thread Gerriet M. Denkmann
var numbers: [UInt64] = …

func numbers( upTo nbr: Int ) -> [UInt64]
{
let slice = numbers[ 0 ..< nbr ] 
return slice
//  Cannot convert return expression of type ‘ArraySlice' 
to return type '[UInt64]' 

//  workaound:
var outCopy:[UInt64] = []
for i in 0 ..< nbr { outCopy.append( numbers[i] ) }
return outCopy
}

Any better way to do this?

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: slicing in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 7 Sep 2016, at 07:55, Jonathan Hull  wrote:
> 
> I realized my comment may not have been clear.

Probably clear enough.

> Here is the actual code (written in Mail):
> 
> var numbers: [UInt64] = …
> 
> func numbers( upTo nbr: Int ) -> [UInt64]  
> {
>   return Array( numbers[ 0 ..< nbr ] )
> }

Excellent. Exactly what I needed. Thanks a lot!.

Kind regards,

Gerriet.



___

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

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

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

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

Re: Init in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 7 Sep 2016, at 10:49, Quincey Morris  
> wrote:
> 
>> Another problem:
>> Super → SubA and SubB.
>> SubA → SubA1 and SubA2
>> SubB → SubB1 and SubB2
>> 
>> Both SubA1 and SubB1 have identical functions. As have  SubA2 and SubB2.
>> Multiple inheritance would be a solution here; but neither Objective-C nor 
>> Swift can do this (and I don’t like C++).
> 
> There’s not necessarily a straightforward conversion from subclassing to 
> protocol composition. It usually takes some fundamental re-thinking of your 
> approach to to the problem.

Following a suggestion from Greg Parker I solved my multiple inheritance 
problem with protocol extensions:

protocol Number
{
func aFunction() -> Int
}

extension Number
{
func aFunction() -> Int
{
print("Error: \(self.dynamicType) must override \(#function)")
return 0
}
}

protocol Number1: Number {}

extension Number1
{
func aFunction() -> Int
{
print("\(self.dynamicType) \(#function) returns 1")
return 1
}
}

[… Omitted similar code with “1” replaced by “2” …]

class NewSuper: Number {}
class NewSubA: NewSuper {}
class NewSubB: NewSuper {}
class NewSubA1: NewSubA, Number1 {}
class NewSubA2: NewSubA, Number2 {}
class NewSubB1: NewSubB, Number1 {}
class NewSubB2: NewSubB, Number2 {}

No more code repetition here. Very satisfying so far. Thanks to Greg Parker!

But now NewSuper has a class function like:
class func classFunction( number: UInt64 ) -> UInt64
{
print(“Error:  must override \(#function)")
return 0
} 
which is overridden in NewSubA1,2  NewSubB1,2 in the same style as aFunction.
So it should be part of my Number… protocols and extensions.
But I cannot get this to work.

NewSuper uses this classFunction like:
func otherFunction( arg: UInt64) -> UInt64
{
return self.dynamicType.classFunction(  arg ) + 21
}

Kind regards,

Gerriet.



___

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

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

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

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

Re: Init in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 7 Sep 2016, at 10:49, Quincey Morris  
> wrote:
> 
> On Sep 6, 2016, at 17:17 , Gerriet M. Denkmann  wrote:
>> 
>> But what to do about localConstantDependingOnSuper?
[…]
> Anyway, this particular example is fairly easily solved by declaring 
> “localConstantDependingOnSuper” as ‘private(set)’.

My Swift book (2.2) has no mention of “private” (Swift 3 beta has).
But even assuming I had Swift 3, I do not quite understand how this should be 
done (I may be a bit dense).

Could you please elaborate?

Kind regards,

Gerriet.


___

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

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

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

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

Re: Init in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 7 Sep 2016, at 11:28, Quincey Morris  
> wrote:
> 
> On Sep 6, 2016, at 21:14 , Gerriet M. Denkmann  wrote:
>> 
>> But I cannot get this to work.
> 
> Meaning … ?? A compiler error? What does the source code look like, of the 
> protocol with the class func in it? What is the error message?

Struggling in a Playground I get lots of different compiler errors with 
different tries.
The first one I remember: “class” was not allowed in a protocol extension, I 
was told to use “static” instead.

> 
>> NewSuper uses this classFunction like:
>> func otherFunction( arg: UInt64) -> UInt64
>> {
>>  return self.dynamicType.classFunction(  arg ) + 21
>> }
> 
> If this is how you’re using it, it’d be clearer for the method you’re 
> currently calling “classFunction” to be an instance method called something 
> like “utilityFunction”. The only real reason it would *have* to be a class 
> function would be if you’re calling it in a context where there is no 
> instance — and the above is not that.

This is a very good idea. I was using a class function, only because it does 
not access any of the ivars.
But it could be an instance method as well (and, as you mentioned: it better 
should be).

I’ll try to fix this in my code.

Thanks a lot!

Kind regards,

Gerriet.


___

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

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

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

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

Re: Init in Swift

2016-09-06 Thread Gerriet M. Denkmann

> On 7 Sep 2016, at 11:42, Quincey Morris  
> wrote:
> 
> On Sep 6, 2016, at 21:31 , Gerriet M. Denkmann  wrote:
>> 
>> My Swift book (2.2) has no mention of “private” (Swift 3 beta has).
> 
> It’s in the 2.2 book under “Language Guide” section “Access Control”

You are right. I used Books.app on my iPad to search for “private” and it found 
only private-use Unicode code points.
Probably my iPad is broken.

> 
>> But even assuming I had Swift 3, I do not quite understand how this should 
>> be done (I may be a bit dense).
> 
> It’s a bit of syntactical pseudo-magic, but it makes sense when you think 
> about it.

[…]

> In that case, you can freely change the value inside the class, but to 
> clients of the class, it “looks like” the property is declared like this: […]

I am more concerned with methods inside my class (and compiler optimisation, 
which might work better, if the compiler knows something to be constant).


> This use of ‘private(set)’ doesn’t prevent you from accidentally changing the 
> value inside the class somewhere. If you want to do that, you’re going to 
> have to get a bit more exotic, maybe a ‘lazy’ let.

I’ll try to read about “lazy”. But right now I am myself a bit lazy and must 
other things first.

Thanks a lot for your help!

Kind regards,

Gerriet.


___

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

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

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

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

Multiple Inheritance via protocol extensions in Swift

2016-09-06 Thread Gerriet M. Denkmann

Trying to eliminate code duplication I tried to use protocol extensions.
But I ran into a rather grave problem.
This probably is “working as documented”.
But it surely it is not working like I hoped it would.

Here is a Playground example:

protocol Number
{
func aFunction() -> Int
}

extension Number
{
func aFunction() -> Int
{
print("Error: \(self.dynamicType) must override \(#function)")
return 0
}
}

protocol Number1: Number {}

extension Number1
{
func aFunction() -> Int
{
print("\(self.dynamicType) \(#function) returns 1")
return 1
}
}

// in my real code there are also a Number2 and Number3 protocols

class NewSuper: Number
{
func superFunction() -> Int
{
return aFunction()
}
}
class NewSubA: NewSuper
{
func subAFunction() -> Int
{
return aFunction()
}
}
class NewSubA1: NewSubA, Number1 {}

let newA1 = NewSubA1()

let c0 = newA1.aFunction()  //  ok
let c1 = newA1.superFunction()  //  prints: Error: NewSubA1 must override 
aFunction()
let c2 = newA1.subAFunction()   //  prints: Error: NewSubA1 must override 
aFunction()

Anything to be done here? Or should I just forget about protocol extensions?

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

Mixing Swift and Objective-C protocols

2016-09-07 Thread Gerriet M. Denkmann
I have several Swift classes CclassA, ClassB), all implementing the BitField 
protocol:

protocol BitField
{
init?(limit: UInt64, verbose: Int)
}

My AppDelegate Swift class has:

var a: BitField?
switch mm
{
case .A:a = ClassA(limit: maxp, verbose: verbose )  
case .B:a = ClassB(limit: maxp, verbose: verbose 
//case .C:  a = ObjC(limit: maxp, verbose: verbose )
Cannot assign value of type ‘ObjC!’ to type 'BitField?'
}

This works fine.
But now I want to add an Objective-C class.
I created BitFieldProtocol.h with:
@protocol BitField 
- (instancetype)initWithPrimeLimit: (uint64_t)primeLimit verbose: 
(NSInteger)verbose;
@end

and ObjC.h,m with:
@import Foundation;
#import "BitField.h"
@interface ObjC : NSObject   
- (instancetype)initWithLimit: (uint64_t)limit verbose: (NSInteger)verbose;
@end

I can create it in AppDelegate:
let ax = ObjC(limit: maxp, verbose: verbose )
print(“ax = \(ax)")

But I cannot put it into my switch statement. The compiler says: Cannot assign 
value of type ‘ObjC!’ to type 'BitField?'
How can I convince the compiler that the ObjC really implements the BitField 
protocol?

This compiles:
case .C:a = ObjC(limit: maxp, verbose: verbose ) as! BitField?

but crashes at run-time:
Could not cast value of type 'ObjC' (0x10bb0c298) to 'Primes.BitField’ 
(0x10bb10120).

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

  1   2   3   4   5   6   7   8   9   10   >