Skip to content

Instantly share code, notes, and snippets.

import kotlinx.cinterop.memScoped
import kotlinx.cinterop.allocArrayOf
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned
import platform.Foundation.NSData
import platform.Foundation.create
import platform.posix.memcpy
public fun ByteArray.toData(): NSData = memScoped {
NSData.create(bytes = allocArrayOf(this@toData),
@leilee
leilee / Install iOS Simulators in Xcode Manually.md
Last active May 15, 2024 01:03
Install iOS Simulators in Xcode Manually
  • Open Xcode -> Preferences -> Components.
  • Open the Console App, clear the console.
  • Go back to the Xcode preferences. Start the simulator download, then cancel it.
  • Now in the Console, you will see something about the cancellation with the download URL.
  • Copy the URL from the Console, download it.
  • Copy this file to ~/Library/Caches/com.apple.dt.Xcode/Downloads.
    • If Downloads did not exist, create a new Downloads directory.
    • If Downloads exists, remove all *.dvtdownloadableindex files under it.
  • Open Xcode -> Preferences -> Components, start the simulator download again, it should find the file you downloaded and install it.
@mona-zsh
mona-zsh / NSString+Truncate.m
Created April 13, 2015 01:01
NSString+Truncate.m
//
// NSString+Truncate.m
// EMLabel
//
// Created by Mona Zhang on 3/31/15.
// Copyright (c) 2015 Mona Zhang. All rights reserved.
//
#import "NSString+Truncate.h"