Tag: 参数

代码更新到Swift 2.0时出现问题。 “不能转换价值”

我已经更新到2.0 Swift自动转换的代码,但我已经看到了一些错误,但我想修复。 其中之一是:“不能将types[AnyObject]的值转换为期望的参数types'[String]? 创build这个VC是为了启动一个电子邮件屏幕,以帮助用户与我联系。 错误是在func lanzarEmail的以下行中: mailController?.setToRecipients(收件人) 代码: import UIKit import MessageUI class tuPropiaHistoriaVC: UIViewController,MFMailComposeViewControllerDelegate { var alert: UIAlertView? var subjectText:String? var destinatario:AnyObject! var mailController:MFMailComposeViewController? @IBOutlet weak var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() //Recipients subjectText = "Mi historia de éxito / superación." destinatario = "1234@hotmail.es" // Do any additional setup after loading the […]

太多的方法调用的参数,预期1,有2?(Xcode)

这个问题还有很多类似的问题,但是没有答案,每个项目都有所不同。 我有这个错误'太多的方法调用的参数,预计1,有2? 但在以前的arrays,我用这个错误没有发生? 这可能是代码的问题,但我不确定? 我已经去寻找可能影响它的其他错误,但是没有运气。 以下是我的编码, #import "MenuViewController.h" #import "ECSlidingViewController.h" @interface MenuViewController () @property (strong, nonatomic) NSArray *menu; @property (strong, nonatomic) NSArray *section1; @property (strong, nonatomic) NSArray *section2; @property (strong, nonatomic) NSArray *section3; @end @implementation MenuViewController @synthesize menu, section1, section2, section3; – (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } […]

iOS使用NSTimers向select器发送参数

有没有办法通过NSTimer发送参数给select器? myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:) userInfo:nil repeats:NO]; – (void)removeTheNote:(NSString*)note { NSLog(@"Note %@ ———– REMOVED!",note); } 我知道使用: myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:myNote) userInfo:nil repeats:NO]; 不起作用,所以我问,有没有办法做到这一点?

完全防止iOS Web应用程序在移动版Safari中打开链接,即使链接包含参数

我发现了多种解决scheme来阻止iOS Web应用程序在移动Safari中打开常规链接,但不幸的是,它们不适用于包含参数的链接,例如 href="index.php?s=example" 这些仍然在移动Safari中打开。 到目前为止我发现的正常链接的最短解决scheme可以在这里find在stackoverflow 。 也许有人可以修改该脚本?

RestKit GET请求queryParameter:没有匹配responseDescriptor

我试图用Restkit做一个请求,但我得到以下错误: {Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No mappable object representations were found at the key paths searched." UserInfo={NSLocalizedDescription=No mappable object representations were found at the key paths searched., NSLocalizedFailureReason=The mapping operation was unable to find any nested object representations at the key paths searched: This likely indicates that you have misconfigured the key paths for your mappings., […]

将float发送给不兼容的typesid的参数

我正在创build一个button,它使用核心数据来保存点注释的名称,xCoordinate和yCoordinate。 我可以成功保留这个名字,但是当我尝试保存一个坐标时,我总是收到这个错误。 我logging了正确的数据,我似乎无法保存它。 当我尝试为newPOI设置值时,出现如下错误:将“float”发送给不兼容types“id”的参数。 在数据模型中,属性设置为浮动。 self.latitude和self.longitude是floattypes的。 我的方法有点粗糙,因为我相对比较新,但是如果有任何反馈,我可以给你提供有关错误的信息。 以下是我的代码的方法。 我不明白'id'在这里发挥的作用。 -(void) saveSelectedPoiName:(NSString *)name withY:(float)yCoordinate withX:(float)xCoordinate{ self.pointFromMapView = [[MKPointAnnotation alloc] init]; self.annotationTitleFromMapView = [[NSString alloc] init]; AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *context = [appDelegate managedObjectContext]; self.annotationTitleFromMapView = name; self.latitude = yCoordinate; self.longitude = xCoordinate; NSEntityDescription *entityPOI = [NSEntityDescription entityForName:@"POI" inManagedObjectContext:context]; NSManagedObject *newPoi = [[NSManagedObject alloc] […]

将parameter passing给select器动作

我正处于一种我认为自己接近解决的情况,但也许不是。 我有一个自定义tableview单元格的tableview。 目前每个tableviewcell有3个uibuttons,访问它们并赋予它们function是没有问题的。 我遇到问题的3个button之一。 该button将用户从当前的导航控制器推到一个webview控制器,但我希望webview控制器是当前tableview单元格持有的http地址。 下面是我正在使用的代码的一小部分。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Identifier"; SearchTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SearchTableCell" owner:nil options:nil]; //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier]; for(id currentObject in topLevelObjects) { if([currentObject isKindOfClass:[SearchTableCell class]]) { cell = (SearchTableCell *)currentObject; […]

通过UIButton的select器传递参数

我在detailDisclousure的标注上有一个detailDisclousurebutton。 当按下这个button时,我需要调用一个方法来传递一个参数来标识调用它的annotation 。 怎么可能呢? 这是我的观点ForAnnotation: – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation isKindOfClass:[Annotation class]]) { static NSString* identifier = @"identifier"; MKPinAnnotationView* pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (pinView == nil) { pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]autorelease]; } Annotation *antt = annotation; pinView.canShowCallout = YES; pinView.draggable = YES; UIButton* detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [detailButton […]

如何将parameter passing给PhoneGap应用程序中的本地页面?

在PhoneGap应用程序中,我们可以使用以下代码设置起始页面。 self.viewController.wwwFolderName = @"www"; self.viewController.startPage = @"index.html"; 但是如果我想传递参数到这个页面,它将不起作用。 self.viewController.startPage = @"index.html?parameter=abc"; 这将导致NSURLErrorRedirectToNonExistentLocation错误。 有没有简单的方法来传递参数到本地页面?

Swift / iOS:如何在AnyObject / Any或Pointers的函数中使用inout参数

我试图编写一个函数,它需要一个variables指针和一个描述符/键,并为variables设置一个新的值。 理想情况下,指针应该是一个对象或一个原语,但我也可以使用单独的函数(或附加参数)。 在我的代码中,我也使用键从数据库中检索新值,但在下面的示例中,我使用虚拟值对其进行了简化,以便在操场中轻松使用它: import UIKit func setValue(inout object: AnyObject, key: String) { switch key { case "String": object = "A String" case "UIColor": object = UIColor.whiteColor() case "Bool": object = true default: println("Unhandled key: \(key)") } } var string: String = "Default String" var color: UIColor = UIColor.blackColor() var bool: Bool = false setValue(&string, "String") […]