Pagasi Journal starting the beginner classes!

kind of a lot just happened.

I was able to implement a scrollview behind my main view controller which was… scary when dealing with a storyboard lol! sometimes I do envy the expedience of SwiftUI, but anyways got it to work.

Then I was able to setup some observers to detect when the keyboard popped up thanks to a Youtube video… but that’s when the problems arose

So apparently touchesBegan doesn’t work on a scrollview… This is a problem because when your keyboard is a numberpad, there is no return button and the only good way to dismiss the keyboard is to either use touchesBegan (Hey, someone touched outside of the keyboard, you can dismiss the keyboard now) or by creating a custom keyboard… which I’m so not in the mood for…

It makes sense that you cant do both scrollview and touchesBegan because scrollview needs to hog all the touch input to manage itself. Supposedly using a tap-gesture gets around it but I couldn’t make that work. I ended up using some old code someone wrote involving subclassing the UIScrollView and also implementing a protocol to get around this. It did work!.. mostly. there’s a good reason why scrollview doesn’t work well with touchesBegan lol. when you go to scroll the view up it automatically activates the touchesBegan and dismisses the keyboard in my case… which defeats the purpose lol! Its a mess… My idea for a fix was to automatically scroll the screen up when the keyboard appears… but like… isn’t that what I was trying to do two days ago? full circle…

anyways! I did it! I got it to scroll up automatically with a

scrollView.setContentOffset(CGPoint, animated: true)

basically when the observer says, hey! the keyboard just popped up, this offset kicks in and bumps the scrollView up… I’m not entirely sure I get it but it worked! holy crap that was a lot of work.

A day off!! I had to do deliveries for my piano studio, as well as attend the end of the school year programs for both of my in school boys, so it was pretty much a given, but!! my wife graciously tested the app again and gave me a new challenge. I need a 3 month running average of 4 out of the 9 data points for each day… which is pulled from Core data as a full chunk of all the data at the moment… I honestly have no idea how I’m gonna do that, but it does seem like I’ll be able to solve it once I dig in so I’m looking forward to tomorrow!

oh my god dates are annoying! today I managed to do the math to average out a bunch of specific numbers from inside an object, that was quite the adventure because removing things from arrays does strange things when you are doing it with a loop lol! every number removed changes the count in the array and you end up with an index out of range … turns out theres this handy removeAll(where:) function that does all that for you hahahaha its good to learn things the hard way though right?

but to create the actual object I want to average out I’ll have to pick only the ones that have a date in the last 90 days… its supposed to be a rolling 3 month average. I’ve watched tons of videos today on it, and I think I can get it done, buuuut I’m only about 70% sure lol

okay working with core data is a bit weird. I’m trying to figure out how to update a specific entry from core data but from a separate file where I have methods for save and fetch data… I guess I don’t really need to do it. I have it working from inside the view controller, and I probably won’t be bothered to actually do it as long as the app works lol but it is still bugging me.

when you pass an array into a func and then save that array to core it creates a new entry. to update an entry you have to know which entry is being edited and I’m not sure how to pass that info into the method, or even how to use that info once I have it. Doing it straight from the tableview is much more convenient… if wrong lol

I’m also a little nervous about adding the “add an entry” icon because that would involve inserting that new entry into the core data array in a specific spot, as well as a date picker, or some way to select a date that the Date() class understands. But I’ll need to add it sigh . one needs to be able to add a date to the list.

but yeah! I was able to edit my data from a lead swipe edit function which pulls up an alert that displays the previous data for that entry as the placeholder text, or the label for that entry if there was no data there. Its pretty exciting!

Man I am caught in an annoying place where I already know the answer is “just use SwiftUI!” Lol but I’m still stubbornly sticking with just UiKit

So I’m trying to set up a progress bar… need to animate a bar of red over a bar of green while keeping text on top regardless of color beneath it. I know how to animate a line but it covers up the label. If I try to animate the width of say a red view over a green view then the label in the view would get smooshed when the view it’s in turns to a width of 0… this feels silly… I know this problem has been solved it’s too common a tool, I will google

…oh I see, there’s literally a UIProgressView I can drag and drop right on the storyboard… yeah I’ll look more into this tomorrow… lol

Question: where exactly should I look for an API? I want an API that will just give me the carb content of foods. I googled and I found one… but I don’t think I like it and I’m imagining that there are many more and I want to explore my options. Is there a place that lists out APIs that are available?

now that that’s out of the way lol, sorry I’ve been missing, left town for a funeral and haven’t been working on apps lately. BUT! I’ve gotten a ton of progress on the UIProgressView, and have successfully implemented what I had envisioned… now does it look good? well no not really but that doesn’t matter because I accomplished what I set out to do hahaha.

I was able to setup a UIProgressView super easy, but then couldn’t figure out why I couldn’t sit a label on top of it… I even mentioned this in @Chris2 's livestream when I saw a circle shaped progress bar lol. for some reason I was thinking that on a storyboard that

label
progressBar

would put the label on top… this is the zstack of the storyboard, and that stack specifically puts the progress bar on top of the label. I had gone so deep into this: learning how to use bezier paths and using basicAnimations, and then learning UIProgressViews and none of it was working all because… I was putting the label on the bottom of the stack facepalm

fortunately @Chris2 did at one point show us that you can go into debugging and look at the “view UI Heiarchy” and it will show you specifically how your objects are stacked… That is what I did and that was when I realized my error.

1 Like

https://data.nal.usda.gov/dataset/usda-national-nutrient-database-standard-reference-legacy-release

That’s one of the most respected food databases in the world.

I guess I’m not the only one working on a diet related app here.

1 Like

dude, I am super grateful! I will be dedicating tomorrow to exploring the data… I don’t see an api at first glance, are you just using it as a straight data file?

I’m not using it at all yet. Early days for me, but I work in the field, and know one of the big players in diet apps uses it.

There’s a small link to API info on the right menus, I THINK that should be helpful. But tbh it’s not info that needs to be updated a lot, so the json file may be all you need, depending on what you’re building.

API success! Well… kinda. So I need carb information on foods but who knew that could be so complicated! I have tapped into the usda.gov api that I can search for a food, but like when I search Apple it comes back with over 1000 resulting foods lol. Also if I just take the first one it’s Apple juice, not even an apple lol. Plus I get a carb amount, but not a serving size? Kinda weird… so yeah I have lots of work to do for sure, but still! I got an API to work and I’m pretty proud of it!

Nice!

I’m pretty sure that the carb amounts are normalized. I forget what units usda is using here everything is listed as g CHO / 100 g Food. (I’m in Europe)

I’m not even sure if I’m doing this right. I can make a call to the api through the http: string and I can edit the link so that I get different calls… but it seems like there’s a more formal way to make these calls. I was only able to understand the json model by directly putting that link into a web browser and then dropping it in a web app to break the json down so Its legible

And then the arrays of information aren’t always the same info… this is going to take some serious work…

But I am trying to look at other apps to see how they did it and it does start to make some sense

Yeah I just get that feeling that I’m reinventing the wheel here

Search bars and tableViews and Protocols! Oh my!

So adding a search bar to this app feels like an amalgamation of all the things lol first just adding it to a table view, then realizing this is the first time I actually need a protocol in my own app to pass data backwards to the main view once didSelectRowAt is used. It was all smooth sailing and it made me feel good that I feel very confident in my knowledge of tables and protocols! Good times

aaaand protocol fail

so I’m implimenting two protocols, and neither one seems to be working for different reasons.

The first protocol gets triggered when someone types into the search bar, which happens under the search function that detects when the search function has changed. This one does seem to work, but the function that needs the data from this trigger doesn’t seem to get the information until after the function has completed? so weird, so the next time the function runs, the data is there, but on the first run it is nil

the second protocol is supposed to send info from one view controller to another, and I’m not sure that’s allowed… on this one when its time to trigger the function that passes the data to the second view controller It just doesn’t trigger the function and I can’t for the life of me figure out why.

I’m quite annoyed with protocols right now, I thought I understood them completely but now they are giving me some serious trouble from the fact that I’m not using them the way they are normally used from the viewDidLoad like in the youTube app we made…

sigh

okay I’m posting here mostly for records sake. I’ve taken on a challenge at my business that’s going to change the way I teach piano pretty hardcore. I can already tell that I will desperately need to write an app to cater to my new needs when this transfer happens, and if all goes well I SHOUld have some extra time to actually program… however, in order to get this thing rolling, I’m going to have to take a short break from programming apps… I may return sooner rather than later, but this is a massive under taking, so I’m not really sure exactly how long it will be. At the latest I should be settled by August. At the soonest a few weeks. see ya’ll then!

Just checking in! My studio conversion process will last into early august and then it’ll be time to start designing the app to handle the new business! I’m actually nervous about the google calender api. I’ll absolutely need to use it and I looked at it and was completely confused lol apis still scare me

Okay so today I decided to dip my toes in the Swift UI ocean. I watched the very first few videos.

So already my SwiftUI screen is different from the video lol Xcode just can’t sit still… my screen has an AppDelegate and and SceneDelegate file instead of a test.Swift file. That’s worrisome. But probably all of you have already processed this lol.

Other than that I can see how watching from the beginning will be very useful! Things like how to open the minimap I simply didn’t know about. But also just taking the time to process this new ContentView file and familiarizing myself is taking a lot of the fear out of the process.

I still plan to wrap up my blood glucose app and start designing my own business app but I think this is a nice pressureless way to ease back into things.

Good to be back!

1 Like

Welcome to the dark side!

I know right! @inversewander i really am a complete beginner here lol which is weird cause I totally published an app in UIKit but feel completely lost for now.

I did one more lesson today and did the challenge! For a minute there I thought Xcode had screwed me again because I couldn’t get to the section of the library that deals with Text it was something to do with where my cursor had clicked last? Weird, but it brings back memories of beating my head against walls… why do I do this to myself lol

1 Like

whoops! took another month off on accident. I’m still here though! just took another SwiftUI class, I plan to take one while the baby naps each day, he’s 1 year old now! insane! Its been a year and 3 months since I started this journey! Completing the app and taking a break to setup my new piano studio did a number on me though, getting back into the groove is tough! Anyways, here’s to remaking the war app!

1 Like