Saving files in xCode and making graph - xcode

I am new to programming. Now i have been learning for a few weeks and am now making my first app. Probably not for public, just for me. At least for now. So here it goes. I want the user to be able to enter his information (for example weight or something like that) into textField and then save it, so I can later form a graph (for example of weight loss through time). Now the graph should not be that much of a problem, since there are many tutorials on that. I am more interested in how to enter information, then save it so it can be later accessed. Any help? What should I read?
Thanks!

Working with UITextFields in Objective C is pretty straightforward - you can grab the NSString from such an object using the 'text' property. Use plists for storage locally, or JSON.

Look at core data tutorials especially related to Apples' doc on “Core Data and Cocoa Bindings”
CoreData shows how to setup objects and save them to a file or simple database. Cocoa Bindings are how to make input screens pass data to object models.
You should be able to write a program to enter weights, save them and show in a table without writing any code.

Related

How to do data modelling for a flowchart?

I've a requirement to persist a flowchart built by users into database. Until now, I've been using BLOBs to store the flowchart image. But I want to serialize the flow chart and persist them as a structured data.
For example, a flow chart will have start and end, process box, input/output box, decision flow etc. All these elements will be connected by arrows. I'm blanking out on how to model data structure that will store this information. Any tips would be appreciated?
Sorry, but this question is too vague.
Perhaps the best question to start off asking yourself:
Q: Do I really want to invent my own format, or find an existing "flowchart"
format that does what I need?
If you want to invent your own, I'd strongly suggest:
Using JSON or XML (instead of something completely ad-hoc), and
Finding JSON or XML examples for storing "graphs" (nodes, edges, etc).
Here is one such example: http://jsongraphformat.info/
But then your next challenge would be how to DISPLAY your flowchat, after you've read it from the database.
ANOTHER SUGGESTION:
Assume, for example, you're using Visio. I'd just store the .vsd in your database!

Whats the best way to include static information in my app?

I am currently working on my first small desktop menubar app (macOS, Swift 3). It needs to access
a) A list of words (Think word dictionary, 1k-5k words, per supported language)
b) A list of structured data (Think simple structs, ~500)
I am currently pondering, whether to build these in code - maybe a factory class per language. Or include them in my app as json and parse at runtime. Or maybe build an SQLite file and read that during runtime, although that approach would be harder to diff in source control ...
As I am new to the platform I was wondering whether there might be a better way that I am not aware of, or maybe performance considerations that render one of the mentioned approaches useless.
As usual, thanks in advance folks !
Your listed solutions can be used for this task. However I think for such kind of tasks the best solution is to use CoreData, where you can store a list of words as well as structured data, also make relations between them if you need it

Best barcodes and how/what to generate barcodes from, and how to store it the best way?

I am writing an webapp for a used thrift store. We are planning to add all items to a database, and I will be using Laravel and MySQL for this.
We also want to get a barcode scanner in order to scan and add items.
But I've never worked with barcodes before and info regarded this for a website like mine is hard to find info on, so is the barcode-scanners so I'm asking help from someone with experience.
I'm not sure which barcodes we should use, but I'm thinking a 3D one, like QR would do good. I've found several qr-generators, but I'm unsure on how I should create them properly from items.
Say the store is named Brukten. And it has items, with number IDs. Should I then generate barcodes out of "Brukten_53" or something, or just the ID, or how is a smart way? Because I can use an option like this instead of storing the generated barcode, right, and its better to generate a QR each time instead of storing the data about it?
At first we will use a web interface to add items, and later on we want to get a barcode-scanner to help scan things, so I'm guessing it would be nice with a scanner that could take pictures and add to database. So we want the DB to be ready for this, and properly made to work with such systems. So I'm wondering also if anyone can recommend me a device for this. I've seen several but unsure what to choose. 2d, 3d, something with camera, or is there other devices we could use?
What we want a device for is:
We want to store in the db: Old things, new things
We want to retrieve: all things
We want to alter info: edit things, sell, check things
Something easier than going around with a laptop, phone or a tablet and entering stuff.
Building the site is no problem for me, PHP, MySQL, Laravel framework and all is old stuff, but barcodes is a new world for me.
You only have to make sure that every single distinct physical item has a unique ID.
A simple way to accomplish this is using category ids as prefixes.
Suppose your "used men clothes category" is ID 25, and when you enter a pair on jeans of that category into the system, you app assign them ID 12345.
You can reference that item as 002500012345. You only need to calculate the 13rd digit using this function (http://edmondscommerce.github.io/php/barcode/ean13-barcode-check-digit-with-php.html) and you have a full-fledged EAN13 barcode you can print using this font (http://www.fontpalace.com/font-details/EAN-13/) and read with virtually any code scanner.
The other approach is generating a unique url for each product:
http://www.example.com/25/12345.html
And embed the url into a QR code.
You can generate the image for the QR code using this library:
http://phpqrcode.sourceforge.net/

Can Groups be used to emulate the "class" or "struct" data structures from other languages

Is there a data structure within LiveCode that can be used as a "holder" for associated data, letting me handle it collectively? I come from a Java / Javascript / C background so I am looking for a Class or Struct sort of data structure.
I've found examples of Groups, which seem to have some of this functionality, but it feels a bit like I'm bending the language to meet my needs.
As a specific example, suppose I had an image field on my screen that would randomly display an image and, when pressed, play an associated sound clip. I'd expect to create a list of "structures" that contained the path to the image and the path to the associated sound clip, and use that data to populate the image field and to decide what sound clip to play.
Would a Group be the correct structure to use in this case? Or am I approaching this in a way that isn't really fitting with the way LiveCode works?
It takes a little getting used to, but the xTalk world is much simpler and more open than any ordinary procedural language. So much of what you once had to manage is no longer required.
So when splash21 said that you could store all your image and sound references in a custom property, he was really saying that the LiveCode environment contains intrinsic, high level functionality that makes these sorts of things instantly accessible, and the only thing required of you is to call for them, and they simply work.
The only way to appreciate this is to make a few simple programs, to really see what is possible. Make your application. Everything you mentioned can be accomplished with perhaps a dozen lines of code in a single handler. I recommend that you join the LiveCode use list and forums. The community is vibrant and eager to help, frequently with full blown solutions to specific problems, but more importantly, as guides and mentors to new users
Craig Newman
Arrays in LiveCode are actually associative arrays (like hash maps). A key is associated with a value. The value might be as well an array.
Chapter 5.5.7 of the User's Guide says
Array elements may contain nested or sub-elements, making them multi-dimensional.
This type of array is ideal for processing hierarchical data structures such as trees or
XML. To access a sub-element, simply declare it using an additional set of square
brackets.
put "ABC" into myVariable["myKeyName"][“aChildElement”]
see also
How to store pictures in a stack?
Dave- I'm hoping to get a struct-like container implemented in the near future. Meanwhile you can, as splash21 mentioned, use custom properties (or better yet, custom property sets) to do what you want. This will give you a pseudo-struct for each object and you can implement the file and sound specifications into the properties. And if you use that in conjunction with a behavior object you'll end up very close to a real inheritable class formation.

NOOB Problems with getting results from code (more specificly with NSComboBox)

I know that this is probably a simple question but here is what I'm racking my brain to figure this out:
I know that this:
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index {
return [midiModelContents objectAtIndex:index];
}
will return the item at the index provided. My question is, what code do I need to use to call this routine?
I've tried something like this:
NSString *curData =(comboBox: midiModel objectValueForItemAtIndex:0);
but I get a "error: 'comboBox' undeclared"
Can anyone help me with the concept that I'm messing up?
First, you might want to read the Objective-C Programming Language to learn the correct syntax for sending messages to objects, including yourself.
You get a nonsense error message because you have written (what is in Objective-C) nonsense code. A valid Objective-C message expression would compile and run successfully, but I don't think it would do what you're expecting it to.
You see (and this is the second thing), comboBox:objectValueForItemAtIndex: is not ordinarily a message you send to yourself. The combo box sends that message to you when you are its data source. Data sources are a variation on the delegate pattern that is among the things described in detail in the Cocoa Fundamentals Guide.
(You can send the message to yourself, and it may even make sense to do this if you deliberately want to go through the same object-value-retrieval path the combo box does, but this is not what you need to do to make a combo box work.)
Both the Language document and the Cocoa Fundamentals document are essential reading for every Cocoa programmer, along with the Memory Management Guide for Cocoa. You should read all three documents from start to finish.
The solution to your immediate problem is for the object that responds to comboBox:objectValueForItemAtIndex: to be the data source of the combo box. You will probably hook this up in IB, in the same nib where you created the combo box.
If none of that makes any sense, then all I can suggest to you is, again, to read those documents. They will explain everything.
If you really did simply mean to ask yourself for the object value the same way the combo box does (i.e., you have the combo box working already and intend to get the object value the same way for some other purpose), then you still need to read the Objective-C Programming Language document to learn the correct syntax to send yourself that message.

Resources