Re: Accessing a property of a view via its controller doesn't work

2021-09-04 Thread Greg Weston via Cocoa-dev
> I access the window of a view by two different ways, in the controller and in > the view, resp., and in the controller, I always get a nil pointer. Have you verified that the view you’re accessing in the controller is the same instance as the one that works? ___

Re: What is the preferred way to set NSTextView content from NSAttributedString?

2020-02-02 Thread Greg Weston via Cocoa-dev
> - I want to set the displayed contents of V to T2. > > What is/are the recommended way/s to do this? > > *I would hope that I could assign V.attributedString = T2, but alas the > world does not seem to be this simple.* The documentation suggests you should be working with the view’s textStorag

Re: Need for Swift

2019-10-15 Thread Greg Weston via Cocoa-dev
> This discussion about Swift vs Objective-C is interesting, but I think it > omits something important. Both those languages only build apps for Apple > products. This was probably “omitted” because it’s not actually true. ___ Cocoa-dev mailing list (

NSImage to JPEG file?

2019-01-16 Thread Greg Weston
>> That would be poor API design. If it had -writeToFile, then it would also >> need -writeToStream:, -writeToFileHandle:, -writeToFileDescriptor:, >> -writeToNSURLSessionDataDelegate:, etc. >> Providing the data itself means you can then use existing APIs on other >> classes to put the data an

Re: NSData from dispatch_data_t?

2018-10-30 Thread Greg Parker
he dispatch_data_t object header. That is not going to match the dispatch_data_t's actual contents. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.co

Re: NSData from dispatch_data_t?

2018-10-30 Thread Greg Parker
d to copy the data. (Of course, if the code using it as an NSData goes on to call -bytes instead of -enumerateByteRangesUsingBlock: then it would be forced to copy into a contiguous representation anyway.) -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler _

Re: Dealing with an @available warning

2018-10-23 Thread Greg Parker
" pInfo.orientation = (NSPaperOrientation)NSPortraitOrientation; #pragma clang diagnostic pop You should file a bug report against AppKit. I'm not sure there is any benefit to marking a plain C enum as unavailable. Use of a new enum would work fine when running on an old

Re: C++ pointer to Cocoa object

2018-09-07 Thread Greg Parker
contains this mCocoaPopupPtr field were itself deallocated then a use-after-free could cause this symptom. >> Is there some other way to test for an invalid void pointer? There is no way to programmatically distinguish all valid Objective-C object pointers from all invalid ones. It&#x

Re: NSDrawer

2018-07-14 Thread Greg Weston
Casey McDermott wrote: > NSPanel is still modal, but longer lasting. We use it a lot, and it > looks better than the modal dialogs in the current app. I read in digest mode so maybe this has already been pointed out, but NSPanel is not modal. ___ Coc

Re: NSComboBox -comboBox:completedString: not called

2018-03-13 Thread Greg Weston
> So, to answer my own question, I can "get this to work" using a custom > NSComboBoxCell > subclass, implementing -completedString. > > Having seen this in action I must confess this is a Bad Idea™. You’re describing long-standing documented behavior and the correct approach to achieve the a

Re: NSString equivalent of CFSTR macro?

2017-12-04 Thread Greg Parker
, so it may allocate a new autoreleased string object every time it runs that line. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator com

Re: NSString equivalent of CFSTR macro?

2017-12-04 Thread Greg Parker
> On Dec 4, 2017, at 2:56 PM, Rick Mann wrote: > >> On Dec 4, 2017, at 14:55 , Greg Parker wrote: >> >>> On Dec 4, 2017, at 2:51 PM, Ben Kennedy wrote: >>> >>>> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: >>>> >>>

Re: NSString equivalent of CFSTR macro?

2017-12-04 Thread Greg Parker
You can also skip the middleman and use `@kSomeCStringConstant`. After the preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly happy with. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing

Re: Is "-init" really needed?

2017-08-07 Thread Greg Parker
dent of its correctness, the code above *looks* wrong. That alone is bad. It ought either to call -init or to have a big scary comment describing why it is safe not to. * If Foo is ever changed to have a superclass other than NSObject, the code above is likely to be wrong. -- Greg Parker

Re: Who owns a child view controller?

2017-07-14 Thread Greg Parker
e-language-specific. (The only exception would be if the Swift compiler > knew that a function was private and final, so it controlled both ends of the > call.) The Swift compiler can avoid autorelease more often than that. Swift can use a simple callee-retain caller-release conve

Re: Who owns a child view controller?

2017-07-14 Thread Greg Parker
you if an object is pointed to by some autorelease pool. You can call _objc_autoreleasePoolPrint() in the debugger to dump the contents of the current thread's autorelease pool stack. You can set environment variable OBJC_PRINT_POOL_HIGHWATER=YES to record stack traces when a large autoreleas

Re: Who owns a child view controller?

2017-07-12 Thread Greg Parker
arising from this reference becoming > invalid. The most common problem I know of is from table and outline view > delegate and data source references. In many cases, it’s wise to nil these > out manually when (say) your window closes. We prefer to use "unretained" or &q

Re: Who owns a child view controller?

2017-07-12 Thread Greg Parker
unting” that might be equivalent. Deferred reference counting is not much like autorelease. The goal of deferred RC is to accumulate many retain and release operations from a single thread and apply them all at once, in the hopes of reducing the cost of repeated refcount operations on a singl

Re: Context leak detected, msgtracer returned -1 ?

2017-05-22 Thread Greg Parker
ug report that this log is too vague. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list.

Re: NSCollectionView selection behavior is insanely bad

2017-04-26 Thread Greg Weston
> Instead of doing the right thing when shift-clicking (selecting a range from > the anchor), it simply adds/removes the clicked item to/from the selection. > That's unlike pretty much any Apple matrix-of-items selection behavior ever. You mean it selects like Finder icon views have since 1984?

Re: Binary floating point format

2017-03-30 Thread Greg Parker
> On Mar 30, 2017, at 9:03 PM, Carl Hoefs > wrote: > >> On Mar 30, 2017, at 8:10 PM, Greg Parker > <mailto:gpar...@apple.com>> wrote: >> >>> On Mar 30, 2017, at 7:09 PM, Carl Hoefs >> <mailto:newsli...@autonomy.caltech.edu>> wrote: &g

Re: Binary floating point format

2017-03-30 Thread Greg Parker
f 2 here that it's hard to trust any guess. Using CFSwapInt64() from CoreFoundation/CFByteOrder.h and from_vax_d8() from https://pubs.usgs.gov/of/2005/1424/ <https://pubs.usgs.gov/of/2005/1424/>, your bytes above are: -41.7215935353 -49.7215935353 -49.7215935353 -49.7215935366 -4

Re: Binary floating point format

2017-03-30 Thread Greg Parker
apping is a good hint that you're looking at a PDP-11 / VAX format. There are two different 64-bit VAX formats, though, and neither is identical to IEEE even after correcting for the byte order. Simply shuffling VAX bytes and interpreting as an IEEE double would be misleadingly clos

Re: Binary floating point format

2017-03-30 Thread Greg Parker
s your floating-point format unless you have a collection of known values in both IEEE format and your format. Many of the historical formats are similar enough that misinterpretation could give incorrect values that look reasonable by eye. -- Greg Parker gpar...@apple.com <mailto:gpa

Re: Can't use +initialize, now what?

2017-03-29 Thread Greg Parker
tack frames into your backtrace which can help identify when +initialize deadlock occurs: `_WAITING_FOR_ANOTHER_THREAD_TO_FINISH_CALLING_+initialize` and `_CALLING_SOME_+initialize_METHOD`. Environment variable OBJC_PRINT_INITIALIZE_METHODS=YES logs some details of +initialize processing that

Re: Can't use +initialize, now what?

2017-03-29 Thread Greg Parker
itialize checking is free once you pay the cost of objc_msgSend(). (The ObjC runtime checks +initialize on uncached dispatch, and never caches anything until +initialize completes. Most dispatches are cached so they pay nothing for +initialize support.) +initialize in Swi

New iTunes visual plugin SDK?

2017-03-27 Thread Greg Weston
So, apparently iTunes 12.6 doesn't support older plugins any more. Has anyone seen or heard news of a new SDK so those of us who have created plugins can update them? Greg ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not

Re: NSMutableData +dataWithLength: sets errno?

2017-03-14 Thread Greg Parker
> call you make might randomly overwrite errno with gibberish. The POSIX standard specifically states that errno's value is undefined almost everywhere and can be arbitrarily changed by almost anything. http://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html <http://pubs.o

Re: -forceCancel an NSOperation

2017-03-01 Thread Greg Parker
be reliably enforced even if the student code is stuck in a hang or a loop. I can't argue with the classification of student code as "hostile" and "malicious". -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler _

Re: macOS 10.13 suggestion for init() throws

2017-02-28 Thread Greg Parker
e NSDocument would break all of its existing subclasses. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moder

Re: What generates NSURLErrorUnsupportedURL?

2017-02-08 Thread Greg Parker
RL is also recorded in the NSError's userInfo dictionary as NSURLErrorFailingURLStringErrorKey. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or mod

Re: Overriding the release mehod

2017-01-25 Thread Greg Parker
an override ought to call [super release] if the object is expected to be retained and released and deallocated normally. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler > On Jan 25, 2017, at 8:23 AM, Dave wrote: > > I hate it when

Re: Overriding the release mehod

2017-01-25 Thread Greg Weston
Dave wrote: > I hate it when people ask [why are you doing X]! Decades of experience seeing such questions make us think that when someone is asking how to do something extraordinary there's about 99% chance they don't actually need to do it and are making things harder for themselves. Sometime

Re: Using floating point instructions

2016-12-06 Thread Greg Parker
t operand 0 must use '&' constraint > > Is there a way to fix this problem? You'll get better answers from a clang list such as cfe-us...@lists.llvm.org. Most of the audience here probably does not have a copy of clang that can compile PowerPC code. Why are you using

Re: iOS: Preventing a singleton from being deallocated when the app is in the background.

2016-10-20 Thread Greg Parker
. Log or crash in dealloc, if your singleton enforcement might allow the object to be deallocated and then a new one to be created. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (

Re: iOS: Preventing a singleton from being deallocated when the app is in the background.

2016-10-19 Thread Greg Parker
ation." No difference. C static storage with no initializer is always initialized to zero. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Pl

Re: How to count Atoms

2016-10-10 Thread Greg Parker
g. The deprecation warning told you to use memory_order_relaxed because that is the memory ordering used by OSAtomicIncrement64. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Coco

Re: Success with NSTableView weak delegates?

2016-09-20 Thread Greg Parker
un on 10.11.6 and yet I see these > message-to-zombie crashes after removing the setDelegate:nil code. Those crashes are expected. NSTableView's delegate is zeroing-weak when both of the following are true: * Your app was built with the 10.11 SDK or newer. * Your app is running

Re: Why doesn't this crash?

2016-09-12 Thread Greg Parker
yMessage]. You must use the result of objc_getClass() instead. Some "unavailable" classes were in fact present as SPI on older OS versions. That will confuse tests like `if ([SomeClass class]) { … }`. Test your code on your old deployment targets. -- Greg Parker gpar...@apple.com

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Greg Parker
is generating incorrect code or incorrect debug > information or corrupting its own indexes. I’ve seen it in my own projects, > and problems have been reported in the developer forums that sound similar. > Typically, it appears, cleaning the build folder fixes the problem. Did

Re: Linking against AVKit breaks app on 10.6

2016-09-12 Thread Greg Parker
ted, while the other frameworks do. You can force weak linking > for that particular framework using > > -weak_framework AVKit > > instead of just using the normal “-framework”. Please file a bug report. A missing availability at

Re: Init in Swift

2016-09-06 Thread Greg Parker
protocol extensions can solve some of those problems. The protocol extension provides a default implementation to every class that conforms to the protocol. Each class may provide its own implementation that overrides the protocol extension's default implementation. --

Re: Limiting app installation

2016-09-05 Thread Greg Weston
> Does Apple allow a developer to limit the number of devices on which an app > can run? I have an app that requires you to pay more to install it on more > than one iPhone and two iPads. It should go without saying these are all on > the same Apple ID. > > I thought Apple didn't allow this. Bu

Re: Mysterious crash with NSTableView

2016-08-27 Thread Greg Parker
environment variables then you may be able to use the scan-build tool to run the clang static analyzer. http://clang-analyzer.llvm.org/scan-build.html -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (C

Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)

2016-08-11 Thread Greg Weston
>> 2. The fact than an object is immutable does not (in general) mean that a >> copy can be represented by the same object reference. For example, an object >> that contained its own date of creation might be immutable, but a copy might >> have a different date, and therefore be a different obje

Re: Codesign assumes folder structure, fails.

2016-07-26 Thread Greg Parker
ion? My understanding is that this is a limitation of the Xcode build system. codesign doesn't care about the framework's structure, but Xcode does and it is telling codesign to look at the wrong path. You should mention rdar://17814234 when you file your bug report. -- Greg Parke

Re: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Greg Parker
too easy to accidentally bind to an unrelated superclass ivar when you really wanted to create a new ivar. -- Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.app

Re: debugging AirDrop (update)

2016-06-01 Thread Greg Parker
. > > Can anybody explain why 3 reboots ≠ 1 reboot? One possibility: some systems will reset caches or other state if the previous uptime was too short. This gets you out of reboot loops when a cache gets corrupted, for example. -- Greg Parker gpar...@apple.com <mailto:gpa

Re: discontiguous bounds ?

2016-05-09 Thread Greg Weston
> I wish to provide a facility with a NSTableView wherein the leftmost > (specifiable) columns remain statically on the left of the display > (subject to vertical scrolling) while the remaining columns scroll > normally constrained to the right of the static columns. I've done > this succes

Re: Where are my bytes hiding?

2016-05-05 Thread Greg Weston
> Second question: > Finder says about the containing folder: 11,239 bytes (33 KB on disk) for 9 > items > 11,239 = sum of TotalFileSizes of the 8 files in this folder. > But where do the “33 KB on disk” come from? 8 times “Zero bytes on disk” > should be zero, shouldn’t it? Surely "xxx on disk

Re: BOOL parameter passed as nil object

2016-04-19 Thread Greg Parker
ven there. On some platforms BOOL is defined as signed char. It may have any of 254 values other than YES or NO. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post adm

Re: BOOL parameter passed as nil object

2016-04-19 Thread Greg Parker
ent a_bool end up with a 1 value assigned to it? Don't do that. The behavior is undefined. It will certainly fail on some current architectures at least some of the time. You should not use -performSelector:withObject: to call methods that use non-object parameters. -- Greg Par

Re: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?

2016-03-04 Thread Greg Parker
ect that performs the callback and pass it to the C code to store and call. The block object would capture the target NSObject so you don't need the dictionary of callback targets. -- Greg Parker gpar...@apple.com Runtime Wrangler _

Re: ARC code in a non ARC app. iOS

2016-02-24 Thread Greg Parker
> On Feb 24, 2016, at 2:31 AM, Dave wrote: > > Also, beware subclassing a Non-ARC Class in an ARC Project - you have to have > the subclass Non-ARC too. This is not true. For example, NSView is not ARC but you can write ARC subclasses of it. -- Greg Parker gpar.

Re: ARC code in a non ARC app. iOS

2016-02-23 Thread Greg Parker
Objective-C++ compilers. Plain C code is unaffected. Note that you may need code changes if your C code uses CoreFoundation types and you want to call it from ARC code. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev

Re: ARC code in a non ARC app. iOS

2016-02-23 Thread Greg Parker
eature(objc_arc) # error This file must be compiled with ARC enabled. #endif -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comme

Re: ARC code in a non ARC app. iOS

2016-02-23 Thread Greg Parker
hin an app that doesn't? Yes, -fno-objc-arc works on iOS too. Was that your question? -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or mod

Re: calendar & repeating events api

2016-02-16 Thread Greg Parker
k: to find "fifth Saturdays" after some starting date. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the l

Re: Obj-C - your thoughts on hiding data members?

2016-01-25 Thread Greg Parker
rimary @interface are @protected by default. Therefore you should either move your ivars out of the primary @interface, or leave them in @interface but explicitly declare them @private or @package. -- Greg Parker gpar...@apple.com Runtime Wrangler ___

Re: Panes vs. Separate Windows

2016-01-11 Thread Greg Weston
> (I also don’t want to restart Xcode wars, but I do actually believe that the > unified window style that arrived in Xcode 4 was an actual decision about > which worked best, made by clever people who actually thought about it. It > wasn’t — I believe — merely clueless. I also want to point out

Re: LSSharedFIleList API deprecated

2015-12-09 Thread Greg Weston
ith the need to remove > recent items. No word yet. > —kevin While not optimal, I would imagine this could be accomplished with a combination of recentDocumentURLs, clearRecentDocuments: and noteNewRecentDocumentURL:. Greg ___ Cocoa-dev mai

Re: Adding minutes to display time

2015-12-08 Thread Greg Parker
way off. How to fix this?* What is the value of print(startDate) ? What do you get if you display `date` and `startDate` using an NSDateFormatter instead of print() ? I bet `date` and `startDate` are in fact five minutes apart, but either your date co

Re: Swift screensavers in Ubuntu?

2015-12-04 Thread Greg Parker
the Swift-ObjC importer. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)

Re: The joys of people using valueForKey to get objects out of a dictionary.

2015-11-10 Thread Greg Weston
> On Nov 10, 2015, at 15:21, Alex Zavatone wrote: > > >> Yeah. Honestly, I'm looking for cases that would justify why all the >> dictionary object access blocks in this code that use valueForKey are >> wrapped with @try/@catch clauses. I've never seen cases with objectForKey >> that would

Re: The joys of people using valueForKey to get objects out of a dictionary.

2015-11-10 Thread Greg Parker
11-10 10:00:55.296 a.out[38293:4747164] ordinary value 2015-11-10 10:00:55.297 a.out[38293:4747164] ( something, ordinary, "@allKeys", "@something" ) 2015-11-10 10:00:55.298 a.out[38293:4747164] *** Terminating app due to uncaught exception 'NSUnknownKeyEx

Re: The joys of people using valueForKey to get objects out of a dictionary.

2015-11-10 Thread Greg Weston
> It's been about 4 or 5 years since I made this mistake but I've just seen a > massive swath of code where every access of a dictionary object is using > valueForKey instead of objectForKey. > > I've got a few examples of why this is a "really bad idea"™, I would like to see these examp

Re: NSFileWrapper - is this really so bad?

2015-10-27 Thread Greg Parker
27;t match. It is unlikely that all of the new annotations and all of the documentation are correct. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post adm

Re: Handling http:// URLs

2015-10-14 Thread Greg Weston
ny behavior you could imagine. Lacking the aforementioned concrete example, I can't come up with any of my own that aren't handled at least as well by a more "normal" mechanism and it strikes me that this has much more potential for abuse, or at lea

Re: New warning in Xcode 7

2015-10-13 Thread Greg Parker
orm was allowed, but I'm not enough of a language lawyer to know for sure. You might get better answers from a compiler mailing list. You can avoid confusion (human and compiler) by writing the statement without the preincrement's side effect: ix

Re: More Swift issues, NSURLComponents

2015-10-06 Thread Greg Parker
> On Oct 5, 2015, at 7:57 PM, Rick Mann wrote: > > Especially when a struct can be an AnyObject. `AnyObject` is an instance of any class type. It is never a struct. `Any` encompasses both classes and structs. -- Greg Parker gpar...@apple.com Runtime

Re: Mac OSX 10.11 and XCode

2015-10-01 Thread Greg Parker
gs? If I recall correctly, you can choose whether or not to relaunch apps when you deliberately log out or restart, but relaunch is automatic for involuntary crashes. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev maili

Re: -[NSThread start] blocks ?!?

2015-09-28 Thread Greg Parker
d by the debugging tools. (Specifically, it's the machinery that records stack traces of queue operations.) If you see this again, please capture a spindump and file a bug report. After you file the bug report, you might be able to work around it like this: defaults write com.apple.dt.

Re: OpenGL Vertical Syncing effect on run loops

2015-09-22 Thread Greg Parker
g factor, not anything in the runloop or NSTimer itself. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the

Re: Error unwrapping an optional which isn't an optional

2015-09-21 Thread Greg Parker
ause it's not optional so Swift won't let it in an 'if > let'. selectedRow's "row index or -1" behavior is an obvious candidate for a Swift optional, but we don't currently have a good way to bridge such API with Objective-C. -- Greg Parker gpar..

Re: Tracking down source of [_NSControllerObjectProxy copyWithZone:]… error

2015-09-21 Thread Greg Parker
at the bottom > Add Exception Breakpoint) Another dumb alternative: implement -[_NSControllerObjectProxy copyWithZone:] to call abort() or otherwise halt the process. Then it will stop in the debugger or generate a crash log with a stack trace pointing to the call site. -- Greg Parker gp

Re: Is it possible to transfer data by using light

2015-09-17 Thread Greg Weston
> This toy can connect to the iphone's network by detecting the blinking > screen of an iPhone. I wonder if it is possible that using this technique > to transfer data. Absolutely. Such techniques have been used for 150 years, using lamps or reflected sunlight to send Morse-like codes to human o

Re: Swift: combining Obj-C enums

2015-09-09 Thread Greg Parker
gPropertiesForKeys: nil, > options: > .SkipsSubdirectoryDescendants | .SkipsPackageDescendants | .SkipsHiddenFiles) In Swift 2 this is an OptionSetType. An option set literal looks like this: [.SkipsSubdirectoryDescendants, .SkipsPackageDescendants, .SkipsHiddenFiles] -- Greg

Re: String.join()?

2015-09-04 Thread Greg Parker
you it doesn’t exist any more), so you can’t call it or > command-click to it. You should file a bug report. It might be possible to make unavailable identifiers command-clickable, which would reveal their OS availability range or their suggeste

Re: Swift: should computed properties be able to throw exceptions?

2015-08-21 Thread Greg Parker
> On Aug 21, 2015, at 9:00 PM, Rick Mann wrote: > >> On Aug 21, 2015, at 20:58 , Greg Parker wrote: >> >>> Rick Mann wrote: >>> >>> Also, if the method of the call site is marked as "throws," does that mean >>> the error wil

Re: Swift: should computed properties be able to throw exceptions?

2015-08-21 Thread Greg Parker
> On Aug 21, 2015, at 8:18 PM, Rick Mann wrote: > >> On Aug 21, 2015, at 20:06 , Greg Parker wrote: >> >>> On Aug 21, 2015, at 6:15 PM, Rick Mann wrote: >>> >>>> On Aug 21, 2015, at 18:13 , Quincey Morris >>>> wrote: >

Re: Swift: should computed properties be able to throw exceptions?

2015-08-21 Thread Greg Parker
ferent: the possibility of error is explicit at the call site. Some people think this is better (no invisible execution paths) and some people think it is worse (too noisy). Either way the model is different enough that we don't call it exception handling. The fact that Swift's

Re: Thread-safe singleton with lazy initialisation

2015-08-18 Thread Greg Parker
guarantees. dispatch_once() is the best solution on Apple's platforms. If you don't like dispatch_once() then you could use pthread_once(). If you don't like dispatch_once() nor pthread_once() then you can use PTHREAD_MUTEX_INITIALIZER instead of pthread_mutex_init(). That avoids

Re: Why is overriding unavailable designated initializer of super required?

2015-08-10 Thread Greg Parker
where else later. The compiler's enforcement is for designated initializers because they should be a bottleneck that the compiler can see. Enforcing covers of every superclass convenience initializer would be difficult because it's likely that the compiler can't see them all when compil

Re: Why is overriding unavailable designated initializer of super required?

2015-08-10 Thread Greg Parker
@end or you can implement it to fail at runtime: @interface YourSubclass -(id) init NS_UNAVAILABLE; @end @implementation YourSubclass ... -(id) init { abort(); // or throw or whatever } @end Either approach wil

Re: ARC and Manual Memory Management

2015-08-10 Thread Greg Parker
subsequent changes. For example, the code might look like it supports non-ARC but the retain/release calls are in fact in the wrong places because the only version that is actually tested is the ARC version. GC tried the approach of ignoring retain/r

Re: Can I show different content in different screens? (screensaver)

2015-07-24 Thread Greg Parker
before it is used along all code paths. The compiler recently became smarter at this analysis so it works in more cases. (Downside: you must specify the variable's type.) let myVar: String if let value = something?.somethingElse { myVar = value.stringName } else {

Re: Swift description

2015-07-12 Thread Greg Parker
// I have the lot print("\(c)") // I have the lot debugPrint(c) // I am CustomDebugStringConvertible debugPrint("\(c)") // "I have the lot" Note that (1) string interpolation prefers the non-debug description when available, and (2) debugPrin

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
caught up. You should file a bug report. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
oryEnumerator. It returns AnyObject type, > so wouldn't there have to be an NSURL cast in there somewhere? `for case` uses Swift's pattern matching system, as seen in `switch`. Something like this should work: for case let item as NSURL in enumerator! { … } -- Gre

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Greg Weston
>> If you ask the wrong question, you get a wrong answer. :) > > Whether or not it was the wrong question is debatable. Honestly I find that assertion suspect considering that you've moved the goalposts three times. ___ Cocoa-dev mailing list (Cocoa-d

Re: Loading .dylib problem

2015-07-01 Thread Greg Parker
lding and packaging embedded dylibs. You may want to reconfigure your project to use it. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderato

Re: Swift 2 throws from init()

2015-07-01 Thread Greg Parker
> On Jul 1, 2015, at 5:39 PM, Rick Mann wrote: > >> On Jul 1, 2015, at 17:04 , Greg Parker wrote: >> >> Implicitly unwrapped optional is a good solution for this. The source code >> is no more complicated outside init, and if you get something wrong then you &g

Re: Swift 2 throws from init()

2015-07-01 Thread Greg Parker
ally run, and then (2) cross your fingers really hard. > It seems the only way to handle this is with an Optional (or implicitly > unwrapped Optional) type? Implicitly unwrapped optional is a good solution for this. The source code is no more complicated outside init, and if you get som

Re: Swift and parameter names

2015-07-01 Thread Greg Parker
left, bottom, right. Classic Mac OS was inconsistent. For example, the C struct initializer for Rect was { top, left, bottom, right }, but the initializer function was SetRect(&rect, left, top, right, bottom). -- Greg Parker gpar...@apple.com Runtime Wrangler __

Re: Swift and parameter names

2015-06-29 Thread Greg Parker
ld prefer a different whitespace convention, one with no spaces around the colon in actual parameters. That's a popular convention in Objective-C. Otherwise there is no difference between Objective-C and Swift here. -- Greg Parker gpar...@apple.com Runtime Wrangler __

Re: Simple Swift question

2015-06-29 Thread Greg Parker
mpiler's understanding of the code don't match. For example, in your code above, writing `let url: NSURL = …` moves the error message from the NSURLRequest line to the NSURL line. -- Greg Parker gpar...@apple.com Runtime Wrangler _

Re: Swift and parameter names

2015-06-24 Thread Greg Parker
ou think the caller should be allowed to specify names or not then you can write two overloads, one of which simply calls the other. (I did something like this at one point for CGRect's initializers, allowing any of CGRect(1, 2, 3, 4) or CGRect(x:1, y:2, w:3,

Re: C Assert in BSD Static Library

2015-06-23 Thread Greg Parker
assert() has no effect on NSAssert(). > Are these set in the Library project or the App project that links to them? Assert behavior is usually set when the library is compiled. Sometimes the library will have a runtime variable that affects assert behavior. -- Greg Parker gpar...@

Re: Trouble With NSURLSession...

2015-06-16 Thread Greg Parker
egateQueue: nil) You're inside a class func. `self` is the class object for class HSNDataManager. That class object is not a valid delegate. Presumably you need to pass an instance of HSNDataManager as the delegate object. -- Greg Parker gpar...@apple.com Runtime Wrangler __

Re: Wanted: Elegant way to manage this task

2015-06-09 Thread Greg Parker
wants NSData. If all goes well you'll get NSData compatibility with zero or one extra copies. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests

  1   2   3   4   5   6   7   8   9   10   >