home.social

#nsstring — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #nsstring, aggregated by home.social.

fetched live
  1. Matching prefixes in Swift strings

    How do you determine if one string starts with another, in Swift?

    Surely that's exactly what the hasPrefix(_:) method is for:

    let greeting = "Hello"

    let sentence = "hello, this is dog."

    if sentence.hasPrefix(greeting) {

    print("Hi! Nice to meet you!")

    } else {

    print("No can haz etiquette?")

    }

    No can haz etiquette?

    Wot?

    The problem is that hasPrefix is not meant for general use with human text; it's barely better than a byte-wise comparison. It only guarantees that it [...]

    wadetregaskis.com/matching-pre

  2. Today I learned about the healing power of

    [attributedString removeAttribute:@"NSOriginalFont" range:fullStringRange];

    And I was wondering why the hell macOS was drawing my string in the totally wrong place.

    What the hell are they doing these days?

    #AppKit #macOS #Apple #NSString #BugFest #Developer #Cocoa

  3. Today I learned about the healing power of

    [attributedString removeAttribute:@"NSOriginalFont" range:fullStringRange];

    And I was wondering why the hell macOS was drawing my string in the totally wrong place.

    What the hell are they doing these days?