![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
macOS开发
文章平均质量分 70
Victor张
这个作者很懒,什么都没留下…
展开
-
Sandbox - 访问带有副文件的主文件 Access sidecar files in a Mac sandboxed app
Access sidecar files in a Mac sandboxed app原创 2023-02-23 18:11:49 · 351 阅读 · 0 评论 -
macOS Sandboxed app 多个程序共享 存入 Group preference的bookmark失败
Share security scoped bookmark in app group翻译 2023-02-15 11:51:19 · 202 阅读 · 0 评论 -
只有20%的iOS程序员能看懂:详解intrinsicContentSize 及 约束优先级/content Hugging/content Compression Resistance
end@end//测试关闭Intrinsic的影响 @implementation IntrinsicView -(instancetype) init {//不兼容旧版Autoreizingmask,只使用AutoLayout //如果为YES,在AutoLayout中则会自动将view的frame和bounds属性转换为约束。} //当用户设置extendSize时,提示系统IntrinsicContentSize变化了。转载 2022-11-18 15:52:41 · 469 阅读 · 0 评论 -
MacOS平台下@rpath在动态链接库中的应用
@rpath. framework 配置原创 2022-09-20 09:52:35 · 775 阅读 · 0 评论 -
Core Data 多线程设计
CoreData 多线程记录转载 2022-08-05 11:58:13 · 187 阅读 · 0 评论 -
CoreData - 查询
CoreData 学习原创 2022-06-22 16:52:57 · 336 阅读 · 0 评论 -
(转载)Multi-Context CoreData 之多线程环境中使用CoreData
CoreData 多线程使用转载 2022-06-13 09:50:16 · 233 阅读 · 0 评论 -
swift / Objective-C - 单例
创建一个完整的单例:#import "SearchDelegate.h"@interface SearchDelegate() <NSCopying,NSMutableCopying>@endstatic SearchDelegate *sharedSearchDelegate = nil;@implementation SearchDelegate+ (inst...原创 2019-07-29 17:29:41 · 355 阅读 · 0 评论 -
Build Metal-based Core Image kernels with Xcode
Apple 文档:Building a Library with Metal’s Command-Line ToolsMetal Shading Language for Core Image Kernels1. 在 Build Rules 结合 xcrun 编译生成Core Image 用的 kernel 文件*.metal: .metal 格式文件*.ci.metal: 是自定义的文件后缀格式.1.工程引入两个文件:ColorLUT_1.ci.metal 和 ColorLUT_1.ci.me原创 2022-03-08 16:14:02 · 770 阅读 · 0 评论 -
Xcode 相关问题
Build Settings1. Xcode 版本升级后找不到网上提到的相关配置了在学习 Metal Shading Language for Core Image Kernels时,在 Building Settings | Metal Compiler 中设置-fcikernel, 但是最新xcode 创建的项目中没有 Metal Compiler 生成选项。这时 可以选中工程文件,设置 Project Format选项:针对我的问题,更好的解决方法:Apple 课程Build Metal-原创 2022-03-08 16:05:17 · 2514 阅读 · 0 评论 -
开发常用命令记录(更新 ...)
查看指令集架构(是否支持arm64):lipo -info filePahte.g.:victor@Victors-Mac-mini ~ % lipo -info ~/libopencv_calib3d.4.5.4.dylibNon-fat file: ~/libopencv_calib3d.4.5.4.dylib is architecture: x86_64victor@Victors-Mac-mini ~ % lipo -info ~ /libomp.dylibArchitecture.原创 2021-12-07 11:41:35 · 1313 阅读 · 0 评论 -
Getting info about parent process that launched us
https://developer.apple.com/forums/thread/115369Q:I’m currently using “ProcessInformationCopyDictionary” to fetch @“ParentPSN”, and then “ProcessInformationCopyDictionary” again to fetch the parent’s bundle id and what-not. This is deprecated. What can.原创 2021-09-29 18:09:31 · 168 阅读 · 0 评论 -
unsigned long与unsigned long long 在windows和linux中位数的区别
转载: https://www.cnblogs.com/wizardface/archive/2012/02/02/2335843.html最近要写一些hvm虚拟机windows调用xen中hypercall的代码,发现一个问题就是unsigned long在windows中和linux中代表的位数不同,因此想调查一下。使用测试程序:#include <stdio.h>int main(){ printf("unsigned long long: %d\n", si.转载 2021-06-29 10:49:48 · 2221 阅读 · 1 评论 -
macos: Clearing the quarantine extended attribute from downloaded applications
Apple doc: 在 Mac 上安全地打开 AppWhen I’m packaging an application for deployment, I normally download the latest version from the vendor. If it’s a drag-and-drop install, where the application is a self-contained bundle, it will get the com.apple.quarantine .转载 2021-06-11 09:57:47 · 152 阅读 · 0 评论 -
macos / xcode 快捷的将选中的文本注释掉(/* ... */)
参考: stackoverflow使用Automator 创建service打开Automator, 选择 Quick Action勾选 Output replaces selected text在左侧Library搜索 AppleScript, 双击Run AppleScript代码如下:on run {input, parameters} repeat with anInput in input if "/*" is in anInput then set input t.原创 2021-06-08 18:16:56 · 282 阅读 · 0 评论 -
swift 类型继承协议后,方法调用规则测试
测试代码:protocol TheProtocol { func method1() func method3()}extension TheProtocol { func method1() { print("Called method1 from TheProtocol") } func method2() { print("Called method2 from TheProtocol") } f原创 2021-05-25 10:54:16 · 143 阅读 · 0 评论 -
macos 自定义main函数,CustomApplication、CustomAppDelegate
原文: http://www.voidcn.com/article/p-pjjwbveg-bvw.html在XCode中创建一个新的 Cocoa项目给我一个AppDelegate.swift文件,如下所示:import Cocoa@NSApplicationMainclass AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow!}The @NSApplicationMa.原创 2021-05-12 14:54:09 · 461 阅读 · 0 评论 -
iOS/macOS - Customize the NSApplication/UIApplication
– OC项目中自定义 application 类macOSStep 1: 创建自己的类:CustomApplicationStep 2: 更改info.plist 文件中 Principal class 配置的类名为 CustomApplication :iOSStep 1: 创建自己的类:CustomApplicationStep 2: main 方法中传入自定义类的名称:– swift 项目中自定义 application 类macOSStep 1: 创建自己的类:ACD原创 2021-05-12 14:24:02 · 296 阅读 · 0 评论 -
Cocoa开发之APP开机自启动
原文: http://www.skyfox.org/cocoa-sandbox-app-launch-at-login.htmlmacOS app 开机自启动虽然有很多种方法,但是在需要上架APPStore的情况下,访问沙盒外的文件会被拒绝.苹果官方提供了两种方式: Service Management framework 和 shared file listThere are two ways to add a login item: using the Service Management .转载 2021-05-12 11:11:47 · 463 阅读 · 0 评论 -
Xcode使用xcconfig文件配置环境
参考:Apple Doc: Add a build configuration (xcconfig) fileApple Doc: Configuration Settings File (xcconfig) formathttp://liumh.com/2016/05/22/use-xcconfig-config-specific-variable/#xcode-targetBuild Setting 的继承关系 (转载)原创 2021-05-11 15:58:50 · 163 阅读 · 0 评论 -
The Unofficial Guide to xcconfig files(copy 为防止原文丢失)
General InformationOne of the least documented aspects of the configuration process are xcconfig files. As of this writing there seem to be no documents provided by Apple that explain how to use xcconfigs or why they exist. A xcconfig file is used as a su转载 2021-04-30 14:09:43 · 185 阅读 · 0 评论 -
通过ServiceManagement注册LaunchdDaemon
在OSX开发与系统密切相关的软件,经常会使用到高权限的操作,让整个程序都以高权限执行显然是不合适的,通过将高权限的任务封装到独立的子程序,按需要进行调用是比较合理的做法。而常见的做法是通过注册LaunchdDaemon,便可轻松实现开机启动、长驻后台、高权限的需求。注册LaunchdDaemon的常用方法是通过launchd工具去load一个与Daemon程序相关的标准的plist文件,这个过程一般放在PKG的安装脚本中完成,但当前越来越多的软件摒弃了PKG的打包方式,而是直接选择了打包成app,这样确实转载 2021-04-06 09:23:40 · 270 阅读 · 0 评论 -
在 macOS 中如何使用 XPC 实现跨进程通讯?
以防丢失,转载自: http://davidleee.com/2020/07/20/ipc-for-macOS/如侵权,联系删除最近需要在 Electron 项目上引入一个比较吃性能的大头功能,因为已经用 Objective-C 实现过一套稳定且性能也可接受的带 UI 方案了,所以计划看看能不能将这套现成的方案直接用到 Electron 里。但想要这么做就必须解决原生 UI 与 Electron 通讯的问题,再进一步,能不能让 Electron 以多进程的方式调起这个大头功能的 Demo 以节省掉绝.转载 2021-04-02 11:30:34 · 2593 阅读 · 0 评论 -
获取系统空闲时间(空闲了多久)
// 鼠标,键盘事件重置// 不包括视频播放public func SystemIdleTime() -> Double? { var iterator: io_iterator_t = 0 defer { IOObjectRelease(iterator) } guard IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"), &iterator) =原创 2021-03-30 16:00:28 · 464 阅读 · 0 评论 -
Close other apps in sandbox mode
参考: https://developer.apple.com/forums/thread/122020当启用 sandbox 时, 无法直接 kill 掉别的进程,需要在 .entitlements 文件中配置信息。测试@IBAction func killAction(_ sender: Any) { let runingApps = NSRunningApplication.runningApplications(withBundleIdentifier:.原创 2021-03-11 10:39:15 · 183 阅读 · 0 评论 -
macOS - Cocoa开发之沙盒机制及访问Sandbox之外的文件
原文地址:http://www.skyfox.org/cocoa-macos-sandbox.htmliOS默认并且只能读写对应的沙盒目录。OSX自从10.6系统开始引入沙盒机制,规定发布到Mac AppStore的应用,必须遵守沙盒约定。沙盒对应用访问的系统资源,硬件外设,文件,网络,XPC,都做了严格的限制,这样能防止恶意的App通过系统漏洞,攻击系统,获取控制权限,保证了OSX系统的安全。沙盒相当于给每个App一个独立的空间。要获取自己空间之外的资源必须获得授权。macOS APP不需要上.原创 2021-02-26 10:30:28 · 2289 阅读 · 0 评论 -
macOS 文件ID
let url = URL.init(fileURLWithPath: "/Users/victor/Pictures/redeyes")var fileID: String? = nillet values = try url.resourceValues(forKeys: .init(arrayLiteral: .fileResourceIdentifierKey))print(values.fileResourceIdentifier)即使改变了 “/Users/victor/Pictur原创 2021-02-25 10:25:43 · 124 阅读 · 0 评论 -
Xcode 动态库的设置
最近项目开发新的功能,要在主应用中嵌入一个子程序:(本文暂不涉及如何嵌入子程序)主程序和子程序引用同一个framework,出现了重复,这会导致程序比较大。为了解决此问题,学习了解了下xcode动态库设置1. 首先我在子程序中移除嵌入的framework2. 因为公用framework,所以我觉得将该framework嵌入大SharedFrameworks路径下比较合适注: 路径是可以自定义的,我在该Demo中将其放在~/***MainApp.app/Contents/SharedFram原创 2021-01-11 17:26:39 · 1729 阅读 · 0 评论 -
Xcode 环境变量
官方文档:Xcode Build System GuideBuild Settings referenceVariableExampleVariableExamplePATH“/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin”LANGen_US.US-ASCIIIPHONEOS_DEPLOYME.原创 2021-01-19 17:26:10 · 609 阅读 · 0 评论 -
macOS: 使用 UserDefaults 进行进程间通信
代码:阶段1Step 1: 首先创建两个工程一个主工程**MainPrj: 发送消息一个Hub工程: 接受消息Step 2: 为两个添加相同的group id原创 2020-12-30 12:30:50 · 458 阅读 · 0 评论 -
Xcode 条件断点笔记
1. 判断Selector(NSString*)NSStringFromSelector(selector) == @“zoomIn:”原创 2020-08-27 18:03:43 · 1135 阅读 · 0 评论 -
KVC 方法: keyPathsForValuesAffectingValueForKey: 在 CIFilter中的应用
关于CIFilter 的 KVC 方法:keyPathsForValuesAffectingValueForKey:/// KVC, 返回能触发对应输入参数 key 的 其他key的集合。 override class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> { // 根据测试发现 super.keyPathsForValuesAffectingValue 会原创 2020-08-07 10:15:51 · 681 阅读 · 0 评论 -
Swift - 学用 数组 Array
文章目录遍历数组方法效率比较遍历数组方法效率比较//var hhArr = Set<Int>.init()////for i in 0..<1000000 {// hhArr.insert(i)//}var hhArr: Array<Int> = [Int].init(repeating: 12, count: 1000000)//forin 遍历var stratTime = CACurrentMediaTime()for num in hhAr原创 2020-06-19 10:26:44 · 252 阅读 · 0 评论 -
macOS: 凸显约束冲突
#if DEBUGUserDefaults.standard.set(true, forKey: "NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints")#elseUserDefaults.standard.set(false, forKey: "NSConstraintBasedLayoutVisualizeMutual...原创 2020-06-19 10:11:30 · 387 阅读 · 1 评论 -
Linux/macOS 文件权限管理
命令:改变文件【owner权限】【group权限】【others权限】均可读可写可执行:chmod 777 temp.txt格式:chmod 权限数字 文件名总共有4部分,如上图第1部分:文件类型,d:文件夹,- : 文件第2部分:owner权限,rwx第3部分:group权限,rwx第4部分:others权限,rwx权限数字:rwx: 4+2+1r–: 4...原创 2020-02-19 20:49:28 · 384 阅读 · 0 评论 -
Swift - 基础 self
self 属性类型的每一个实例都有一个隐含属性叫做self,self完全等同于该实例本身。你可以在一个实例的实例方法中使用这个隐含的self属性来引用当前实例。定义一个很简单的Counter类,Counter能被用来对一个动作发生的次数进行计数:class Counter { var count = 0 func increment() { count += ...原创 2020-06-19 10:00:11 · 169 阅读 · 0 评论 -
ios/macOS - 为新建文件添加前缀
为新建文件添加前缀(指定的项目)打开 CustomTempleteDemo.xcodeproj 文件夹,创建文件于路径(注意文件名):./CustomTempleteDemo.xcodeproj/xcshareddata/IDETemplateMacros.plist注: 我是用 sumblime text 打开并创建文件的IDETemplateMacros.plist的文件内容...原创 2020-04-17 10:58:52 · 308 阅读 · 0 评论 -
Swift - 学用 字典 Dictionary
方法: mapValues, compactMapValuesvar dic = [String: Any]()dic["key1"] = "aaaa1"dic["key2"] = "aaaa2"dic["key3"] = "aaaa3"dic["key4"] = "aaaa4"dic["key5"] = "aaaa5"dic["key6"] = "aaaa6"dic["key7"...原创 2020-04-03 11:19:50 · 922 阅读 · 0 评论 -
Swift - button的状态绑定一个变量
给 button的状态绑定一个变量class ViewController: NSViewController { @IBOutlet weak var undoBtn: NSButton! @IBInspectable var enableUndo: Bool = false override func viewDidLoad() { ...原创 2020-03-13 17:48:14 · 522 阅读 · 0 评论 -
形如:%2$@, %1$@, %2$d, %1$d 的占位符
%1$@%2$@%1$d%2$d一段OC代码, 其他语言也类似NSString *total = @"10";NSString *sub = @"3";NSString *enStr = @"%@ of %@";NSString *chStr = @"%2$@ 个中的 %1$@ 个"; NSString *egLishString = [NSString str...原创 2020-03-05 09:59:33 · 1807 阅读 · 0 评论