Re: How to Open Dictionary

2016-09-02 Thread Cosmo Birch
You might find this site helpful: 
http://useyourloaf.com/blog/swift-string-cheat-sheet/ 

> On Sep 2, 2016, at 2:08 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.

___

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

Re: How to Open Dictionary

2016-09-01 Thread Igor Ranieri
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.

Best,

Igor

> On 01 Sep 2016, at 15:09, Gerriet M. Denkmann  wrote:
> 
> 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/igor%40elland.me
> 
> This email sent to i...@elland.me


___

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