Continuing to play around in Swift and trying to convert something from the C world and have been stuck trying various syntax. I have some fixed data I want to initialize into a structure array. Here's how I wold do it in C but I can't figure it out in Swift so rather than keep guessing I'll ask those that know more. Here's my C code.
#include <stdio.h>
typedef struct my_data {
const char *company;
const char *city;
const char *state;
float latitude;
float longitude;
} my_data;
int main() {
my_data data[2]={
{ "Joes Crab Shack", "Miami", "FL", 30.316599, -119.050254},
{ "Jims Crab Shack", "Los Angeles", "CA", 35.316599, -112.050254}
};
}
In Swift I can create a similar struct...
struct my_data {
var company = String();
var city = String();
var state = String();
var latitude:Float;
var longitude:Float;
}
Now I am stuck in how to declare and initialize the fixed data like I am doing in C. Guessing it is something simple and getting the syntax right has baffled me. I'd like to keep the initialization style in the similar format to C since I can easily extract and format this data from a file.