How to validate Core Data attributes ? (example in official doc doesn't work)

2017-06-13 Thread Glen Huang
Hi, I'm trying to validate an attribute of a NSManagedObject, I create a transformable attribute called location, make it CLLocation, and define a method on the object: func validateLocation(_ value: AutoreleasingUnsafeMutablePointer) throws { if value.pointee == nil { fat

Re: How to validate Core Data attributes ? (example in official doc doesn't work)

2017-06-13 Thread Glen Huang
rote: > > On Jun 13, 2017, at 19:10 , Glen Huang <mailto:hey...@gmail.com>> wrote: >> >> In the Core Data Xcode editor, I enabled optional for this attribute, but I >> expect this method will prevent the object from being saved when the it's >> locat

Re: How to validate Core Data attributes ? (example in official doc doesn't work)

2017-06-13 Thread Glen Huang
et etc). Also I don't quite get the "can’t afford the therapy afterwards" part, care to explain? (Sorry if that's a joke and I didn't get it) Thanks. > On 14 Jun 2017, at 2:41 PM, Quincey Morris > wrote: > > On Jun 13, 2017, at 23:32 , Glen Huang <mailto:h

Re: How to validate Core Data attributes ? (example in official doc doesn't work)

2017-06-14 Thread Glen Huang
yet. It's a bit discouraging. Sigh. > On 14 Jun 2017, at 3:26 PM, Quincey Morris > wrote: > > On Jun 13, 2017, at 23:54 , Glen Huang <mailto:hey...@gmail.com>> wrote: >> >> what do you use instead of Core Data? > > I ended up writing my own objec

Unable to extract JPEG from PHAsset

2017-06-16 Thread Glen Huang
Hi, I'm trying to extract the JPEG data from a PHAsset. I did it like this: let fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)] let assets = PHAsset.fetchAssets(with: fetchOptions)

Re: Unable to extract JPEG from PHAsset

2017-06-18 Thread Glen Huang
1:29 PM, David Duncan wrote: > > >> On Jun 16, 2017, at 7:31 AM, Glen Huang wrote: >> >> Hi, >> >> I'm trying to extract the JPEG data from a PHAsset. I did it like this: >> >> let fetchOptions = PHFetchOptions() >> f

Re: Unable to extract JPEG from PHAsset

2017-06-18 Thread Glen Huang
Forgot to mention, I also tested passing an image created using UIImage(named:) to UIImageJPEGRepresentation, and it worked just fine on my real device. I opened rdar://32829011 , there is a test case in it, if you're interested. > On 18 Jun 2017, at 5:45 PM, Glen Huang wrote: > &

Put UICollectionView within UITableViewCell

2018-03-09 Thread Glen Huang
Hi, I asked a question about putting UICollectionView within UITableViewCell on Apple Developer Forums (https://forums.developer.apple.com/thread/98176), but it doesn’t get many replies. I’m not sure if it’s ok to repost the question here. I apologize if it’s not. Here is the question: Hi, I'

Re: Put UICollectionView within UITableViewCell

2018-03-09 Thread Glen Huang
ethod is slightly off. I can’t > look it up at the moment. > >> On Mar 9, 2018, at 8:00 AM, Glen Huang wrote: >> >> Hi, >> >> I asked a question about putting UICollectionView within UITableViewCell on >> Apple Developer Forums (https://forums.develop

Re: Put UICollectionView within UITableViewCell

2018-03-10 Thread Glen Huang
I’ll give it a shot, thank you very much > On 10 Mar 2018, at 10:27 AM, Cosmo Birch wrote: > > But you presumably know the width (i.e. the CollectionView width minus any > insets), and you can calculate the height based on that with NSString or > NSAttributedString boundingRect functions. Assu

Using NSFetchedResultsController with many-to-many relationship

2018-03-10 Thread Glen Huang
Hi, I have two models: Person and Club. They have a many-to-many relationship. I want to display all people in a table view sectioned by clubs (which means there might be duplicate people across sections). I wonder how to do that with NSFetchedResultsController? NSFetchRequest never returns the

Re: Using NSFetchedResultsController with many-to-many relationship

2018-03-10 Thread Glen Huang
Works like a charm. Thanks! > On 11 Mar 2018, at 6:03 AM, Quincey Morris > wrote: > > On Mar 10, 2018, at 13:06 , Steve Christensen wrote: >> >> Don't complicate your life by managing multiple NSFetchedResultsControllers. >> Just create a single one that returns Club entities. > > The other

Creating object graph in swift, Core Data or vanilla objects?

2018-03-21 Thread Glen Huang
Hi, I'm using Core Data as my model, but I don't want to actually persist anything. Anytime a view controller is shown, I load json data from my server and populate the store. The problem is that objects in Core Data persist between view controllers, even with in-memory store type. But when I

Re: Creating object graph in swift, Core Data or vanilla objects?

2018-03-21 Thread Glen Huang
, why not make all the attributes > transient? But I would still persist, and just refresh the object graph with > the response based on how often the data may change. > > On Wed, Mar 21, 2018 at 4:56 AM, Glen Huang <mailto:hey...@gmail.com>> wrote: > Hi, > >

Re: Creating object graph in swift, Core Data or vanilla objects?

2018-03-21 Thread Glen Huang
r stores as you need. > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > >> On Mar 21, 2018, at 7:40 AM, Glen Huang > <mailto:hey...@gmail.com>> wrote: >> >> Thanks for the suggestion Alex. >>

Best strategy to update view controllers in navigation stack after users edit data

2018-04-20 Thread Glen Huang
Hi, I have an app where user can edit data and save to my server. I wonder what’s the best way to update affected view controllers in the navigation stack? To give an example, imagine it’s an a recipe app where users can create recipes and edit other’s recipes. In the navigation controller’s ro

Re: Best strategy to update view controllers in navigation stack after users edit data

2018-04-21 Thread Glen Huang
. > any trivial architectural changes in the client would need to be also made on > the server. Good point. > On Apr 21, 2018, at 5:46 AM, Ben Kennedy wrote: > >> On Apr 20, 2018, at 1:15 AM, Glen Huang wrote: >> >> I have an app where user can edit data and save to my serv