我想创建一个日历条目到iPhone日历,我尝试了以下代码
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = self.selectedPost.postTitle;
event.notes = self.selectedPost.postContent;
event.startDate = self.selectedPost.startDate;
event.endDate = self.selectedPost.endDate;
EKCalendar *targetCalendar = nil;
targetCalendar = [eventStore defaultCalendarForNewEvents];
NSLog(@"%@",targetCalendar);
[event setCalendar:targetCalendar];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
UIAlertView *alert = nil;
NSLog(@"err %@",err);
if (err) {
alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[err localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
}
else{
alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Added to calender" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
}
[alert show];
Run Code Online (Sandbox Code Playgroud)
但结果是
2013-01-15 …Run Code Online (Sandbox Code Playgroud) 我想在替换NSTextView中的部分文本后实现撤消操作.我用以下代码替换部分文本
- (void)omeAction
{
NSString *fullString = [self.textView string];
NSRange selectedRange = [self.textView selectedRange];
NSString *selectedString = [fullString substringWithRange:selectedRange];
NSString *stringToReplace = ...;
[[self.textView textStorage] beginEditing];
[[self.textView textStorage] replaceCharactersInRange:selectedRange withString:stringToReplace];
[[self.textView textStorage] endEditing];
}
Run Code Online (Sandbox Code Playgroud)
执行撤消时,我无法撤消文本替换
我在我的app.i中集成了FCM通知和云消息,其遵循与firebase doc中提到的完全相同的步骤.即使我尝试过FCM提供的示例代码.它只是抛出一些警告<FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "The operation couldn’t be completed. and <FIRMessaging/WARNING> FIRMessaging registration is not ready with auth credentials.
任何人都可以帮我解决它.我正在谷歌搜索一周,但没有任何帮助我得到.我用Appdelegate.m编写的代码是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Register for remote notifications
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
// iOS 7.1 or earlier
UIRemoteNotificationType allNotificationTypes =
(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge);
[application registerForRemoteNotificationTypes:allNotificationTypes];
} else {
// iOS 8 or later
// [END_EXCLUDE]
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings …Run Code Online (Sandbox Code Playgroud) 我正在尝试为IOS制作填字游戏应用程序,但我不知道如何检查字符串是否是有效的英语单词.
我怎么检查它.是否有任何API或在线工具来检查它.提前致谢
我需要像facebook的导航栏一样的导航栏色调(在iOS 7中)
我选择了facebook App的颜色并设置了它
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"#365491"]];
Run Code Online (Sandbox Code Playgroud)
但显示wron颜色.颜色是正确的.我通过将其设置为普通视图的背景来测试该颜色.
上面代码的结果是

但我需要这样的
此外,当我尝试通过设置相同颜色的视图背景时

如何重现像facebook这样的导航栏.
在我的项目中,我正在使用coredata.其中一个实体有一个名为newTotal的属性,在其对应的NSManagedObject类中属性声明就像
@property (nonatomic, strong) NSString *newTotal;
Run Code Online (Sandbox Code Playgroud)
如果我在NSObject子类中添加这样的属性,XCode将显示如下错误
error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects
Run Code Online (Sandbox Code Playgroud)
但是在NSManaged对象子类中,它没有显示错误,但是当访问属性时应用程序崩溃,就像EXC_BAD_ACCESS一样.
为什么XCode没有显示错误但是应用程序崩溃了?这是XCode/clang/LLVM的错误吗?
我知道它与合成相关的东西.NSManagedObject子类没有合成其中的属性,但@dynamic指令只是告诉编译器getter和setter方法不是由类本身实现,而是由其他地方实现(如超类或将在运行时提供).但我对此没有明确的想法.任何人都可以对这个问题有一个清晰的认识吗?
我有一个带有 Swift 包管理器的 iOS 库。我正在尝试运行单元测试, swift test
我不使用的原因是,我正在尝试从源代码管理中xcodebuild删除。.xcodeproj另外,当我们使用 spm 创建时会出现警告xcodeproj,generate-xcodeproj 将很快被弃用。TL;DR 这个库依赖于 Lottie,我尝试swift test 在根目录中运行,但它给出了很多错误。就像 /.build/checkouts/lottie-ios/lottie-swift/src/Public/Animation/AnimationView.swift:859:11: 错误:在我尝试的范围内找不到“superview”
swift test -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios14.5-simulator"
Run Code Online (Sandbox Code Playgroud)
然后它给出了错误error: module 'XCTest' was created for incompatible target x86_64-apple-macos10.15。我没有在任何地方指定 macos10.15,我使用的是 macOS 11.5.1
test我可以使用上述命令替换为 来构建包build。我的测试命令有什么问题?
据我了解,这是因为我没有指定目标模拟器,是否可以使用 指定目标模拟器swift test?
我正在尝试使用MAC OS X mavericks在我的mac中安装OCLint它的文档在这里说
*以下代码片段是终端启动时获取的.bashrc或.bash_profile文件的示例.*
OCLINT_HOME=/path/to/oclint-release
export PATH=$OCLINT_HOME/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?我是否需要创建.bashrc或.bash_profile文件,或添加到现有文件.我在哪里可以找到.bashrc或.bash_profile文件
我从这里https://firebase.google.com/docs/crashlytics/get-started遵循了有关设置crashlytics的说明
但是当我的应用执行时
Fabric.with([Crashlytics.self])
Run Code Online (Sandbox Code Playgroud)
该应用程序崩溃并显示消息 *** Terminating app due to uncaught exception 'FABException', reason: '[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'
从谷歌搜索,我有人说我们应该在Info.plist文件中添加以下代码。
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>your_key</string>
<key>Kits</key>
<array>
<dict>
<key>KitInfo</key>
<dict/>
<key>KitName</key>
<string>Crashlytics</string>
</dict>
</array>
</dict>
Run Code Online (Sandbox Code Playgroud)
但是,如果我遵循https://firebase.google.com/docs/crashlytics/get-started,在哪里可以找到APIKey
我想在一个语句中检查一个对象是否是一个类型NSNumber和一个布尔变量true.为此我写了如下:
let someBool = ...
if value.isKindOfClass(NSDictionary) {
// do something with dict
}
else if (let number = value as? NSNumber) && someBool{
//Do something with number
}
else {
// do something here
}
Run Code Online (Sandbox Code Playgroud)
但是,像'模式变量绑定这样的抛出错误不能出现在表达式中'.
如何在单一if条件下使用可选的展开和布尔条件?
ios ×6
objective-c ×5
swift ×3
macos ×2
boolean ×1
calendar ×1
cocoa-touch ×1
core-data ×1
crashlytics ×1
eventkit ×1
facebook ×1
firebase ×1
ios7 ×1
iphone ×1
llvm-clang ×1
nstextview ×1
optional ×1
undo-redo ×1