Live data from Hacker News

Interacting with C Pointers

developer.apple.com

11–15 of 15 posts

Re: Interacting with C Pointers

#12
>> For safety, Swift requires the variables to be initialized before being passed with &. This is because it cannot know whether the method being called tries to read from a pointer before writing to it.

Isn't the 'maybeError' var being used uninitialized in the example right about this passage?

Re: Interacting with C Pointers

#13

>> For safety, Swift requires the variables to be initialized before being passed with &. This is because it cannot know whether the method being called tries to read from a pointer before writing to it. Isn't the 'maybeError' var being used uninitialized in the example right about this passage?

It actually does get initialized, albeit intialized to "nil". Someone asked the same question on the devforums. https://devforums.apple.com/thread/238423?tstart=0

Re: Interacting with C Pointers

#14
post #2

I'm a little disappointed with the scope of this writeup. I just finished my first full Swift app this weekend, and by far, the most bothersome part was interacting with the C APIs (CoreMedia, ImageIO, etc.) I would have loved to see more examples of interacting with framework objects like CGImageSources, CMSampleBuffers, etc. For example, CGImageSourceCreateWithURL() returns an Unmanaged !. You can't pass that objec…

> I'm a little disappointed with the scope of this writeup.

There's a teaser at the end that there will be a follow-up article about UnsafePointer.

I just hope they hurry up and post it soon. I have half a large app that relies on UnsafePointers, and I could really use some clear documentation to reassure myself that I'm not abusing them.

Re: Interacting with C Pointers

#15
post #2

I'm a little disappointed with the scope of this writeup. I just finished my first full Swift app this weekend, and by far, the most bothersome part was interacting with the C APIs (CoreMedia, ImageIO, etc.) I would have loved to see more examples of interacting with framework objects like CGImageSources, CMSampleBuffers, etc. For example, CGImageSourceCreateWithURL() returns an Unmanaged !. You can't pass that objec…

> I'm a little disappointed with the scope of this writeup. There's a teaser at the end that there will be a follow-up article about UnsafePointer. I just hope they hurry up and post it soon. I have half a large app that relies on UnsafePointers, and I could really use some clear documentation to reassure myself that I'm not abusing them.

Likewise, I'm running into UnsafePointers with IOKit.
Post reply on HN