|
qsort_b in Swift
The compiler probably inlines the call to the comparison function, as opposed to qsort_b which has (of course) already been compiled so it has to make a regular function call. That makes a big differe
The compiler probably inlines the call to the comparison function, as opposed to qsort_b which has (of course) already been compiled so it has to make a regular function call. That makes a big differe
|
By
Jens Alfke
· #309
·
|
|
NSAllowsArbitraryLoads
You can't edit your Info.plist, or change settings like these; the app bundle is immutable. At WWDC this year Apple said that they're getting stricter about App Transport Security exemptions like this
You can't edit your Info.plist, or change settings like these; the app bundle is immutable. At WWDC this year Apple said that they're getting stricter about App Transport Security exemptions like this
|
By
Jens Alfke
· #301
·
|
|
Difference between NSPoint, NSSize, NSRect and the CG Versions
I don't see how they could be incompatible if they're the same size. The only 4-byte floating point type is 'float', so if the CG and NS types are using the same-size values, how can they be different
I don't see how they could be incompatible if they're the same size. The only 4-byte floating point type is 'float', so if the CG and NS types are using the same-size values, how can they be different
|
By
Jens Alfke
· #290
·
|
|
Difference between NSPoint, NSSize, NSRect and the CG Versions
Historical reasons. AppKit predates Core Graphics (it predates Apple's acquisition of NeXT.) —Jens
Historical reasons. AppKit predates Core Graphics (it predates Apple's acquisition of NeXT.) —Jens
|
By
Jens Alfke
· #288
·
|
|
How to store C Arrays as a Property or iVar?
I answered that yesterday. —Jens
I answered that yesterday. —Jens
|
By
Jens Alfke
· #228
·
|
|
How to store C Arrays as a Property or iVar?
NSData.bytes is a property of type "void*". And NSPointerFunctions even has a property whose type is a C function pointer: @property (nullable) BOOL (*isEqualFunction)(const void *item1, const void*it
NSData.bytes is a property of type "void*". And NSPointerFunctions even has a property whose type is a C function pointer: @property (nullable) BOOL (*isEqualFunction)(const void *item1, const void*it
|
By
Jens Alfke
· #227
·
|
|
Compiling Conditionally depending on OS
TARGET_OS_MAC is incorrect — for some reason that evaluates to true on all Apple platforms. You want TARGET_OS_OSX instead. Here's the full list as documented in <TargetConditionals.h>, which is the h
TARGET_OS_MAC is incorrect — for some reason that evaluates to true on all Apple platforms. You want TARGET_OS_OSX instead. Here's the full list as documented in <TargetConditionals.h>, which is the h
|
By
Jens Alfke
· #226
·
|
|
How to store C Arrays as a Property or iVar?
No one said this was a property. It's just an instance variable. Also, it's fine for properties to be C types — after all, there are plenty of integer or boolean properties, and UIKit and AppKit have
No one said this was a property. It's just an instance variable. Also, it's fine for properties to be C types — after all, there are plenty of integer or boolean properties, and UIKit and AppKit have
|
By
Jens Alfke
· #218
·
|
|
How to store C Arrays as a Property or iVar?
The time to read and unwrap an integer from an NSArray is probably under a microsecond, so it's unlikely to be a performance problem. But there's nothing wrong with using a C array. It's what I'd do,
The time to read and unwrap an integer from an NSArray is probably under a microsecond, so it's unlikely to be a performance problem. But there's nothing wrong with using a C array. It's what I'd do,
|
By
Jens Alfke
· #208
·
|
|
How to store C Arrays as a Property or iVar?
(IIRC you suggested using an NSMutableArray of NSNumbers?) Honestly, it depends. It does have overhead, although not as much as it used to, since NSNumbers of reasonable-size integers don't allocate a
(IIRC you suggested using an NSMutableArray of NSNumbers?) Honestly, it depends. It does have overhead, although not as much as it used to, since NSNumbers of reasonable-size integers don't allocate a
|
By
Jens Alfke
· #203
·
|
|
Understanding NSNetService and peer-to-peer streaming
This is a classic newbie networking mistake. (No offense I hope!) TCP is a stream, and there is absolutely no delimiter between writes, and no association between the number of bytes written vs. the n
This is a classic newbie networking mistake. (No offense I hope!) TCP is a stream, and there is absolutely no delimiter between writes, and no association between the number of bytes written vs. the n
|
By
Jens Alfke
· #199
·
|
|
How to store C Arrays as a Property or iVar?
You can't assign (or compare) arrays in C/C++. You have two options: (a) Call memcpy: memcpy(&myArray, &_mArray, sizeof(myArray)); (b) Wrap a struct around the array, since structs are copyable. Drawb
You can't assign (or compare) arrays in C/C++. You have two options: (a) Call memcpy: memcpy(&myArray, &_mArray, sizeof(myArray)); (b) Wrap a struct around the array, since structs are copyable. Drawb
|
By
Jens Alfke
· #190
·
|
|
Understanding NSNetService and peer-to-peer streaming
Right. You need to keep track of that yourself, like with a Peer class that can hold onto those streams and act as their delegate. NSNetService doesn't really have anything to do with those streams. A
Right. You need to keep track of that yourself, like with a Peer class that can hold onto those streams and act as their delegate. NSNetService doesn't really have anything to do with those streams. A
|
By
Jens Alfke
· #185
·
|
|
APFS & FileSystem attributes
It wouldn’t be a valid filesystem if it didn’t support the system calls like stat() that NSFileManager uses to get file attributes. Now, not every filesystem supports every attribute (you’re not going
It wouldn’t be a valid filesystem if it didn’t support the system calls like stat() that NSFileManager uses to get file attributes. Now, not every filesystem supports every attribute (you’re not going
|
By
Jens Alfke
· #181
·
|
|
APFS & FileSystem attributes
If it did, it would break most apps, so no. —Jens
If it did, it would break most apps, so no. —Jens
|
By
Jens Alfke
· #179
·
|
|
"broken pipe", but not when debugging...
It does seem absurd that the most fundamental APIs — the C standard library and POSIX/Darwin system calls — aren’t supported by Xcode’s documentation features. Especially since the header files give z
It does seem absurd that the most fundamental APIs — the C standard library and POSIX/Darwin system calls — aren’t supported by Xcode’s documentation features. Especially since the header files give z
|
By
Jens Alfke
· #176
·
|
|
"broken pipe", but not when debugging...
For some reason lost in ancient Unix history, if you write to a file-descriptor that’s been closed at the other end, a SIGPIPE signal is raised. This will by default kill your process. It’s annoying b
For some reason lost in ancient Unix history, if you write to a file-descriptor that’s been closed at the other end, a SIGPIPE signal is raised. This will by default kill your process. It’s annoying b
|
By
Jens Alfke
· #164
·
|
|
Installing a Launchd.plist
LaunchDaemons is the wrong directory; that’s for system daemons that run outside of any user context. (I’m surprised you actually got this to work, because it’s difficult to present any UI from a daem
LaunchDaemons is the wrong directory; that’s for system daemons that run outside of any user context. (I’m surprised you actually got this to work, because it’s difficult to present any UI from a daem
|
By
Jens Alfke
· #118
·
|
|
dispatch_async question
The call you showed runs the block on the main thread. That aspect may be crucial. Does the code this is part of run on a different thread/queue? Also, it can often be very useful to defer some code u
The call you showed runs the block on the main thread. That aspect may be crucial. Does the code this is part of run on a different thread/queue? Also, it can often be very useful to defer some code u
|
By
Jens Alfke
· #111
·
|
|
Trying to make Arc happy
I think you resolve this by changing it to the form shown in the error messages, i.e. - (BOOL)isNiceAndHas: (NSArray *__autoreleasing *)friends; —Jens
I think you resolve this by changing it to the form shown in the error messages, i.e. - (BOOL)isNiceAndHas: (NSArray *__autoreleasing *)friends; —Jens
|
By
Jens Alfke
· #98
·
|