On Thu, Jul 28, 2016 at 2:55 PM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I often call methods that return an optional collection. I then iterate over
> it. The problem is, it's a bit cumbersome to write:
>
> if let container = someOptio
I often call methods that return an optional collection. I then iterate over
it. The problem is, it's a bit cumbersome to write:
if let container = someOptionalContainer
{
for item in container
{
}
}
I wish I could just write
for item in
I watched the WWDC 2015 video about protocol-oriented programming and value
semantics. Both of them use the example of a diagramming app, where the user
can make a diagram of circles and polygons. They make a protocol for Drawable
(makes sense), and then make Circle and Polygon structs.
I'm
> On Aug 1, 2016, at 02:25 , Rimantas Liubertas wrote:
>
>
> I did. That's one of the two talks I mentioned.
>
> Well, so they did cover this, didn't they? You move item, you get the new
> struct with the new position. And if you save the old one, you have a cheap
> way
> On Aug 1, 2016, at 02:14 , Rimantas Liubertas wrote:
>
>
> Similarly, in the diagramming example from the WWDC videos, how would that
> app handle the user editing existing Drawables in the Diagram? Let's say you
> allow the user to click on a Drawable and drag it to
ave Sweeris
>
>> On Aug 2, 2016, at 6:22 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> I'm trying to define a protocol that has a read-only, immutable member
>> "uuid" that can be set in the init() method, but I'm havin
be too easy to break,
and could be disallowed, requiring conforming types to create storage for the
property and set it in init()).
>
> Jordan
>
>
>> On Aug 2, 2016, at 17:01, Rick Mann via swift-users <swift-users@swift.org>
>> wrote:
>>
>> It complain
I'm trying to define a protocol that has a read-only, immutable member "uuid"
that can be set in the init() method, but I'm having trouble. I have this:
protocol
Element
{
var uuid : { get }
}
extension
Element
{
init(...)
{
self.uuid = ...
}
}
I can't make it let,
It sure seems natural.
Is there some reason the language can't allow a sub-struct to add member
variables, such that the whole is treated like a contiguous set of members?
In my case, I have a rect-like value type, but I'd rather it inherit from
CGRect, rather than contain a CGRect. That makes
> On Aug 10, 2016, at 09:31 , Jens Alfke wrote:
>
> If you’re going for something bigger than that, why not just use a Raspberry
> Pi or C.H.I.P. or one of the other tiny ARM PC boards? They all run Linux,
> and I believe people are already working on porting Swift to run
I just saw a question which brought up something I didn't know about.
Apparently sometimes you have to call object.self in a place that looks like
you should just use "object." What does this usage mean?
for subclassObject in objects {
switch subclassObject.self {<--- Here, why not
self."
To me, for an instance, foo an foo.self should be equivalent in all respects
(shouldn't it?).
>
> Best,
> Austin
>
>
> On Fri, Jul 8, 2016 at 9:38 AM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I just saw a question which brough
> On Jul 10, 2016, at 11:44 , Saagar Jha via swift-users
> wrote:
>
> Well, what if you wanted to create a String with one character? There’s no
> way to differentiate.
That hardly seems like the justification. In that case, you'd specify the type:
let s: String =
> On Aug 3, 2016, at 03:23 , Dan Loewenherz <d...@lionheartsw.com> wrote:
>
> On Wed, Aug 3, 2016 at 3:51 AM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
>
> > On Aug 2, 2016, at 19:06 , Jordan Rose <jordan_r...@apple.com> wrote:
>
> On Aug 1, 2016, at 16:32 , Jens Alfke <j...@mooseyard.com> wrote:
>
>
>> On Aug 1, 2016, at 1:19 AM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> It seems like reference semantics are more appropriate here.
>
> Yes,
In my schematic capture app, I had a class hierarchy that started with Element.
From that I derived PartDefinition and PartInstance. Element has an immutable
UUID, name, and description. Element knows how to encode itself as XML by
conforming to an XMLCoding protocol.
Now I'm trying to make
header = parsedHeader
>> }
>> }
>
> Then, if you want to provide a nicer interface, do it with an extension:
>
>> protocol Element {
>> var uuid : UUID{ get }
>> var name : String? { get, set }
>> }
>>
>> extension PartIn
d to see that change.
I don't think I get to take advantage of value semantics, and it makes me
wonder if any typical, non-trivial model's object graph really has no reference
semantics.
>
> Jack
>> On Aug 1, 2016, at 4:32 PM, Jens Alfke via swift-users
>> <swift-users@swift.or
> On Aug 9, 2016, at 08:24 , Karl <razie...@gmail.com> wrote:
>
>
>> On 3 Aug 2016, at 02:01, Rick Mann via swift-users <swift-users@swift.org>
>> wrote:
>>
>> It complains if I make it a let because computed properties must be var.
>> Becau
Is it possible to use Swift for bare-metal programming on embedded devices?
These devices usually have memory-mapped registers that are read and written to
affect the operation of the device. Some can be quite small (e.g. 8-bit
registers, simple single physical memory address space), and others
> On Aug 2, 2016, at 13:07 , Dave Abrahams via swift-users
> wrote:
>
>
> on Mon Aug 01 2016, Rick Mann wrote:
>
>>> On Aug 1, 2016, at 19:18 , Jack Lawrence wrote:
>>>
>>> Jens: Why? There are significant benefits to value semantics for
>>> this
Why can my instance methods not call class methods without the class specifier?
class MyClass
{
func
foo()
{
classMethod()
}
class
func
classMethod()
{
}
}
Why do I have to call MyClass.classMethod()? Just a choice made by the language
designers to distinguish
I have some Swift code (in Xcode 7.3) that's calling a C function in the GDAL
library. It's declared like this:
typedef void *GDALDatasetH;
GDALDatasetH CPL_DLL CPL_STDCALL
GDALOpen( const char *pszFilename, GDALAccess eAccess ) CPL_WARN_UNUSED_RESULT;
I'm calling it with code like this:
class
sure seems like Swift could easily check for
Unsafe Pointers with value == 0.
>
> Dan
>
> On Fri, Jul 1, 2016 at 2:59 AM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I have some Swift code (in Xcode 7.3) that's calling a C function in the GDAL
&g
> Karen Stone wrote:
>> I believe there’s real value in being explicit about referencing class
>> members. It helps both the reader of the code and it makes writing code
>> with typical IDE conveniences like code completion less cluttered and more
>> informative. Unfamiliar class methods
Is there any concise way to write the following?
if let collection = someOptionalCollection
{
for item in collection
{
}
}
I can imagine more complicated things, too:
if let collection = someOptionalCollection as? [SomeType]
{
for item in collection
{
}
}
It would be
> On Feb 9, 2017, at 13:31 , Saagar Jha wrote:
>
> for item in someOptionalCollection ?? [] {
> item.doSomething()
> }
>
Thanks, this is probably the closest. Sadly I can't seem to test downcasting
because Playgrounds just stop working, with no feedback, for this
y? { }" — to parallel "for
> case let x? in array { }"
>
>
>> On Fri, Feb 10, 2017 at 1:03 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>> I love the idea of for in? (Or even for? In). You should pitch that to
>> evolution
I love the idea of for in? (Or even for? In). You should pitch that to
evolution.
Sent from my iPhone
> On Feb 10, 2017, at 07:04, Tino Heth <2...@gmx.de> wrote:
>
>
>> Is there any concise way to write the following?
>>
>> if let collection = someOptionalCollection
>> {
>>for item in
piler to yell at
>> you for doing overhead-inducing stuff in a loop, for example.
>>
>> Anyway, best of luck :-)
>>
>> - Dave Sweeris
>>
>>> On Aug 9, 2016, at 15:10, Rick Mann via swift-users <swift-users@swift.org>
>>> wrote:
>
I get this error in the following code: "Type of expression is ambiguous
without more context", on the DispatchQueue. But only if I mark it as "lazy",
and not if I don't. I'm not sure why.
class
myClass
{
lazy var myQ = DispatchQueue(label: "Op", attributes: .concurrent)// <--
ERROR
> On Sep 12, 2016, at 00:02 , Quinn The Eskimo! via swift-users
> wrote:
>
>
> On 12 Sep 2016, at 06:40, Jacob Bandes-Storch via swift-users
> wrote:
>
>> I'd recommend filing a bug at bugs.swift.org.
>
> Agreed.
Done.
> On Sep 12, 2016, at 00:53 , Quinn The Eskimo! via swift-users
> wrote:
>
>
> On 12 Sep 2016, at 08:46, Rick Mann wrote:
>
>> I had assumed lazy worked like static, which I understand uses dispatch_once
>> under the hood.
>
> Correct.
>
>
ct Bar {
> init(x: Int, y: Int? = 42) { }
> }
>
> class Foo {
> lazy var myQ = Bar(x: 3)
> }
>
>
> I'd recommend filing a bug at bugs.swift.org.
>
> On Sun, Sep 11, 2016 at 10:19 PM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I g
I'm trying to write this function. The errorHandler: parameter is modeled after
the NSFileManager enumerate() function. If I include the @escaping you see
there, I get the error "@escaping may only be applied to parameters of function
type".
The second parameter, iterator:, seems to have no
s list regarding do
>> this topic, not in a situation to search for it. It is a short coming in how
>> escaping can be applied to things like optional closures.
>>
>> I was in the process of authoring an email for swift evolution about it and
>> haven't yet gotten a
I have some code that implements an HTTP server. You use it like this:
server["/some/path"] =
{ inReq in
return .ok(.json(["key" : "value"]))
}
".ok" is a case in the HttpResponse enum.
The subscript on "server" above looks like this:
class HttpServer {
typealias Handler =
I've seen old (pre-Swift 3) posts online (e.g.
http://stackoverflow.com/questions/28920232/why-do-integers-not-conform-to-the-anyobject-protocol)
that address this, but my code worked yesterday before I used Xcode 8 GM to
migrate it to Swift 3, and now it doesn't, so I'm trying to understand
Sep 9, 2016, at 14:34 , Rick Mann via swift-users <swift-users@swift.org>
> wrote:
>
> I have some code that implements an HTTP server. You use it like this:
>
> server["/some/path"] =
> { inReq in
> return .ok(.json(["key" : "valu
I'm wrapping CLLocationManager (and its delegate), and I'm trying to create a
protocol like this. This is directly cribbed from CLLocationManagerDelegate.
---
public
protocol
LZLocationManagerDelegate : NSObjectProtocol
{
optional public func locationManager(manager:
> On Oct 26, 2016, at 22:23 , Dave Abrahams via swift-users
> wrote:
>
>
> on Wed Oct 26 2016, Rick Mann wrote:
>
>> It seems fairly natural to want to do this:
>>
>> let bigDictionary = ...
>> let smallerDictionary = bigDictionary.filter { key, value in > returning
C"]
>let sd = bd.filter{(k, v) in
>k > 1}
>dump(sd)
In this example, sd is an array of tuples of (key, value), not a dictionary.
>
>On 27/10/2016, 01:12, "Rick Mann via swift-users"
> <swift-users-boun...@swift.org on behalf of swift-
It seems fairly natural to want to do this:
let bigDictionary = ...
let smallerDictionary = bigDictionary.filter { key, value in }
Similarly, it seems natural to want to map this way.
Am I overlooking something?
--
Rick Mann
rm...@latencyzero.com
When working with URLComponents query items, it would be nice to write code
like this:
var oqi: [URLQueryItem]? = [..., ..., ...]
var comps = URLComponents(…)
comps.queryItems += oqi
The problem is that queryItems is [URLQueryItem]?, and so I can't just append.
I'd like to write a version of
> On Nov 21, 2016, at 09:46 , Kenny Leung via swift-users
> wrote:
>
> This is so confusing. "Literals are untyped", but there’s a “BooleanLiteral”,
> which is obviously of type Boolean.
Agreed.
--
Rick Mann
rm...@latencyzero.com
>>>>>>
>>>>>>> Instead, a family of overloaded global functions gives you the most
>>>>>>> coverage and best performance, at the expense of repetition and
>>>>>>> boilerplate code:
>>>>>>>
>&
> On Nov 21, 2016, at 15:09 , Marco S Hyman wrote:
>
>> Except it does, because if I write
>>
>> let a = 2
>
>> a is of type Int (at least, according to Xcode's code completion).
>
> and if you write
>
> let b = 2 + 0.5
>
> 2 is treated as a double. The type of
My earlier post about converting Decimal to Double was part of a larger effort
by me to write a calculator app that supports dimensional analysis/unit
conversions. I've explored some existing libraries on the topic, ranging from
this one in Common Lisp
> On Nov 22, 2016, at 03:04 , Tino Heth <2...@gmx.de> wrote:
>
> Hi Rick,
>
> as evolution is somewhat paused, swift-users seems to gain more traction ;-)
>
> Imho the most natural would be
> extension Array {
> …
> }
>
> I hope to see this addition included when the topic is discussed again.
nsive. Perhaps the compiler magically optimizes this down to an atomic
instruction, but I doubt it.
BTW, is there any easy way to see the generated assembly? Seems to be a missing
feature in Xcode.
>
>> On Nov 21, 2016, at 7:55 PM, Rick Mann via swift-users
>> <swift-users@sw
as already discussed and dismissed.
>
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 22. November 2016 um 01:32:42, Rick Mann via swift-users
> (swift-users@swift.org) schrieb:
>
>> My googling is not turning up an answer that works in Xcode 8.
; var result: S.Iterator.Element = 0
>>>>> for element in sequence { result += element }
>>>>> return result
>>>>> }
>>>>>
>>>>> func sum(_ array: Array) -> Double {
>>>>> var result = Double()
>>>
A lot of architectures provide CPU support for atomic increment and the like.
does, too, but most of it is unavailable in Xcode 8.1.
Is there a Swift AtomicInteger? Is that worth adding to the language?
--
Rick Mann
rm...@latencyzero.com
___
ective-C anyway,
>>> because, if you don’t know what’s in the string, you need to validate it
>>> (imagine if the user of your app finds out that they can cause you to
>>> instantiate any arbitrary class) and if you do know what’s in the string,
>>> why are
> On Nov 12, 2016, at 22:47 , David Sweeris <daveswee...@mac.com> wrote:
>
>
>> On Nov 13, 2016, at 00:38, Rick Mann via swift-users <swift-users@swift.org>
>> wrote:
>>
>> So, it seems there's still no way to do something like instantiate
ment type 'inout CGPoint'
> points[0].anchorPt += dv
> ~~^~~~
>
> but that's still not great. So, yes, please do file a bug at bugs.swift.org.
>
> Thank you!
> Jordan
>
>> On Nov 11, 2016, at 13:29, Rick Mann via swift-users <swift-users@swift.
I'm trying to do this:
protocol Signumable
{
func sgn() -> Self
}
extension Signumable
{
func
sgn()
-> Self
{
let pos = 0 < self // Error
let neg = self < 0 // Error
let p
hould not consider it like something super class does. If you want it that
> way, use class inheritance instead.
>
> Zhaoxin
>
> Get Outlook for iOS
>
> _____________
> From: Rick Mann via swift-users <swift-users@swift.org>
> Sent: 星期三, 十一月 16, 2016 07
rint("fooFunc FooClass")
> }
> }
>
> let fc = FooClass()
> fc.fooFunc()
>
> Dan
>
> On Tue, Nov 15, 2016 at 4:28 PM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> The following gives Xcode 8.1 a very hard time. Eventually I get a B
it is better to extend the existing `SignedNumber`
> protocol instead of introducing your own `Signumable`, unless if you need to
> write other generic algorithms that need your protocol as their constraints.
>
>> On Nov 19, 2016, at 6:44 PM, Rick Mann via swift-users
>> <swift-
It seems I can't do this:
let r = Int(a > b)
but I can do it with a literal:
let r = Int(true)
I'd like to do this to implement signum without branching, but perhaps that's
not possible.
--
Rick Mann
rm...@latencyzero.com
___
swift-users mailing
r now I'm doing what I need with branching, but it would be nice to find a
more efficient way.
>
>
> Jon
>
>> On Nov 20, 2016, at 10:48 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> It seems I can't do this:
>&
I think the error I'm getting here is misleading. Should I file a bug?
import CoreGraphics
func
+=(inLHS : inout CGPoint, inRHS : CGPoint)
{
inLHS.x += inRHS.x
inLHS.y += inRHS.y
}
struct
PathPoint
{
varanchorPt:CGPoint?
}
var points = [PathPoint()]
let dv = CGPoint(x: 0,
2016, at 22:47 , David Sweeris <daveswee...@mac.com> wrote:
>>>
>>>
>>>> On Nov 13, 2016, at 00:38, Rick Mann via swift-users
>>>> <swift-users@swift.org> wrote:
>>>>
>>>> So, it seems there's still no way to do something
> On Oct 27, 2016, at 10:29 , Dave Abrahams wrote:
>
>
> on Thu Oct 27 2016, Rick Mann wrote:
>
>>> On Oct 26, 2016, at 22:23 , Dave Abrahams via swift-users
>>> wrote:
>>>
>>>
>>> on Wed Oct 26 2016, Rick Mann wrote:
>>>
>>
It seems
It seems I can write this:
extension String
{
public func deleting(prefix inPrefix: String) -> String
public func deleting(prefix inPrefix: String) -> String?
}
But I was hoping it would do the right thing:
let a = s.deleting(prefix: "foo")
if let b = s.deleting(prefix: "foo") { }
But it
> On Oct 13, 2016, at 14:51 , Greg Parker <gpar...@apple.com> wrote:
>
>>
>> On Oct 13, 2016, at 2:36 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> It seems I can write this:
>>
>> extension String
>
gt;
> -- Howard.
>
> On 30 November 2016 at 09:28, Greg Parker via swift-users
> <swift-users@swift.org> wrote:
>
> > On Nov 29, 2016, at 2:55 AM, Rick Mann via swift-users
> > <swift-users@swift.org> wrote:
> >
> > Working on dimensional anal
Working on dimensional analysis, I have some proof-of-concept code that seems
to be working:
let n1 = kilogram * meter / second * second
([(kg⋅m) / s]⋅s)
let n2 = kilogram * meter / (second * second)
[(kg⋅m) / (s⋅s)]
Note: () around unit products, [] around unit quotients.
Awesome!
> On Dec 15, 2016, at 22:11 , Terence Parr via swift-users
> wrote:
>
> Dear Swift-users! Just a quick note that I finally got the Swift code
> generation target for the ANTLR 4 parser generator integrated and released!
> You can see the release notes here:
>
I've got Swift and libdispatch installed and linking under Ubuntu 16.04, but
I'm not sure how to set up the Linux equivalent of the macOS run loop in order
to service all the dispatch queues.
I'm having a hard time finding an example of how to do this. Some GCD C code
calls dispatch_main()
I'm refactoring some Objective-C code to inherit from a new Swift super class.
This has been going okay, and I've been cleaning up build errors as I spot them
(some auxiliary enums caused enum name changes, etc.).
But my last error seems to be that I can't subclass the Swift class: "Cannot
> On Apr 14, 2017, at 22:33 , Guillaume Lessard <gless...@tffenterprises.com>
> wrote:
>
> Your class probably needs to be declared as open.
>
> @objc open class Camera : NSObject {}
Thanks. Sadly, that does not fix it.
> Guillaume Lessard
>
>> On A
> On Apr 22, 2017, at 12:23 , Saagar Jha <saa...@saagarjha.com> wrote:
>
>
> Saagar Jha
>
>> On Apr 21, 2017, at 04:35, Rick Mann via swift-users <swift-users@swift.org>
>> wrote:
>>
>> I have a debugLog() method that looks like this:
&g
> On Apr 17, 2017, at 08:54 , Joe Groff <jgr...@apple.com> wrote:
>
>
>> On Apr 14, 2017, at 7:41 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> I'm refactoring some Objective-C code to inherit from a new Swift super
>
My Objective-C file is importing "Module-Swift.h", and that file has some of my
other Swift classes, but not the one I just wrote. I've tried making the class
public, but I didn't need to do that on any of the others.
I've tried cleaning the build folder of my Xcode project, but I get the same
I'm trying to make a module out of a C library and header file. It has at least
one empty struct:
struct lgs_context_t {};
and a function:
LGS_EXPORT struct lgs_context_t* lgs_init(const lgs_context_params_t* params);
Swift sees the function, I can call it and assign the result to a variable,
mentation reason for this;
> it's not just the compiler being capricious.)
> - In frameworks, only public and open classes are included in the generated
> header, since it's part of your framework's public interface.
>
> Are you in any of these situations?
>
> Jordan
>
>
> On Apr 18, 2017, at 09:11 , Joe Groff <jgr...@apple.com> wrote:
>
>
>> On Apr 17, 2017, at 6:19 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> I'm trying to make a module out of a C library and header file. It has
I'm trying to pass a Data of allocated size to a C function for it to fill in:
lib_example_call(_ params: UnsafePointer!, _ data:
UnsafeMutableRawPointer!)
...
{
self.dataBuffer = Data(capacity: BufferSizeConstant)
var params = lib_call_params_t();
params.data_capacity =
We have withUnsafePointer(to:) and withUnsafeMutablePointer(to:). Why does the
first take an inout parameter? The function names imply that the first will not
modify the pointer (which I take to mean its contents), and it makes it quite
clunky to pass in constant things.
--
Rick Mann
I'm using a third-party C library whose header doesn't properly tag things like
enums, and so they show up in Swift without their cases. Is there any way to
write an auxiliary file to help the compiler do the conversion (e.g. something
in the modulemap file), so that I don't have to modify the
be
>> able to derive its pointer. The languages requires inout arguments to be
>> vars, leading to withUnsafePointer() requiring the passed object to be a var.
>>
>> There may be other subtleties I'm not aware of, though.
>>
>>> Le 27 avr. 2017 à 02:42, Rick Man
I could swear this was compiling a couple days ago, as I was making the call
inside the block and dealing with issues around that.
Can anyone explain what's going on here?
class
MyClass
{
func
execute()
{
self.dataBuffer = Data(capacity: lgsImageDataSize)
Oh wow, it's the debugLog() call! If that's inside the block, it fails to
compile.
> On Apr 24, 2017, at 14:18 , Rick Mann via swift-users <swift-users@swift.org>
> wrote:
>
> I could swear this was compiling a couple days ago, as I was making the call
> inside
> On Apr 27, 2017, at 01:48 , Alex Blewitt wrote:
>
...
> The let constant may not even be stored in a single place; if it's known to
> be constant it can be in-lined at the point of use and potentially unpacked
> and dead code elimination throw away the unused members, for
> On Apr 27, 2017, at 18:56 , Hooman Mehr wrote:
>
> You should be able to type your `dataBuffer ` as [Int8] (Byte array). Then
> you won’t need `withUnsafeMutableBytes`. You can simply call it like this:
>
> self.request = c_library_call(, dataBuffer) // Call as if it is a C
C
> array
>
> It works because of C interoperability compiler magic.
>
> As long as the instance holding `dataBuffer` is not deallocated and you have
> not resized the array, the pointer should remain valid.
>
>> On Apr 27, 2017, at 4:38 PM, Rick Mann via swift-users
&
Yeah, okay. So: how do I do this in a way that is safe?
--
Rick Mann
rm...@latencyzero.com
> On Apr 27, 2017, at 23:00, Rien wrote:
>
> To address your question:
>
> https://developer.apple.com/reference/foundation/data/1779823-withunsafemutablebytes
>
> "Warning
>
The following playground reproduces an issue I'm having, in that the code won't
compile depending on the content of the closure. In fact, an empty closure is
fine, but when I try to call certain things, it's not.
I figure it has something to do with the type inference for inPointer, but I
ointer
> ) -> Void in
> // ...
> }
>
>
> On 25.04.2017 10:45, Rick Mann via swift-users wrote:
>> The following playground reproduces an issue I'm having, in that the code
>> won't compile depending on the content of the closure. In fact, an empty
>>
> On May 10, 2017, at 01:23 , Brent Royal-Gordon <br...@architechies.com> wrote:
>
>> On May 8, 2017, at 2:01 AM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> Seriously, I've been googling this for a half-hour, and I can't fi
> On May 10, 2017, at 11:52 , Joe Groff <jgr...@apple.com> wrote:
>
>
>> On May 8, 2017, at 4:47 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> I have this C library that interacts with some hardware over the network
>>
I continue to struggle with the "proper" and most efficient way to do things
with Data.
In this case, I have a set of bytes received over a serial port in a Data. The
last two bytes are a (big- or little-endian) UInt16 CRC. However, there maybe
an odd or even number of bytes in the Data before
I'm trying to use apinotes for this third-party C library (call it
"Lib.dylib"). It has an enum lgs_error_t:
typedef enum {
lgs_error_none = 0,
lgs_error_invalid_handle = -1,
lgs_error_null = -2,
lgs_error_invalid_parameter = -3,
lgs_error_invalid_operation = -4,
Seriously, I've been googling this for a half-hour, and I can't find an answer
(everything that comes up is for ErrorType, absolutely nothing for Error).
I have an enum:
enum MyErrors : Error
{
case one(String)
case two
case three(String)
}
let a: MyErrors = .one("foo")
let b =
gt; let slice = bytes[0..<4]
> slice.withUnsafeBytes { buffer in
> let d = Data(bytesNoCopy: UnsafeMutableRawPointer(mutating:
> buffer.baseAddress!), count: buffer.count, deallocator: .none)
> // whatever you do, dont let d escape
> }
>
>
>
>> On May 4, 2017, at 16:31,
Is it possible to make a (immutable) Data() object from a slice of a [UInt8]
and avoid copying the data?
--
Rick Mann
rm...@latencyzero.com
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
t;
>>> On Apr 22, 2017, at 12:23 , Saagar Jha <saa...@saagarjha.com> wrote:
>>>
>>>
>>> Saagar Jha
>>>
>>>> On Apr 21, 2017, at 04:35, Rick Mann via swift-users
>>>> <swift-users@swift.org> wrote:
>>>>
&
I have this C library that interacts with some hardware over the network that
produces a ton of data. It tells me up front the maximum size the data might be
so I can allocate a buffer for it, then does a bunch of network requests
downloading that data into the buffer, then tells me when it's
1 - 100 of 120 matches
Mail list logo