Menu
  • HOME
  • TAGS

Programmatically change screen saver settings

osx,swift,core-foundation

As I mentioned in Cocoa-Dev list, I was able to do it this way. Reading: var moduleDict = CFPreferencesCopyAppValue("moduleDict", "com.apple.screensaver") as NSDictionary var saverName = moduleDict["moduleName"] as String! Writing: var moduleDict = CFPreferencesCopyAppValue("moduleDict", "com.apple.screensaver") as NSDictionary var mutable = moduleDict.mutableCopy() as NSMutableDictionary mutable["moduleName"] = "MyScreenSaver" mutable["path"] = mySaverPath CFPreferencesSetValue("moduleDict", mutable...

Identifying cause of exception creating symmetric key in Swift

xcode,exception,swift,core-foundation

There's a fundamental difference in how exceptions are used and handled between C++ and Objective-C. In Objective-C they are intended to be fatal events that indicate pending complete failure. In C++ they are commonly used in lieu of returning an error value which might not be checked (java and C#...

IOS/xcode/Core Foundation: If a value is null do you have to release it?

core-foundation

If the argument is NULL, CFRelease will cause a runtime error and your application will crash. If the retain count of CFTypeRef objects becomes zero the memory allocated to the object is deallocated and the object is destroyed. If you create, copy, or explicitly retain (see the CFRetain function) a...

How to progrmatically make Mac OS X ICNS with 10 differnt images using sips or other

objective-c,osx,applescript,core-foundation,sips

If you want to use iconutil, you can do that. At least on my 10.9.5 system, it's part of the base OS. It's not a special install, like developer tools. You can verify that using: pkgutil --file-info /usr/bin/iconutil Here, that outputs: volume: / path: /usr/bin/iconutil pkgid: com.apple.pkg.BSD pkg-version: 10.9.0.1.1.1306847324 install-time:...

Swift CGPDFContextBeginPage and CFData

swift,core-foundation,cfdata,cfdictionary

CFData is “toll-free bridged” with NSData, and CFDictionary with NSDictionary. So the following should work: var mediaBox = CGRect(x: 0.0, y: 0.0, width: 612, height: 792) let boxData = NSData(bytes: &mediaBox, length: sizeofValue(mediaBox)) let pageInfo = [ kCGPDFContextMediaBox as String : boxData ] CGPDFContextBeginPage(context, pageInfo) ...

How can I enumerate all Keychain items in my OS X application?

objective-c,osx,security,keychain,core-foundation

You're providing an empty dictionary and not a valid query. If you take the code from the answer you were looking at and drop it into your project: NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys: (__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnAttributes, (__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit, nil]; NSArray *secItemClasses = [NSArray arrayWithObjects: (__bridge id)kSecClassGenericPassword, (__bridge...

Can a login item depend on the Core Foundation framework?

objective-c,osx,core-foundation

A login item is just a program. You could make Pages a login item, and I'm pretty certain Pages depends upon the Core Foundation framework. An alternative, and in my opinion superior, way of doing this is to use launchd....

CGRectMake Symbol not Found

osx,core-graphics,core-foundation,jsctypes

In the end I couldn't export the function so the solution I had to use was define the function myself, i guess that it was just returning a rect with fields populated and it worked :) CGRectMake: function() { /* https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake * CGRect CGRectMake ( * CGFloat x, * CGFloat...

Move window from dock icon to other

objective-c,osx,core-foundation

This is not possible. OS X doesn't work like Windows. The central organizing principle is the application, not the window. Applications are inherently single processes (there can be helpers in separate processes, but that's not reflected in the Dock or Command-Tab application switcher; the helpers generally don't have UI). The...

Vertical Text Alignment in Core Text

ios,objective-c,core-graphics,core-text,core-foundation

As I am not quite sure how you approached the solutions from the linked post, I will suggest a solution based on one of those answers. This may be exactly what you tried, but it may also be the appropriate solution. I assume a method exists for obtaining the size...

Ctypes How to set OSType which expects characters but is defined as unsigned int (OSX)

python,osx,ctypes,core-foundation

const OSType kFinderSig = 'MACS'; 'MACS' is a character constant, not a string! This code is using a (questionable) GCC extension for multi-character character constants. You can reproduce the results in Python using the (builtin) struct module: import struct kFinderSig = struct.unpack(">L", "MACS")[0] Alternatively, just hard-code the value as 0x4d414353...

How to change CFAttributedString's string but not attributes?

ios,nsattributedstring,core-foundation

You have not explained why we have to do this in the CFAttributedString world, and I certainly can't think of a reason to do so, so here's a basic outline of how to do it in the NSAttributedString world. Basically, you just cycle through the attributes of the first string...

Return Core Foundation object from a non-CF class method using ARC and iOS 5+ support

ios,objective-c,memory-management,automatic-ref-counting,core-foundation

Possible solutions: Rename your method according to the naming conventions of the Objective-C Basic Memory Management Rules, e.g. start the method name with "copy": - (CFStringRef)copyUTITypeForPath:(NSString *)path { NSString *extension = [path pathExtension]; CFStringRef result = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); return result; } Then the caller of the method is...

CoreFoundation references and AddressBook programming

ios,abaddressbook,core-foundation

You do not get NULL value cause of kABPersonEmailProperty record returns multi value type. Actually it returns valid object with empty list of values: NSLog(@"%@", emailMultiValue) -> ABMultiValueRef 0x156bbb00 with 0 value(s)

Ported OSX Obj-C/CG Screenshot Code to js-ctypes - crash on final line

objective-c,osx,core-graphics,core-foundation,jsctypes

Wowww so after struggling for like some hours then posting this I realize it right away haha Casing typo in selector!! I had writeTofile:atomically instead of writeToFile:atomically! If anyone would like to test this out, it's a simple firefox addon test case. Install an addon that allows installing addons from...

CFMessagePortInvalidationCallBack has no context info for remote ports

cocoa,core-foundation

Since all CFType objects are toll-free bridged to NSObject and thus id, you can use the associated object API (e.g. objc_setAssociatedObject()).

Get and set bundle-idenfitier of my app during run time

objective-c,osx,core-foundation

Changing the bundle identifire Is not possible. Even if you do some nasty digg, it will be rejected from appstore. As for obtaining it, use : [[NSBundle mainBundle] bundleIdentifier];...

GetProcessForPID not deprecated?

osx,core-foundation

SetFrontProcess is part of the Carbon API. Most of it has been deprecated since 10.8, and it's not available at all on 64-bit. It's still available for 32-bit applications, but it's certainly not something you'll want to use for new code. Use the Cocoa NSRunningApplication object as a substitute....

Leak in this method

ios,memory-leaks,core-foundation

You should use __bridge_transfer instead of __bridge in (__bridge NSData*)value. The value return from SecItemCopyMatching method (copy means the value returns should be released in apple naming convention) should be released, so you should transfer the ownership to ARC....