当你播放远程视频AVPlayer并开始倒带时,擦洗器就会出现问题.
如何顺利实施?
我项目的代码如下 - https://github.com/nullproduction/Player
- (void)initScrubberTimer
{
double interval = .1f;
CMTime playerDuration = [self playerItemDuration];
if (CMTIME_IS_INVALID(playerDuration))
{
return;
}
double duration = CMTimeGetSeconds(playerDuration);
if (isfinite(duration))
{
CGFloat width = CGRectGetWidth([scrubberSlider bounds]);
interval = 0.5f * duration / width;
}
__weak id weakSelf = self;
CMTime intervalSeconds = CMTimeMakeWithSeconds(interval, NSEC_PER_SEC);
mTimeObserver = [self.player addPeriodicTimeObserverForInterval:intervalSeconds
queue:dispatch_get_main_queue()
usingBlock:^(CMTime time) {
[weakSelf syncScrubber];
}];
}
- (void)syncScrubber
{
CMTime playerDuration = [self playerItemDuration];
if (CMTIME_IS_INVALID(playerDuration)) …Run Code Online (Sandbox Code Playgroud) 有一个包含 Catalyst 的 ios 项目。该项目具有无法针对 mac 架构进行编译的YandexMobileMetrica依赖项。如何使用 Swift Package Manager 添加仅限 iOS 的依赖项?
我尝试做两个目标。在第一个spm-test中,我禁用了 mac 标志。在第二个中,spm-test-mac离开了。我的 Package.swift 看起来像这样:
import PackageDescription
let package = Package(
name: "spm-test",
products: [
.library(
name: "spm-test",
targets: ["spm-test"]),
],
dependencies: [
.package(name: "YandexMobileMetrica", url: "https://github.com/yandexmobile/metrica-sdk-ios", from: "3.14.1"),
],
targets: [
.target(
name: "spm-test",
dependencies: ["YandexMobileMetrica"]),
.target(
name: "spm-test-mac",
dependencies: [])
]
)
Run Code Online (Sandbox Code Playgroud)
错误:
AppDelegate.swift:11:12: No such module 'YandexMobileMetrica'
Run Code Online (Sandbox Code Playgroud)
我的 AppDelegate.swift
// AppDelegate.swift
//
import UIKit
#if !targetEnvironment(macCatalyst)
import YandexMobileMetrica …Run Code Online (Sandbox Code Playgroud) 我想在应用关闭时保存未完成的数据下载.
试过这样,但总是空的resumeData:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate) name:UIApplicationWillTerminateNotification object:nil];
- (void)appWillTerminate
{
[self.downloadTask cancelByProducingResumeData:^(NSData *resumeData) {
if (resumeData)
[self saveData:resumeData];
else
NSLog(@"Not exist");
}];
}
Run Code Online (Sandbox Code Playgroud) 我在主线程中创建实体Artist,然后在后台线程中传递它并与实体相册相关联.
怎么做正确?
- (IBAction)add:(id)sender
{
Artist *artist = [Artist MR_createEntity];
artist.title = @"Eminem";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
// here a large calculation
Album *album = [Album MR_createEntity];
album.title = @"Album 1";
[artist setAlbums:[NSSet setWithArray:@[album]]];
dispatch_async(dispatch_get_main_queue(),^{
[artist.managedObjectContext MR_saveToPersistentStoreAndWait];
});
});
}
Run Code Online (Sandbox Code Playgroud)
错误:
MagicalRecordTest[2008:1803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship 'albums' between objects in different contexts (source = <Artist: 0x15eaa2d0>
Run Code Online (Sandbox Code Playgroud) 我使用lib MagicalRecord(https://github.com/magicalpanda/MagicalRecord)进行CoreData.framework.
我不明白如何使用临时对象.
如何为临时对象创建NSManagedContext以及在关闭控制器后是否删除每个NSManagedObject?
ios ×4
core-data ×2
afnetworking ×1
avfoundation ×1
avplayer ×1
cocoa-touch ×1
nsurlsession ×1
swift ×1