有没有办法从自定义应用程序中将iCal事件添加到iPhone日历?
我正在研究Cocoa应用程序,它应该能够分析和突出显示用Objective-C,SQL,JavaScript,Python等语言编写的源代码.文本也应该是可编辑的(例如,使用NSTextView).
请告知在Mac OS X 10.5中实现此类功能的最佳方法是什么.
无需支持自动完成和其他额外功能.通过关键字,字符串,#include和数字进行简单格式化,但性能很酷就可以了.
此外,如果支持语言配置,那将会很棒.
谢谢!
请查看此标题:
// Test.h
@interface Test : NSObject @end
extern id A; // (0)
//extern static id B; // (1) Uncomment to get a compiling error
extern id C; // (2)
//extern static id D; // (3) Uncomment to get a compiling error
Run Code Online (Sandbox Code Playgroud)
并进入这个实现:
// Test.m
#import "Test.h"
id A = @"A"; // (4)
static id B = @"B"; // (5)
@implementation Test
id C = @"C"; // (6)
static id D = @"D"; // (7)
@end
// Still Test.m
@interface …Run Code Online (Sandbox Code Playgroud) 当我尝试使用最新版本的Swift 设置label1为第一个字母时,我在最后一行收到错误string.如何解决这个问题?
let preferences = UserDefaults.standard
let name1 = "" + preferences.string(forKey: "name")!
let name2 = name1
label1.text = name2.substring(from: 0)
Run Code Online (Sandbox Code Playgroud) 我正在构建一个命令行工具,它应该在运行时监听自定义 URL 方案:
import AppKit
import CoreServices
let RunLoop = CFRunLoopGetCurrent()
class EventHandler: NSObject {
@objc(handleAppleEvent:withReplyEvent:)
func handleURLEvent(_ e: NSAppleEventDescriptor,
_ reply: NSAppleEventDescriptor) {
guard
let descriptor = e.paramDescriptor(forKeyword: .init(keyDirectObject)),
let stringValue = descriptor.stringValue,
let components = URLComponents(string: stringValue) else {
exit(EXIT_FAILURE)
}
print(components)
CFRunLoopStop(RunLoop)
}
}
let status = LSSetDefaultHandlerForURLScheme(
"myscheme" as CFString, "com.test.myscheme" as CFString)
guard status == 0 else {
print(status)
exit(EXIT_FAILURE)
}
let handler = EventHandler()
let manager = NSAppleEventManager.shared()
manager.setEventHandler(handler, andSelector: #selector(EventHandler.handleURLEvent(_:_:)),
forEventClass: .init(kInternetEventClass), andEventID: …Run Code Online (Sandbox Code Playgroud) 当其父窗口处于活动状态或非活动状态时,所有本机控件的外观都不同。我们应该如何在自定义组件中检查此状态,例如在渲染按钮单元时?
我们可以检查和controlView.window的属性,但它们不能涵盖所有情况。例如,如果您在桌面上打开应用程序的一个窗口,而在全屏空间中打开另一个窗口,则根据公共API,其中只有一个可以是键或主键。但是,标准控件似乎使它们在两个空间中均处于活动状态:isMainWindowisKeyWindow

请注意,两个Safari窗口中的工具栏按钮如何呈现为活动状态。我们如何实现相同的行为?
我有以下可可形式:
struct Canvas: PreviewProvider {
static var previews: some View {
VStack {
HStack(alignment: .firstTextBaseline) {
Text("Endpoint:")
TextField("https://localhost:8080/api", text: .constant(""))
}
Divider()
HStack(alignment: .firstTextBaseline) {
Text("Path:")
TextField("/todos", text: .constant(""))
}
Spacer()
}
.padding()
.previewLayout(.fixed(width: 280, height: 200))
}
}
Run Code Online (Sandbox Code Playgroud)
该面板看起来不错,但我想右对齐“ Endpoint:”和“ Path:”标签:

所以我应用了一个自定义的水平对齐方式:
struct Canvas: PreviewProvider {
static var previews: some View {
VStack(alignment: .label) {
HStack(alignment: .firstTextBaseline) {
Text("Endpoint:").alignmentGuide(.label) { $0[.trailing] }
TextField("https://localhost:8080/api", text: .constant(""))
}
Divider()
HStack(alignment: .firstTextBaseline) {
Text("Path:").alignmentGuide(.label) { $0[.trailing] }
TextField("/todos", text: .constant(""))
}
Spacer() …Run Code Online (Sandbox Code Playgroud) 这是NSToolbar使用附件视图控制器插入 SwiftUI 的方式:
import SwiftUI
import PlaygroundSupport
var hostingView = NSHostingView(rootView:
ZStack {
Color.clear
HStack {
Text("Hey")
Text("SwiftUI")
}
}
.padding()
.edgesIgnoringSafeArea(.all)
)
hostingView.frame.size = hostingView.fittingSize
let titlebarAccessory = NSTitlebarAccessoryViewController()
titlebarAccessory.view = hostingView
titlebarAccessory.layoutAttribute = .trailing
let mask: NSWindow.StyleMask = [.titled, .closable, .miniaturizable, .resizable]
let window = NSWindow(
contentRect: .init(x: 0, y: 0, width: 480, height: 300),
styleMask: mask, backing: .buffered, defer: false)
window.center()
window.contentView = NSHostingView(rootView: Color(.windowBackgroundColor))
window.toolbar = .init()
window.titleVisibility = .hidden
window.addTitlebarAccessoryViewController(titlebarAccessory)
PlaygroundPage.current.liveView = window.contentView?.superview …Run Code Online (Sandbox Code Playgroud) 我想要在Things应用程序中完成与特殊项目相同的行为.我的意思是补充工具栏底部的日志和垃圾项目:
日志和垃圾箱项目位于最底层http://tinyurl.com/lhctza
请建议以任何方式在侧栏树中实现相同的功能.
我觉得特殊的'spacer'树项应该与outlineView:heightOfRowByItem:方法一起使用.
但是,我找不到如何计算所有可见项目的总高度(包括组之间的空间).
cocoa ×6
appkit ×3
ios ×3
iphone ×2
nswindow ×2
objective-c ×2
swiftui ×2
c ×1
calendar ×1
eventkit ×1
executable ×1
forms ×1
info.plist ×1
macos ×1
nscell ×1
nstextview ×1
nstoolbar ×1
nsview ×1
outline-view ×1
phone-number ×1
sidebar ×1
swift ×1
swift3 ×1
tree ×1
url ×1