Communicate to and from Hype and a native iOS app

Not just yet but I’ve looked into it. I just wanted to make sure I could send to and from swift first

Can I suggest you watch these. The are 4 short videos that take you through coreData.

Ignore the parts that talk about the table, you are not using one. Instead you will use your data from hype.

Here is a quick example ( very thrown together as proof of concept ) of using stuff from the video.

Personally though I would push the text that needs editing to the App and use the app to edit ( similar to what the video shows in the name edits ) rather than a textArea or whatever on the scene. (513.1 KB)

1 Like

Hi @MarkHunte. Thanks you for putting this together for me and I'll watch the videos when I get a spare few minutes tonight.

I've attempted to run you demo you sent however it throws up an error in relation to:

webView!.evaluateJavaScript("HYPE.documents['(htmlName)'].getElementById('name').querySelector('textArea').value = '(st1! )'")

Fatal error: Unexpectedly found nil while unwrapping an Optional value

any ideas how I can correct this or is this something to do with how my Xcode is set up?

Thanks again for all your help,



Although I expect bugs in it due to it just being a proof of concept, thats one is odd.

I am still on Xcode Version 12.4 (12D4e) and MacOs Catalina.

So that could be it.

I just re downloaded the one I posted and it works.

Did you edit anything ?
I am assuming it means the st1 value is returning nil ?

Note also I have been playing with a different approach which does away with the textAreas as editors and uses the App as the editor. ( as mentioned above )

Again proof of concept to get started. But not worth posting just yet also we kinda need to get the other one working first..

1 Like

Hi @MarkHunte - Here is a screenshot when I run the code. It does appear that the st1 value is returning nil.

Might try run the code on my partners laptop if I can Xcode on that to see if it throws up the same error.



Hi @MarkHunte,

Just a quick update. I have tried to load the files in Xcode on my partners laptop to run the code and the same error happens. I'll try play around with this next week to see if I can get any success with it working on my set up but it does appear to be something related to running it on a newer version of Xcode.



What is your setup?
Xcode etc..

As a test substitute the string value with a hard coded one and see what it does.

Just to show possibilities

The code is a bit of a jumble where I am playing at seeing how this could work for multiple entries being sent to and from hype/App.

As it is it would likely confuse more than help.

So not posting it...yet at least .. but it shows you what I mean about using the built in editing of the app rather than the buggy TextAreas.

1 Like

Hi @MarkHunte. Sorry I haven’t got back to you today. I’ve been really busy but will look at this tomorrow. I did managed to hard code the string value very briefly and it worked so I’m wondering if it’s something to do with my set ups.

Thanks again,


No prob.
What system and Xcode are you on..

1 Like

I'm pretty sure the problem is that this line is failing:

if self.contentItems?.first?.content! == ""  {

On a fresh install nothing has been saved, and the value of self.contentItems?.first?.content! is going to be nil and not "". So since this check gives the wrong value it fails later with str1 expecting there to be content stored. Instead, if you change the line to:

if self.contentItems?.first?.content! == nil  {

It will at least not fail and and I believe work more correctly based on my skimming of what the code is trying to do.


Ah thanks for that makes sense. You understand it correctly , that part indeed is to try and counter empty coreData.

In my later code ( video above ) I had started using

if self.contentItems?.count == 0 {

1 Like

Hi @MarkHunte

On my MacBook - Big Sur 11.1 and Xcode 12.5.1

Just quickly tried this and the demo is working as expected now on my system :slight_smile:

I've not had a lot of time today to play more around this as I back to my day job this week but hopefully on Wednesday night I'll be able to look over the videos you sent and understand how this works and can be incorporated into my next app :+1: maybe I can get my boss to give me some time to work on my apps :crossed_fingers:

Thanks also @Jonathan for helping out with this and creating an amazing piece of software to help my ideas come to life.

I'll keep you both updated on my progress,

Thanks again,




I will probably post the new example in the next couple of days.

Do go over the videos, I feel that is key for getting started on coreData, don't kill yourself over the previous example but do look at it .
There are a some changes that deal with multiple boxes in the next version and also App native Alert/editor.

Again this is just proof of concept and may not be the correct way of writing an app to any acceptable standard. I.e Since all of my Apps I write are for my own use I am a hack when it comes to code.. :smiley:


Quick vid of the latest.

I did away with Alerts and am now using another ViewController.
This seemed a better way of doing it. The trick for me at least was figuring out a way to pass data to and back from each ViewController. I figured that out it, not seen it done my way but it works !!

I am using segue unwinds. Amazing little critters.

I will post the files once I have filled them with comments...


Hi @MarkHunte. this looks great? Does it effect any functionality with how the rest of the app will work in hype? As you can see from my online version, there is text to speech and I was wondering if this method would interfere with that somehow.

Thanks again,


Not as far as I am aware.
Text to speech just needs to know where to read from.
The new text is sent back to Hype to display as current.

How are you doing the text to speech.

By the way I will be putting the files up tomorrow morning..

1 Like

Using basic JS:

var text = hypeDocument.getElementById("text").innerHTML;
var x = text;
var u = new SpeechSynthesisUtterance();
var voices = speechSynthesis.getVoices();
u.voice = voices.filter(function(voice) { return == 'Bruce'; })[0];
u.text =  x
u.lang = 'en-UK';
u.rate = .8;

It works relatively well but obviously there some differences between different browsers.

I do not see why that would not still work.

Also note , in my Templates I actually show native app Speech to text. Although I think the one generated by your javascript probably sound better.

1 Like

I have posted the Project here as a new post.