iOS 开发
文章平均质量分 72
Victor张
这个作者很懒,什么都没留下…
展开
-
只有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 · 448 阅读 · 0 评论 -
MacOS平台下@rpath在动态链接库中的应用
@rpath. framework 配置原创 2022-09-20 09:52:35 · 683 阅读 · 0 评论 -
Core Data 多线程设计
CoreData 多线程记录转载 2022-08-05 11:58:13 · 178 阅读 · 0 评论 -
CoreData - 查询
CoreData 学习原创 2022-06-22 16:52:57 · 322 阅读 · 0 评论 -
(转载)Multi-Context CoreData 之多线程环境中使用CoreData
CoreData 多线程使用转载 2022-06-13 09:50:16 · 221 阅读 · 0 评论 -
swift / Objective-C - 单例
创建一个完整的单例:#import "SearchDelegate.h"@interface SearchDelegate() <NSCopying,NSMutableCopying>@endstatic SearchDelegate *sharedSearchDelegate = nil;@implementation SearchDelegate+ (inst...原创 2019-07-29 17:29:41 · 348 阅读 · 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 · 2466 阅读 · 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 · 272 阅读 · 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 · 135 阅读 · 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 · 272 阅读 · 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 · 156 阅读 · 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 · 165 阅读 · 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 · 165 阅读 · 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 · 2128 阅读 · 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 · 117 阅读 · 0 评论 -
Xcode 动态库的设置
最近项目开发新的功能,要在主应用中嵌入一个子程序:(本文暂不涉及如何嵌入子程序)主程序和子程序引用同一个framework,出现了重复,这会导致程序比较大。为了解决此问题,学习了解了下xcode动态库设置1. 首先我在子程序中移除嵌入的framework2. 因为公用framework,所以我觉得将该framework嵌入大SharedFrameworks路径下比较合适注: 路径是可以自定义的,我在该Demo中将其放在~/***MainApp.app/Contents/SharedFram原创 2021-01-11 17:26:39 · 1654 阅读 · 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 · 584 阅读 · 0 评论 -
Xcode 条件断点笔记
1. 判断Selector(NSString*)NSStringFromSelector(selector) == @“zoomIn:”原创 2020-08-27 18:03:43 · 1090 阅读 · 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 · 665 阅读 · 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 · 245 阅读 · 0 评论 -
Swift - 基础 self
self 属性类型的每一个实例都有一个隐含属性叫做self,self完全等同于该实例本身。你可以在一个实例的实例方法中使用这个隐含的self属性来引用当前实例。定义一个很简单的Counter类,Counter能被用来对一个动作发生的次数进行计数:class Counter { var count = 0 func increment() { count += ...原创 2020-06-19 10:00:11 · 164 阅读 · 0 评论 -
ios/macOS - 为新建文件添加前缀
为新建文件添加前缀(指定的项目)打开 CustomTempleteDemo.xcodeproj 文件夹,创建文件于路径(注意文件名):./CustomTempleteDemo.xcodeproj/xcshareddata/IDETemplateMacros.plist注: 我是用 sumblime text 打开并创建文件的IDETemplateMacros.plist的文件内容...原创 2020-04-17 10:58:52 · 294 阅读 · 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 · 878 阅读 · 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 · 1758 阅读 · 0 评论 -
swift 学用 - 枚举(Enum)
文章目录1. 枚举作为字典的key, 需要继承协议 Hashable2. 在switch、guard之外提取关联值1. 枚举作为字典的key, 需要继承协议 Hashable至于协议的方法,可以自己重新实现,也可以不用再实现2. 在switch、guard之外提取关联值根据反射机制提取关联值protocol Associated {}extension Associated { ...原创 2020-02-26 14:45:29 · 311 阅读 · 0 评论 -
CoreData - performBlock: & performBlockAndWait:
官方文档performBlock:You use this method to send messages to managed objects if the context was initialized using NSPrivateQueueConcurrencyType or NSMainQueueConcurrencyType.This method encapsulates an...原创 2019-11-05 17:58:58 · 427 阅读 · 0 评论 -
Xcode 添加资源目录, 在app的Resource目录下添加自定义目录
方式一: 拖拽的方式添加资源文件夹一般添加资源文件夹到项目时,文件夹显示的是黄色,生成的.app的Resource文件下也没有添加的文件夹:可见 .app 的Resource 目录下没有需要的资源文件:解决:添加资源文件夹时修改下面选项,文件夹呈现蓝色,生成的.app的Resource文件下有添加的文件夹:方式二:在Build Phases中添加资源文件...原创 2018-09-27 17:57:50 · 9822 阅读 · 1 评论 -
msg解决shareSDK分享失败问题
1.分享的url为空或者含特殊字符(未编码)导致分享失败 解决:判空url编码:self.rootView.shareUrl = [self.rootView.shareUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 2.分享的图片过大,导致分享失败解决:...原创 2015-12-18 11:55:25 · 1638 阅读 · 0 评论 -
ios extern 声明全局变量
A类中a.m这样定义了一个a类的全局变量? 1 2 3 4 #import "a.h" NSString* hello=@"helloworld"; @implementation a // NSString* hello=@"helloworld"; 两个地方都行,反正就是定义了这么一个类的全局外...转载 2016-03-10 23:52:08 · 717 阅读 · 0 评论 -
scrollview/tableview 无法响应touch事件
scrollview 及其子视图无法响应touch事件办法一:给view添加点击事件 - (void)viewDidLoad { [super viewDidLoad]; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc...原创 2015-12-18 17:09:15 · 1046 阅读 · 0 评论 -
textview 自适应高度
-(void)textViewDidChange:(UITextView *)textView{ if (textView.frame.size.height>100) {//当textview的高度到100时,返回 return; } <p class="p1"><span class="s1"><span> </span>原创 2016-01-07 13:37:54 · 531 阅读 · 0 评论 -
macOS Loaded the "XXXX" nib but no view was set.
NSViewController 从 xib 加载 view 时出现错误:macOS: Loaded the "XXXX" nib but no view was set.iOS :loaded the "XXXView" nib but the view outlet was not set 没有做nib文件到xxxViewControler程序的关联,特此记录下来:1, 打...转载 2018-09-29 11:33:13 · 904 阅读 · 0 评论 -
pch文件的创建和配置
http://www.cnblogs.com/wzdevelop/p/7339262.html文章目录一、手动创建和配置PCH文件二、编辑PCH文件混编import 头文件时提示 file not foundPCH文件(Precompile Prefix Header File),也就是预编译头文件,其作用就是,方便你一次性导入在多个文件中同时用到的头文件、宏或者URL地址等(全局使用),...转载 2019-01-09 16:56:20 · 977 阅读 · 0 评论 -
iOS/macOS 关于时间的处理
转载: http://www.cocoachina.com/ios/20161216/18361.html做App避免不了要和时间打交道,关于时间的处理,里面有不少门道,远不是一行API调用,获取当前系统时间这么简单。我们需要了解与时间相关的各种API之间的差别,再因场景而异去设计相应的机制。时间的形式在开始深入讨论之前,我们需要确信一个前提:时间是线性的。即任意一个时刻,这个地球上只有...转载 2019-02-20 15:54:54 · 575 阅读 · 0 评论 -
iOS/macOS - Customize the NSApplication/UIApplication
macOS: 更改info.plist 文件中类的配置信息:iOS: main 方法中传入自定义类的名称:原创 2019-07-15 11:55:29 · 434 阅读 · 0 评论 -
import 头文件时提示 file not found
import 头文件时提示 file not found注意pch文件路径 和 要引入的文件路径, 以及两个路径之间的关系。可以为工程添加头文件路径“Header Search Paths” : 形如 import <xxx.h> 和 import “xxx.h” 都会到配置的路径先查找头文件。“User Header Search Paths” : ...原创 2019-07-30 10:58:06 · 2931 阅读 · 0 评论 -
OC Swift混编 记录
OC 项目混编Swift在OC项目中初始创建swift文件时,会提醒创建桥接文件点击 Create Bridging Header 就会生成一个桥接文件如果误点导致没有创建桥接文件,可手动创建一个 “工程名-Bridging-Header.h" 的头文件,然后在工程中配置文件(参考下一步)工程配置target | Build Settingsswift 引用 OC...原创 2019-08-14 16:17:40 · 498 阅读 · 0 评论 -
Xcode 创建bot (Installer Bot)
创建Installer Bot, 自动构建Application本文基于macOS 项目,非iOS项目1. 配置 Server Xcode 服务因为我是在本地创建 Bot, 所以就把本机作为服务器1)怎么将本机作为服务器?网上有很多博客使用 Mac OS Server 软件搭建本地服务器比如: 第一次和你见面,我就深深的爱上你-Xcode Bot我采用Apache服务器Mac自带A...原创 2019-08-16 11:43:23 · 654 阅读 · 0 评论 -
OC / Swift / Xcode - 怎么私有化init 方法(禁止调用init方法生成对象)
Is it possible to make the -init method private in Objective-C?NS_UNAVAILABLE - (instancetype)init NS_UNAVAILABLE;This is a the short version of the unavailable attribute. It first appeared in ...转载 2019-10-09 17:23:42 · 2485 阅读 · 0 评论 -
iOS导航栏颜色
-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; //通过设置BackgroundImage来设置导航的背景 //设置背景为透明 [self.navigationController.navigationBar setBackgroundImage:[UIImage new...原创 2016-06-15 14:48:03 · 687 阅读 · 0 评论