我已成功将"RestKit"pod添加到我的项目中,并且还按照本文中描述的步骤操作:Cocoapods in swift.我将RestKit导入到我的ViewController类的源文件中:
import RestKit
Run Code Online (Sandbox Code Playgroud)
但我不知道为什么我无法访问它.它不会显示RestKit中的任何类.表明:
'RestKit'不存在这样的模块.
我再次尝试创建一个新项目并添加了"RestKit".并创建了一个桥接头并将"RestKit"导入ViewController claas的源文件中.现在我运行该项目它显示错误
// in this file Pods-SOCKit-prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h" // Pods-environment.h file not found
// and also in this file Pods-TransitionKit-prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h" // Pods-environment.h file not found
Run Code Online (Sandbox Code Playgroud)
如果有人知道这背后的问题是什么,请向我解释一下,并建议一种在Swift中使用RestKit的方法.
请帮忙使用SFTP连接到我的服务器,我尝试了很多。但它不能正常工作。服务器工作正常。
// 第一个方法
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = "username : password"
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
let url = NSURL(string: "sftp.myserver.com")
let task = session.dataTaskWithURL(url!) {
(let data, let response, let error) in
// data - nil, response - nil
}
task.resume()
Run Code Online (Sandbox Code Playgroud)
// 第二种方法
func connect() {
let url: NSURL = NSURL(string: "sftp.myserver.com")!
let login:String = "username"
let password:String = …Run Code Online (Sandbox Code Playgroud) 我有ALAssetsLibrary从相机返回的图像.现在,我想在一个显示它UIImageView.我尝试了这段代码,但它显示了一些错误:
var assets : ALAsset = photoArray.objectAtIndex(indexPath.row) as ALAsset
cell.cameraOutlet.image = UIImage(CGImage: assets.thumbnail()) as UIImage // Showing error - Missing argument for parameter 'inBundle' in call
Run Code Online (Sandbox Code Playgroud)
之后,我尝试了这段代码:
var assets : ALAsset = (photoArray.objectAtIndex(indexPath.row) as ALAsset)
var imageRef : CGImageRef = assets.thumbnail() as CGImageRef // showing error - Unmanaged<CGImage>, is not convertible to CGImageRef
cell.cameraOutlet.image = UIImage(CGImage: assets.thumbnail()) as UIImage // Showing error - Missing argument for parameter 'inBundle' in call
Run Code Online (Sandbox Code Playgroud)
我想显示图像,我该怎么做?
dispatch_async(dispatch_get_main_queue(), {
self.photoLibrary.enumerateGroupsWithTypes(ALAssetsGroupType(ALAssetsGroupAlbum),
usingBlock: {
(group: ALAssetsGroup!, …Run Code Online (Sandbox Code Playgroud) 我有代码从库中获取照片并访问类型.但我不知道如何检查图像是PNG还是JPEG.通过ALAssetLibrary,我们可以轻松完成此任务.我想通过Photos框架实现它.任何人都有任何想法.?有什么建议.提前致谢.
我尽我所能,但我被困在这里.我想从iPhone相册中导入所有照片.所以我想出了这个ALAssestsLibrary API.
photoLibrary.enumerateGroupsWithTypes(ALAssetsGroupType(ALAssetsGroupSavedPhotos), usingBlock: { group in
if group != nil
{
}
}, failureBlock: { error in println("\(error)")})
Run Code Online (Sandbox Code Playgroud)
如何添加这行代码.
group enumerateAssetsUsingBlock:groupEnumerAtion
Run Code Online (Sandbox Code Playgroud)
我尝试添加它但它没有显示任何enumerateAssetsUsingBlock属性.?
这是实际的代码.!在Objective-C中
dispatch_async(dispatch_get_main_queue(), ^
{
@autoreleasepool
{
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"error occour =%@", [myerror localizedDescription]);
};
ALAssetsGroupEnumerationResultsBlock groupEnumerAtion = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if (result!=NULL)
{
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto])
{
[self.g_imageArray addObject:result];
}
}
};
ALAssetsLibraryGroupsEnumerationResultsBlock
libraryGroupsEnumeration = ^(ALAssetsGroup* group, BOOL* stop)
{
if (group == nil)
{
return;
}
if …Run Code Online (Sandbox Code Playgroud) 我有这段代码用于显示emailMessageBody中的某些内容。代码如下。
var emailViewController : MFMailComposeViewController = MFMailComposeViewController()
emailViewController.mailComposeDelegate = self
emailViewController.setToRecipients(["----"])
emailViewController.setSubject("----")
emailViewController.setMessageBody("\n\n\n" + "-- \r\n " + "----- Device : \(self.deviceName), App Version : \(self.appVersion), Model : \(deviceModel) , iOS Version : \(self.deviceVersion), Country Code : \(self.countryCode), Localised Model : \(deviceLocalizedModel) \n \n \n", isHTML: true)
self.presentViewController(emailViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
大家看到我在内容中加了“ \ n”,但在emailBody中未显示新行。如果有人知道如何在emailMessageBody中获得一些新行,请帮助。
这是我的代码.我必须为localNotification添加任何内容.有什么建议.提前致谢.我阅读了很多本地通知教程.我不知道错过了什么.
var localNotifications : UILocalNotification!
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
localNotifications = UILocalNotification()
localNotifications.fireDate = NSDate(timeIntervalSinceNow: 20)
localNotifications.timeZone = NSTimeZone.defaultTimeZone()
localNotifications.alertBody = "Check it out!"
localNotifications.soundName = UILocalNotificationDefaultSoundName
localNotifications.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
UIApplication.sharedApplication().scheduleLocalNotification(localNotifications)
Run Code Online (Sandbox Code Playgroud)
}
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
println("Alvin Notification recieved")
if application.applicationState == UIApplicationState.Active
{
// show alertView
Utilities.sharedInstance.alertThis("Hello", message: "Hey")
}
else if application.applicationState == UIApplicationState.Background
{
UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
}
else if application.applicationState == UIApplicationState.Inactive
{
UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
}
application.applicationIconBadgeNumber = 0 …Run Code Online (Sandbox Code Playgroud)