Crash in CFPreferencesSetAppValue

  • Hello. This piece of code causes CFPreferencesSetAppValue() to
    crash:

    - (CFDictionaryRef) createBlockSaveData {

    CFDictionaryRef
    parent=[super createBlockSaveData];

    CFStringRef
    keys[]={CFSTR("LinkBlockURL"), CFSTR("LinkBlockDisplayName"),
    CFSTR("LinkBlockBrowser"), CFSTR("BlockType"), nil};

    CFTypeRef
    values[]={url ? (__bridge CFTypeRef)(url) : CFSTR("null"),

    displayName ? (__bridge CFTypeRef)(displayName) : CFSTR("null"),

    browser ? (__bridge CFTypeRef)(browser) : CFSTR("null"),

    CFSTR(LKBLockTypeURL),

    nil};

    CFMutableDictionaryRef
    dÏDictionaryCreateMutableCopy(nil, 0, parent);

    if (url) {for (int
    t=0; t
  • On 22 May 2013, at 11:10 PM, <tridiak...> wrote:

    >
    >
    > Hello. This piece of code causes CFPreferencesSetAppValue() to
    > crash:
    >
    > - (CFDictionaryRef) createBlockSaveData {
    >
    > CFDictionaryRef
    > parent=[super createBlockSaveData];
    >
    > CFStringRef
    > keys[]={CFSTR("LinkBlockURL"), CFSTR("LinkBlockDisplayName"),
    > CFSTR("LinkBlockBrowser"), CFSTR("BlockType"), nil};
    >
    > CFTypeRef
    > values[]={url ? (__bridge CFTypeRef)(url) : CFSTR("null"),
    >
    >
    > displayName ? (__bridge CFTypeRef)(displayName) : CFSTR("null"),
    >
    >
    > browser ? (__bridge CFTypeRef)(browser) : CFSTR("null"),
    >
    >
    > CFSTR(LKBLockTypeURL),
    >
    > nil};
    >
    > CFMutableDictionaryRef
    > d=CFDictionaryCreateMutableCopy(nil, 0, parent);
    >
    > if (url) {for (int
    > t=0; t

    Your code sample cuts off before (I think) it gets to the last point of contact with your code in the crash. We don't see any use of the keys and values arrays. Could you offer a complete listing, and tell us where in the method the crash occurs? Give us the full stack trace, which might provide a clue of what went wrong.

    Also, have you verified the types of url, displayName, and browser? If your "url" is an NSURL/CFURLRef, that's likely your problem; the ternary operator shows you expect the value to be a CFString.

    — F

    --
    Fritz Anderson
    Xcode 4 Unleashed: 4.5 supplement for free!
    http://www.informit.com/store/xcode-4-unleashed-9780672333279
  • Sorry about cutoff. Don't know what happened. Let's try again (is
    there a maximum message size?).

    Hello. This piece of code causes
    CFPreferencesSetAppValue() to crash:

    - (CFDictionaryRef)
    createBlockSaveData {

    CFDictionaryRef parent=[super
    createBlockSaveData];

    CFStringRef keys[]={CFSTR("LinkBlockURL"),
    CFSTR("LinkBlockDisplayName"), CFSTR("LinkBlockBrowser"),
    CFSTR("BlockType"), nil};

    CFTypeRef values[]={url ? (__bridge
    CFTypeRef)(url) : CFSTR("null"),

    displayName ? (__bridge
    CFTypeRef)(displayName) : CFSTR("null"),

    browser ? (__bridge
    CFTypeRef)(browser) : CFSTR("null"),

    CFSTR(LKBLockTypeURL),

    nil};

    CFMutableDictionaryRef dÏDictionaryCreateMutableCopy(nil, 0,
    parent);

    if (url) {for (int t=0; t
  • Sorry about noise. Just realised CFPreferences doesn't like
    NSURL/CFURL.
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today