我一直在研究一种方法,在多个设备(如iPad或Mac)之间同步存储在iPhone应用程序中的核心数据。在iOS上,用于core data的同步框架并不多(如果有的话)。然而,我一直在思考以下概念:

A change is made to the local core data store, and the change is saved. (a) If the device is online, it tries to send the changeset to the server, including the device ID of the device which sent the changeset. (b) If the changeset does not reach the server, or if the device is not online, the app will add the change set to a queue to send when it does come online. The server, sitting in the cloud, merges the specific change sets it receives with its master database. After a change set (or a queue of change sets) is merged on the cloud server, the server pushes all of those change sets to the other devices registered with the server using some sort of polling system. (I thought to use Apple's Push services, but apparently according to the comments this is not a workable system.)

有什么特别的需要我考虑的吗?我已经研究了REST框架,如ObjectiveResource、Core Resource和RestfulCoreData。当然,这些都是与Ruby on Rails一起工作的,我并不依赖于Ruby on Rails,但这是一个起点。我的解决方案的主要要求是:

任何更改都应该在后台发送,而不需要暂停主线程。 它应该使用尽可能少的带宽。

我想过一些挑战:

Making sure that the object IDs for the different data stores on different devices are attached on the server. That is to say, I will have a table of object IDs and device IDs, which are tied via a reference to the object stored in the database. I will have a record (DatabaseId [unique to this table], ObjectId [unique to the item in the whole database], Datafield1, Datafield2), the ObjectId field will reference another table, AllObjects: (ObjectId, DeviceId, DeviceObjectId). Then, when the device pushes up a change set, it will pass along the device Id and the objectId from the core data object in the local data store. Then my cloud server will check against the objectId and device Id in the AllObjects table, and find the record to change in the initial table. All changes should be timestamped, so that they can be merged. The device will have to poll the server, without using up too much battery. The local devices will also need to update anything held in memory if/when changes are received from the server.

我还遗漏了什么吗?我应该考虑什么样的框架来实现这一点?

我从我的Linux shell连接到mysql。我时不时地运行一个太大的SELECT查询。打印啊打印啊,我已经知道这不是我的意思。我想停止查询。

按Ctrl+C(几次)完全杀死mysql,带我回到shell,所以我必须重新连接。

是否有可能在不杀死mysql本身的情况下停止查询?

我通过Ruby宝石“续集”使用PostgreSQL。

我要四舍五入到小数点后两位。

这是我的代码:

SELECT ROUND(AVG(some_column),2)    
FROM table

我得到以下错误:

PG::Error: ERROR:  function round(double precision, integer) does 
not exist (Sequel::DatabaseError)

当我运行以下代码时,我没有得到错误:

SELECT ROUND(AVG(some_column))
FROM table

有人知道我哪里做错了吗?

当我试着在我的iPhone上检查网络连接时,我得到了一堆错误。有人能帮我解决这个问题吗?

代码:

import Foundation
import SystemConfiguration

public class Reachability {

class func isConnectedToNetwork() -> Bool {

    var zeroAddress = sockaddr_in()
    zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
    zeroAddress.sin_family = sa_family_t(AF_INET)

    let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
        SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
    }

    var flags: SCNetworkReachabilityFlags = 0

    if SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) == 0 {
        return false
    }

    let isReachable = (flags & UInt32(kSCNetworkFlagsReachable)) != 0
    let needsConnection = (flags & UInt32(kSCNetworkFlagsConnectionRequired)) != 0

    return (isReachable && !needsConnection) ? true : false
}

}

代码的错误:

如果它是不可读的,错误1说:

'Int'不能转换为'SCNetworkReachabilityFlags'

错误2和3:

找不到一个超载的'init'接受提供的参数

我正在使用以下代码发送电子邮件。代码在我的本地机器上正常工作。但是在生产服务器上,我得到了错误消息

var fromAddress = new MailAddress("mymailid@gmail.com");
var fromPassword = "xxxxxx";
var toAddress = new MailAddress("yourmailid@yourdoamain.com");

string subject = "subject";
string body = "body";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
{
    Host = "smtp.gmail.com",
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential(fromAddress.Address, fromPassword)       
};

using (var message = new MailMessage(fromAddress, toAddress)
{
    Subject = subject,
    Body = body
})

smtp.Send(message);

在我的Gmail A/c上,我从生产服务器运行代码后收到了以下电子邮件

Hi , Someone recently used your password to try to sign in to your Google Account mymailid@gmail.com. This person was using an application such as an email, client or mobile device. We prevented the sign-in attempt in case this was a hijacker trying to access your account. Please review the details of the sign-in attempt: Friday, 3 January 2014 13:56:08 o'clock UTC IP Address: xxx.xx.xx.xxx (abcd.net.) Location: Philadelphia PA, Philadelphia, PA, USA If you do not recognise this sign-in attempt, someone else might be trying to access your account. You should sign in to your account and reset your password immediately. Reset password If this was you and you are having trouble accessing your account, complete the troubleshooting steps listed at http://support.google.com/mail?p=client_login Yours sincerely, The Google Accounts team

Try:

sudo apt-get install maven

如果它对你有用,就忽略这篇文章的其余部分。

介绍

我在2013年4月开始安装我的Ubuntu 12.10,当时正常的sudo apt-get安装maven还不能用于maven 3。

如果你想深入了解你的ubuntu内核,了解apt-get以及它在哪里找到可供安装的应用程序列表,这篇文章中的手动安装是很有用的 . 如果你在Ubuntu 12.10时遇到了和我一样的问题,它也可能对Ubuntu 15.04等最新版本有用。

通过apt-get自动安装:

如果您当前的ubuntu不能通过普通的“apt-get install maven”安装maven,请检查手动安装。

sudo apt-get update
sudo apt-get install maven

如果你的ubuntu不是最新的,或者你以前使用过maven 2,请确保删除maven 2:

sudo apt-get remove maven2

手动安装通过apt-get添加maven 3资源库(Ubuntu 14.04检查更新1):

如果你的ubuntu apt-get存储库列表不是最新的,这是很有用的。

安装系统需要Maven 3,而且大多数文档都是关于如何将Maven安装到Ubuntu 12.04或之前版本的。我找到的最好的文件是:

杀手罗非鱼的博客

我想到的整个过程如下:

sudo -H gedit /etc/apt/sources.list 添加以下行源代码。文件列表: Deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu精密主 Deb-src http://ppa.launchpad.net/natecarlson/maven3/ubuntu精密主 Sudo apt-get update && Sudo apt-get install maven3 Sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn

警告1:命令“sudo apt-add-repository ppa:natecarlson/maven3”在我的Ubuntu上不起作用,必须运行sudo apt-add-repository -rm ppa:natecarlson/maven3才能让我的apt-get再次工作。 警告2:感谢David,在运行第4步之前,您需要删除到以前版本maven的现有符号链接。

OS X安装

我决定添加OS X安装,以防您为开发人员使用多个环境:请参阅源stackoverflow线程了解更多详细信息。

安装相当于apt-get的Homebrew,然后使用以下命令安装Maven:

brew install maven

更新1:ubuntu 14.04的安装

我自己没有尝试过,但我相信这应该可以在没有安全警告的情况下工作:

sudo apt-get purge maven maven2 maven3
sudo apt-add-repository ppa:andrei-pozolotin/maven3
sudo apt-get update
sudo apt-get install maven3

注意:来源在这里,非常感谢@rendybjunior, @Dominic_Bartl和@FunThomas424242

我在PostgreSQL中有一个有很多列的表,我想添加一个自动递增的主键。

我试图创建一个名为BIGSERIAL类型id的列,但pgadmin响应一个错误:

错误:序列必须与它所链接的表具有相同的所有者。

有人知道如何解决这个问题吗?我如何在PostgreSQL中添加或创建一个自动递增的主键而不重新创建表?

我试图在我的IOS项目中添加一个框架,但当我构建时,我总是得到相同的消息:

ld:框架没有找到Pods Clang:错误:连接器命令失败,退出码为1(使用-v查看调用)

我试图删除我的pod目录,然后运行pod install 我打开。xcworkspace,就像它在pod安装的日志中写的那样,我在xcode上清理项目,然后尝试构建,但它不会工作。

我的podfile是这样的:

xcodeproj '/Users/guillaume/project/Mobile/iOS/FoodPin/FoodPin.xcodeproj'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'SwiftHTTP', '~> 0.9.2'

我的xcode版本是6.3.1

谢谢你!

尝试用swift字典中的键字符串填充数组。

var componentArray: [String]

let dict = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Components", ofType: "plist")!)
componentArray = dict.allKeys

这将返回一个错误:'AnyObject'与string不相同

也试过

componentArray = dict.allKeys as String 

but get: 'String'不能转换为[String]

我目前正在用Xcode 6 (Beta 6)测试我的应用程序。UIActivityViewController在iPhone设备和模拟器上工作得很好,但在iPad模拟器和设备(iOS 8)上崩溃

Terminating app due to uncaught exception 'NSGenericException', 
reason: 'UIPopoverPresentationController 
(<_UIAlertControllerActionSheetRegularPresentationController: 0x7fc7a874bd90>) 
should have a non-nil sourceView or barButtonItem set before the presentation occurs.

我使用以下代码用于iPhone和iPad的iOS 7以及iOS 8

NSData *myData = [NSData dataWithContentsOfFile:_filename];
NSArray *activityItems = [NSArray arrayWithObjects:myData, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:nil applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard];
[self presentViewController:activityViewController animated:YES completion:nil];

我得到一个类似的崩溃在我的另一个应用程序以及。你能引导我吗?ios8中的UIActivityViewController有什么变化吗?我查过了,但在这上面什么也没找到