<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div style="font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: Arial;" class="">Say we split up Foundation's enums roughly into categories. You have your policies (NSURLCacheStoragePolicy, NSDateFormatterStyle), states/answers (NSURLSessionTaskState, NSQualityOfService), and, well, lists (NSSearchPathDirectory, NSStringEncoding). Given those, I’d say&nbsp;protocols, generics, and zero-cost abstractions are frequently a better choice (but not always). For instance, IMHO a closed protocol better models commonly-used styles.</div></blockquote><div>I agree a lot that enums are not nearly as useful as they seem at first sight, and I know I'm not the only one who started with an enum-based solution and realised later that it doesn't work out as expected.</div><div>But I didn't encounter that with enums in Foundation — obviously, because I'm not writing Foundation code ;-), so could you give some concrete examples where the different alternatives would be a better fit?</div><div>My experience is that enums loose their appeal quickly when you want to attach behaviour or properties to the different cases… but I think closed protocols would also be just a workaround, inferior compared with case classes and ad-hoc union types.&nbsp;</div><div><br class=""></div></div></body></html>