Communicate to and from Hype and a native iOS app

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.

3 Likes

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,

Chris

2 Likes

Cool,

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:

2 Likes

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...

2 Likes

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,

Chris

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 voice.name == 'Bruce'; })[0];
u.text =  x
u.lang = 'en-UK';
u.rate = .8;
speechSynthesis.speak(u); 

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.

5 Likes