我正在尝试xcodebuild从命令行执行并存档我的应用程序。但是,出于某种原因,它My Mac显示为我的 iOS 应用程序的有效运行方案。这就是为什么运行这个会抛出。
xcodebuild: error: Failed to build workspace MyApp with scheme 'My-iOS-App.
Reason: The run destination My Mac is not valid for Running the scheme ''My-iOS-App'.
Run Code Online (Sandbox Code Playgroud)
关于如何解决这个问题的任何想法?
Restaurant我的应用程序中有一个Realm对象。该Restaurant对象具有许多Table与其连接的对象。如果我保存,它看起来像这样:
Restaurant *restaurant = [[Restaurant alloc] init];
restaurant.url = [_userData url];
restaurant.type = [_userData kind];
for (int i = 0; i < [[_userData tables] count]; i++) {
Input *input = [[_userData tables] objectAtIndex:i];
Table *table = [[Table alloc] init];
table.title = input.title;
table.seats = input.seats;
table.type = input.type;
[restaurant.tables addObject:table];
}
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.fileURL = [NSURL URLWithString:[Preferences getRealmPath]];
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:nil];
[realm beginWriteTransaction];
[realm addObject:restaurant];
[realm commitWriteTransaction];
Run Code Online (Sandbox Code Playgroud)
现在,我想要的是当添加餐厅时,但该餐厅已经存在于该配置中,因此不存储它。但是,如果添加了同一家餐厅,但是有所 …
在我的应用程序中,我有一些代码来获取中的主机范围URL。看起来像这样:
private func rangeOfHost(text: String) -> NSRange? {
let url = URL(string: text)
if let host: String = url?.host {
if let range = text.range(of: host) {
return NSRange(
location: range.lowerBound.encodedOffset,
length: range.upperBound.encodedOffset - range.lowerBound.encodedOffset
)
}
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
Xcode一直警告我'encodedOffset' is deprecated: encodedOffset has been deprecated as the most common usage is incorrect. Use utf16Offset(in:) to achieve the same behavior.。但是,我不清楚如何用这些建议替换那些encodingOffsets。有任何想法吗?
我在 Laravel Forge 服务器上设置了自动 iOS 推送通知。但是,有时并非所有推送通知都会发送出去。所以,我试图通过将它们添加到队列来解决这个问题。这是我现在的代码:
$devices = DB::table('devices')->get();
foreach ($devices as $device)
{
$push = PushNotification::app('Development')
->to($device->device)
->send($message);
$push = PushNotification::app('Distribution')
->to($device->device)
->send($message);
}
Run Code Online (Sandbox Code Playgroud)
现在,我尝试这样做:
$this->dispatch($push = PushNotification::app('Distribution')
->to($device->device)
->send($message));
Run Code Online (Sandbox Code Playgroud)
但这 - 显然 - 行不通。我该如何正确执行此操作?我不得不承认,我不太了解添加到队列的语法,而且文档在这方面不是很清楚也无济于事。
我已经设置UITableView为使用新的拖放 API。
if #available(iOS 11, *) {
self.tableView.dragDelegate = self
self.tableView.dropDelegate = self
self.tableView.dragInteractionEnabled = true
navigationController?.navigationBar.prefersLargeTitles = false
}
Run Code Online (Sandbox Code Playgroud)
现在,我实现了下面的方法,以便能够为 d&d 使用自定义视图。
@available(iOS 11.0, *)
func dragInteraction(_ interaction: UIDragInteraction, previewForLifting item: UIDragItem, session: UIDragSession) -> UITargetedDragPreview? {
print("Custom Preview method called!")
let test = UITextView.init(frame: CGRect.init(x: 0, y: 0, width: 200, height: 200))
test.text = "sfgshshsfhshshfshsfh"
let dragView = interaction.view!
let dragPoint = session.location(in: dragView)
let target = UIDragPreviewTarget(container: dragView, center: dragPoint)
return UITargetedDragPreview(view: test, parameters:UIDragPreviewParameters(), target:target) …Run Code Online (Sandbox Code Playgroud) 我有以下内容UICollectionViewCompositionalLayout:
public lazy var layout: UICollectionViewLayout = {
let layout = UICollectionViewCompositionalLayout {
(sectionIndex: Int, layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalHeight(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(115))
var count: Int = 2
if self.view.traitCollection.horizontalSizeClass != .compact {
if self.view.frame.size.width > 900 {
count = 5
} else {
count = 3
}
}
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: count)
let spacing = CGFloat(10) …Run Code Online (Sandbox Code Playgroud) 我正在iOS 11中使用新的放大导航栏标题.但我似乎无法更改textColor.
我试过做:
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
Run Code Online (Sandbox Code Playgroud)
这没有做任何事情.有任何想法吗?
我有一个添加了这个库的 Phalcon 项目:https : //github.com/vlucas/phpdotenv。该库旨在从 .env 文件加载一些环境变量。我创建了这样一个文件并将其放入我的项目中。
VERSION_NUMBER=3.14
DATABASE_HOST=localhost
DATABASE_NAME=test
DATABASE_USER=root
DATABASE_PASS=root
Run Code Online (Sandbox Code Playgroud)
我将我的loader.php文件重写为以下代码:
<?php
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerNamespaces(array(
'Test\Models' => $config->application->modelsDir,
'Test\Controllers' => $config->application->controllersDir,
'Test\Forms' => $config->application->formsDir,
'Test\Classes' => $config->application->classesDir,
'Test\Classes\Excel' => $config->application->excelDir,
'Test' => $config->application->libraryDir
));
$loader->register();
// Use composer autoloader to load vendor classes
require_once __DIR__ . '/../../vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->required(['DATABASE_HOST', 'DATABASE_NAME', 'DATABASE_USER', 'DATABASE_PASS']);
$dotenv->overload();
Run Code Online (Sandbox Code Playgroud)
在我的配置文件中,我用环境变量替换了密钥: …
在我的应用程序中,我有一个自定义RealmDatabase类。它为我初始化 Realm 数据库。
public class RealmDatabase: Database {
let realm: Realm
//
// I also provide a shared() singleton
//
public init(fileURL: URL) {
let config = Realm.Configuration(fileURL: fileURL)
Realm.Configuration.defaultConfiguration = config
realm = try! Realm()
}
public func observe<T>(_ block: @escaping ((T) -> Void), for object: T.Type) where T : Storable {
realm.objects(object).observe { (changes) in
print("Changes: ", changes)
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我还编写了一个名为的类,SyncEngine以便我可以开始与 CloudKit 同步。这个类看起来像这样:
public class SyncEngine: NSObject {
private let database: Database
public …Run Code Online (Sandbox Code Playgroud) ios ×4
objective-c ×2
php ×2
realm ×2
swift ×2
laravel-4 ×1
mac-catalyst ×1
nsrange ×1
phalcon ×1
queue ×1
string ×1
uikit ×1
uitableview ×1
xcode ×1
xcodebuild ×1