cocoa

Notifications for file system changed?

£可爱£侵袭症+ 提交于 2020-02-20 09:29:46
问题 I'm implementing a free space on disk bar where while files are being copied, the free space bar updates. I need some way of being notified of file system changes. What's the best way to go about doing this? 回答1: The File System Events Programming Guide has all the info you need. You want to register with the File System Events API (OS X 10.5 and later). 回答2: To monitor operations on individual files you can use kqueue file change notifications. Uli Kusterer has a nice Obj-C wrapper called

Array of Objects in Core Data Entity?

帅比萌擦擦* 提交于 2020-02-20 04:57:20
问题 I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? 回答1: You can't create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your Workout entity called, say, exercises . Then set its Destination to the Exercise entity and check the "To-Many Relationship" checkbox. Note

Array of Objects in Core Data Entity?

寵の児 提交于 2020-02-20 04:57:08
问题 I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? 回答1: You can't create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your Workout entity called, say, exercises . Then set its Destination to the Exercise entity and check the "To-Many Relationship" checkbox. Note

How to read NMEA data from USB GPS device through cocoa application

时间秒杀一切 提交于 2020-02-19 07:02:14
问题 I am using USB GlobalSat(USG-MR350) GPS device. I want to get location data (latitude and longitude) from the device within my mac cocoa application.Tried to run the AMSerialPort sample code.It is detecting the usb device but it is giving output in nonreadable format.How can this data be converted to readable format.This is a part of the source code: - (void)serialPortReadData:(NSDictionary *)dataDictionary { // this method is called if data arrives // @"data" is the actual data, @"serialPort

Fill an UIBezierPath with a UIImage

给你一囗甜甜゛ 提交于 2020-02-19 05:07:00
问题 I got an UIBezierpath with a circle shape: UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:100]; But then i want to fill the circle with an UIImage (show only a portion of the image which is inside the circle) Best Regards Kristian Edit: Thanks to Daniel and Dave for excellent answers :D saved me a lot of trouble ;D The solutions: CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddPath(ctx, path.CGPath); CGContextClip(ctx); and: path.addClip; Both

Fill an UIBezierPath with a UIImage

我怕爱的太早我们不能终老 提交于 2020-02-19 05:04:47
问题 I got an UIBezierpath with a circle shape: UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:100]; But then i want to fill the circle with an UIImage (show only a portion of the image which is inside the circle) Best Regards Kristian Edit: Thanks to Daniel and Dave for excellent answers :D saved me a lot of trouble ;D The solutions: CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddPath(ctx, path.CGPath); CGContextClip(ctx); and: path.addClip; Both

Fill an UIBezierPath with a UIImage

偶尔善良 提交于 2020-02-19 05:03:22
问题 I got an UIBezierpath with a circle shape: UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:100]; But then i want to fill the circle with an UIImage (show only a portion of the image which is inside the circle) Best Regards Kristian Edit: Thanks to Daniel and Dave for excellent answers :D saved me a lot of trouble ;D The solutions: CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddPath(ctx, path.CGPath); CGContextClip(ctx); and: path.addClip; Both

Fill an UIBezierPath with a UIImage

安稳与你 提交于 2020-02-19 05:02:08
问题 I got an UIBezierpath with a circle shape: UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:100]; But then i want to fill the circle with an UIImage (show only a portion of the image which is inside the circle) Best Regards Kristian Edit: Thanks to Daniel and Dave for excellent answers :D saved me a lot of trouble ;D The solutions: CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddPath(ctx, path.CGPath); CGContextClip(ctx); and: path.addClip; Both

Hiding Dividers in NSSplitView

混江龙づ霸主 提交于 2020-02-16 06:51:31
问题 Since NSSplitView doesn't allow for hiding its dividers (the delegate method only allows for hiding dividers that are on the split views edge), I chose to subclass NSSplitView and override its draw methods to prevent specific dividers from drawing. However, as soon as I override either draw(rect:) or drawDivider(in:) the NSSplitView no longer animates it's dividers if I collapse an item like so activityItem.animator().isCollapsed = collapsed It even happens if I call super directly without

How can I get notified of a system time change in my Cocoa application?

一个人想着一个人 提交于 2020-02-14 03:11:46
问题 I have a Cocoa application that records datestamps on events. I need to know when the system time is reset and by how much, but I can't seem to fine a notification anywhere that tells me such a thing has happened. This change could happen because NTP reset the clock or because the user reset (e.g. from System Preferences). It would be great if there was just a NSNotification I could register to receive, but I'm open to any suggestions. 回答1: Apple added in NSSystemClockDidChangeNotification,