Re: [swift-users] Mapping C semantics to Swift

2016-05-19 Thread Ramakrishna Mallireddy via swift-users
An working example, let fm = NSFileManager.defaultManager() var mh = mach_header() // Defined as C struct, var lc = load_command() // Defined as C struct var location = 0 if let data = fm.contentsAtPath("home/user/projects/some.o") { data.getBytes(&mh, length: sizeof(mach_hea

Re: [swift-users] Mapping C semantics to Swift

2016-05-19 Thread Joe Groff via swift-users
> On May 19, 2016, at 10:00 AM, Ken Burgett via swift-users > wrote: > > I would like to know if a struct in Swift has any guarantee of contiguity, > like a struct in C. I am attempting to port a C program that makes many > assumptions about the underlying semantics of C structs, and does th

[swift-users] Mapping C semantics to Swift

2016-05-19 Thread Ken Burgett via swift-users
I would like to know if a struct in Swift has any guarantee of contiguity, like a struct in C. I am attempting to port a C program that makes many assumptions about the underlying semantics of C structs, and does things like overlaying an array over the struct using a cast, and then performs a

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-19 Thread Jens Alfke via swift-users
> On May 19, 2016, at 12:58 AM, Quinn The Eskimo! via swift-users > wrote: > > The reason I ask is that most of the time when I mess around with files I > transfer the entire file to and from memory, which is something that the > Foundation APIs excel at. I believe Mac/iOS developers usually

Re: [swift-users] Dictionary with optional values

2016-05-19 Thread Jeremy Pereira via swift-users
> On 18 May 2016, at 11:56, Artyom Goncharov via swift-users > wrote: > > Hi, here is the playground snippet: > > var noOptDict = ["one": 1, "two": 2, "three": 3 ] > noOptDict["one"] = nil > noOptDict // “one” is gone > > var optDict: [String: Int?] = ["one": 1, "two": 2, "three": nil] > optD

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-19 Thread Quinn "The Eskimo!" via swift-users
On 18 May 2016, at 23:02, John Myers via swift-users wrote: > I've been having trouble figuring out how to read and write data to a > textfile … Your examples show you transferring the data line-by-line. Is that the end goal? Or just fallout from what you happened to get working? The reas