cocoa

How to control the scientifc style of NSNumberFormatter?

亡梦爱人 提交于 2020-02-24 17:58:25
问题 I'm converting a long string representing a very big or small number to a string in scientific notation. E.g. 9999999999999999999999999 to 9.999999999999999E24. I use NSNumberFormatter. NSNumberFormatter *ns = [[NSNumberFormatter alloc] init]; [ns setNumberStyle: NSNumberFormatterScientificStyle]; NSString *result = [ns stringFromNumber: [ns numberFromString: aBigOrSmallString]]; [ns release]; But how can I control the precision part? For example, from 912345678 to 9.12E8 or 9.1234E8. 回答1:

Can't Send NSMutableDictionary To Another Class

拟墨画扇 提交于 2020-02-24 14:10:28
问题 All, I'm trying to send the NSMutableDictionary "response" to another class of mine, or rather, have the other class pull the dictionary from this class. When the other class uses the "getResponse" method, it returns null. The code I have attached is my XML parser, which is what puts the information I need into the dictionary. At the very bottom is the method that shows "(null)" in the NSLog. I have commented it for you. EDIT: I do use the initXMLParser method to initialize in the other class

NSCollectionView sizeForItemAt always returning exception when trying to reference an item in its collection

走远了吗. 提交于 2020-02-24 11:25:30
问题 Context - I am working on a macOS menu bar app which displays a collection of items. The items exist in a collection view and contain a textfield. Right now, the collection view layout is at a fixed height of 50, and I am trying to dynamically increase the size of the cell based on the size of the textfield. I believe the best way to do this is in the sizeForItemAt method, but I can not seem to reference a cell and its textfield to calculate and return it's height. Whenever I try and get a

NSCollectionView sizeForItemAt always returning exception when trying to reference an item in its collection

南楼画角 提交于 2020-02-24 11:25:07
问题 Context - I am working on a macOS menu bar app which displays a collection of items. The items exist in a collection view and contain a textfield. Right now, the collection view layout is at a fixed height of 50, and I am trying to dynamically increase the size of the cell based on the size of the textfield. I believe the best way to do this is in the sizeForItemAt method, but I can not seem to reference a cell and its textfield to calculate and return it's height. Whenever I try and get a

Receipt validation issue in App Purchases Mac Store “Receipt validation should be presented…”

杀马特。学长 韩版系。学妹 提交于 2020-02-24 11:15:50
问题 My applications uses the Store Kit API to purchases in app purchases. I am getting the following store rejection issue, has anyone ever encountered this? 2.3 Apps that do not perform as advertised by the developer will be rejected The app is not using the Store Kit API properly. The application needs to use receipt validation in order for Store Kit to properly process In App Purchases. I inquired further and they said: Receipt validation should be presented on launch of the app. Anyone have

Receipt validation issue in App Purchases Mac Store “Receipt validation should be presented…”

人盡茶涼 提交于 2020-02-24 11:14:06
问题 My applications uses the Store Kit API to purchases in app purchases. I am getting the following store rejection issue, has anyone ever encountered this? 2.3 Apps that do not perform as advertised by the developer will be rejected The app is not using the Store Kit API properly. The application needs to use receipt validation in order for Store Kit to properly process In App Purchases. I inquired further and they said: Receipt validation should be presented on launch of the app. Anyone have

How to close window (NSWindowController) by hitting the ESC key?

拟墨画扇 提交于 2020-02-23 08:01:39
问题 Issue I would like the user being able to close a window by hitting the ESC key but I can't get it to work in this specific case, hitting ESC triggers an error sound (the "no you can't do that" macOS bloop) and nothing happens. Context I'm making a subclass of NSWindowController which itself creates an instance of a subclass of NSViewController and sets it in a view. Both controllers have their own xib file. NSWindowController: final class MyWindowController: NSWindowController,

swift CGPDFDocument parsing

99封情书 提交于 2020-02-23 04:16:28
问题 I'm trying to use Swift to parse the contents of PDF documents, following Apple's programming guide (in which all the examples are ObjC...) let filepath = "/Users/ben/Desktop/Test.pdf" let localUrl = filepath as CFString if let pdfURL = CFURLCreateWithFileSystemPath(nil, localUrl, CFURLPathStyle.cfurlposixPathStyle, false) { if let pdf = CGPDFDocument(pdfURL) { if let inf = pdf.info { CGPDFDictionaryApplyFunction(inf, { (key, object, info) -> Void in print("\(key), \(object), \(info)") }, nil

How do I process a mouse click using Quartz events?

偶尔善良 提交于 2020-02-23 04:06:19
问题 I have a CGEventTap and I would like to observe and process all system mouse click events. Detecting a mouse click event is easy, but I don’t want some of the clicks to get processed by the rest of the system. And I can’t figure out how. The system only sends low-level events like mouseUp , mouseDown , mouseDragged and so on. When I receive a mouseDown event, I don’t know if it’s a part of a mouse click yet, could be a drag event. I have to wait for the following event – if it’s a mouseUp , I

Is FSGetVolumeInfo the recommended alternative to NSWorkspace's deprecated mountedLocalVolumePaths method?

岁酱吖の 提交于 2020-02-22 05:10:25
问题 I need to get a list of mounted local volumes on Mac OS X. Previously, the Cocoa class NSWorkspace had a mountedLocalVolumePaths method for getting the array of mount points for such volumes. Since Lion, this is now deprecated, with no hint in the documentation about what we should use instead. The only other Apple-specific API I have found which provides this information is the FSGetVolumeInfo function from the CoreServices.framework. This enumerates the mounted volumes if you pass