小编Noo*_*oor的帖子

架构arm64的未定义符号.将C调用到ObjC++文件中?

我收到Apple Mach-O链接器错误:

Undefined symbols for architecture arm64:
  "_TestFunction", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

以下是重现错误所需的所有步骤:

  1. 我创建了一个新的单视图通用Objective C项目(Xcode Version 6.0.1(6A317))).
  2. 然后我创建了一个名为TestClass的新ObjectiveC文件
  3. 将TestClass.m更改为TestClass.mm
  4. 将" void TestFunction();" 添加到我的.h
  5. 将" void TestFunction(){}" 添加到我的.mm中
  6. 导入TestClass.h我的ViewController.m并尝试TestFunction()从我的viewDidLoad 调用.

我正在做一些Core-Audio工作,需要在我的MIDI回调中进行一些C++调用,所以我不能进行任何ObjectiveC方法调用,因为它们会阻塞音频线程.

也许Xcode将TestFunction()视为C++调用,因此不会从纯ObjectiveC类中获取它?有没有办法告诉Xcode它是C函数?

c++ xcode objective-c ios

4
推荐指数
1
解决办法
3167
查看次数

iPhone SDK 4:奇怪的编译错误,MPMoviePlayerController

我有一个viewController包含以下方法:

- (IBAction) playMovie {
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"]];

    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:)
                                       name:MPMoviePlayerPlaybackDidFinishNotification
                                       object:moviePlayer];

    moviePlayer.controlStyle = MPMovieControlStyleNone;
    moviePlayer.shouldAutoplay = YES;

    [self.view addSubview:moviePlayer.view];
    [moviePlayer setFullscreen:YES animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

由于错误,我无法编译代码:

未定义的符号:

  "_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
      _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in AnotherViewController.o
     (maybe you meant: _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr)
  "_OBJC_CLASS_$_MPMoviePlayerController", referenced from:
      objc-class-ref-to-MPMoviePlayerController in AnotherViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

这条消息对我没有意义.

我打算将此方法用作视图控制器的一部分.我是否必须为播放器创建单独的视图控制器,或者情况并非如此?

我在创建这个项目时使用了SDK 3.1.2,但是根据新的API规则完全重写了playMovie方法.当前的SDK版本是4.0.1

iphone

3
推荐指数
1
解决办法
3704
查看次数

google admob undefined symbol for architecture armv7

我用最新的admob库版本6.12.0替换了旧版本的admob 6.6.1,但我得到了这个错误,虽然每件事都很好.我正在使用xcode 6.0.1,如何解决这个问题,有什么帮助吗?

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_EKEvent", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_OBJC_CLASS_$_EKEventEditViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

xcode admob ios

3
推荐指数
1
解决办法
2796
查看次数

点击UITableView Cell时隐藏标签

我的单元格中有一个标签,我想在点击时显示/隐藏.我知道我必须得到从内部轻敲的单元格的索引路径didSelectRowAtIndexPath.但我不确定如何在特定单元格中显示/隐藏标签.

我可以从内部显示/隐藏它didSelectRowAtIndexPath,还是有办法处理它cellForRowAtIndexPath然后更新它?

我做了一些研究,但我真的找不到很多东西.

以下是我到目前为止的所有内容:

var selectedRowIndex: NSIndexPath = NSIndexPath(forRow: -1, inSection: 0)

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    selectedRowIndex = indexPath
}
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios swift

3
推荐指数
1
解决办法
5798
查看次数

坚持谷歌admob sdk 7

我已经实现了谷歌admob sdk 6.12,广告出现了,一切都运行完美,几天后谷歌更新了sdk 7,再次我导入新的sdk但这次我无法使用#import "GADInterstitial.h"每次我得到错误#import"GADInterstitial.h"没有找到,导入所有框架但没有成功,如果我使用@class GADInterstitial.h;和使用此代码没有广告出现

- (void)viewDidLoad {
          [super viewDidLoad];
          self.interstitial = [[GADInterstitial alloc] init];
          self.interstitial.adUnitID = Interstical_Unit_id;

          GADRequest *request = [GADRequest request];
          // Requests test ads on simulators.
          request.testDevices = @[ GAD_SIMULATOR_ID ];
          [self.interstitial loadRequest:request];
        }
 - (void)gameOver {
      if ([self.interstitial isReady]) {
        [self.interstitial presentFromRootViewController:self];
      }
      // Rest of game over logic goes here.
    }
Run Code Online (Sandbox Code Playgroud)

admob ios

2
推荐指数
1
解决办法
903
查看次数

通过过滤某些值从现有创建新词典

好的,所以这是我的问题.

我将对象数组(Person类)添加到字典中.每个包含fullName和其他一些属性.我通过循环生成密钥来创建字典

NSString -stringWithFormat:@"person%d"
Run Code Online (Sandbox Code Playgroud)

为了方便起见,我可以说我的字典看起来像

NSDictionary *dict=@{@"person1": @"Ilena Jennifer DCruz", @"person2":@"James Bond", @"person3":@"Skylark", @"person4":@"Xan Xiaa Zuang Ming"};
Run Code Online (Sandbox Code Playgroud)

现在,我需要一个只有每个人名字的词典.

我怎么能这样呢?

objective-c ios

1
推荐指数
1
解决办法
4688
查看次数

如何解决"无法在URL加载持久性存储"错误?

当我想通过选择iOS模拟器5.0在Facebook上分享帖子我的应用程序崩溃我不知道如何解决这个问题这里是我的日志消息

2012-12-28 14:55:19.175 SendQuote[2029:3603] Unable to load persistent store at URL 'file://localhost/Users/winsolutions/Library/Application%20Support/iPhone%20Simulator/5.0/Library/Keyboard/UserDictionary.sqlite' ({
    metadata =     {
        NSPersistenceFrameworkVersion = 419;
        NSStoreModelVersionHashes =         {
            UserDictionaryEntry = <f0c9025b 602122f9 37a4e274 bdaacec1 b9a66f83 fca5c43b bed5e80a 6baee338>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "5232202C-AF68-41AA-905F-5B023F1954D4";
        "_NSAutoVacuumLevel" = 2;
    };
    reason = "The model used to open the store is incompatible with the one used to create the store";
})
Run Code Online (Sandbox Code Playgroud)

最后我收到这条日志消息

2012-12-28 14:55:33.822 SendQuote[2029:c07] -[CFXPreferencesSearchListSource tryLock]: unrecognized selector sent …
Run Code Online (Sandbox Code Playgroud)

iphone xcode facebook sharing ios

0
推荐指数
1
解决办法
906
查看次数

从nsmutable数组中删除对象

我通过按钮操作在数组中逐个添加数组中的文本字段,同样我想从最后一个一个一个地删除另一个按钮中的这些文本字段,我该怎么办我使用此代码添加

- (IBAction)btnAddTxtField:(id)sender {
   // [self buttonPressed];
//    currentIndex =0;
//    
//    int x = 132;
//    int y = 550;
//    

//   
//    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake((currentIndex % 1) * x + 45, (currentIndex / 1) * y + 28, 214, 25)];
//    
//    
    textField = [[UITextField alloc] initWithFrame:CGRectMake(76, ([txtFieldArray count] * 30), 191, 25)];
    [textField setBorderStyle:UITextBorderStyleLine];
    textField.font = [UIFont systemFontOfSize:20];
    textField.placeholder = @"Enter text";
    textField.autocorrectionType = UITextAutocorrectionTypeNo;
    textField.keyboardType = UIKeyboardTypeDefault;
    textField.returnKeyType = UIReturnKeyDone;
    textField.clearButtonMode = UITextFieldViewModeWhileEditing; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitextfield nsmutablearray ios

0
推荐指数
1
解决办法
131
查看次数

Xcode 6.1升级 - ViewController不再符合协议WKScriptMessageHandler

WKScriptMessageHandler在我的iOS应用程序中使用来自Webkit的消息.我正在使用该WKScriptMessageHandler协议,但显然在将Xcode升级到最新的6.1升级后,我现在收到此错误消息:

Type 'ViewController' does not conform to protocol 'WKScriptMessageHandler'
Run Code Online (Sandbox Code Playgroud)

关于如何做到这一点的任何想法?为什么Apple会改变这一点

这是我的代码如下:

import UIKit
import WebKit

class ViewController: UIViewController, WKScriptMessageHandler {

    @IBAction func fourButton(sender: UIButton){
        performSegueWithIdentifier("login", sender: self)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func userContentController(userContentController: WKUserContentController!, didReceiveScriptMessage message: WKScriptMessage!){
        println("got message: \(message.body)")
    }

}
Run Code Online (Sandbox Code Playgroud)

xcode webkit ios swift

0
推荐指数
1
解决办法
2110
查看次数

iOS - 委托不工作

我有两个视图控制器,AbcViewControllerXyzViewController.两个控制器的行为类似.每个都有一个"添加"按钮,分别打开一个AddNewAbcViewControllerAddNewXyzViewController.

AddNewAbcViewController,当按钮"提交"被录音时,它会做必要的东西并关闭,然后将其恢复AbcViewController.我在这里使用委托AbcViewController关闭的地方AddNewAbcViewController.这有效.

现在我想为XyzViewController和做同样的事情AddNewXyzViewController,但它不起作用.当调用btnSubmit时AddNewXyzViewController,它没有进入XyzViewControllerdimiss方法.我已多次扫描我的代码,但没有找到任何额外的未添加.我甚至给了一个不同的dismiss方法名称XyzViewController,AddNewXyzViewController但是也没用.我错过了什么?

这是我AbcViewController和我的片段AddAbcViewController.Xyz的代码是相同的:

上课AddNewAbcViewController.h

#import <Foundation/Foundation.h>

// protocol
@protocol AddNewAbcProtocol <NSObject>

-(void)dismiss;

@end

@interface AddNewAbcViewController : UIViewController<UITextViewDelegate>

@property(nonatomic, weak)id<AddNewAbcProtocol> delegate;

@end
Run Code Online (Sandbox Code Playgroud)

上课AddNewAbcViewController.m

@interface AddNewAbcViewController() <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
...
@end

@implementation AddNewAbcViewController

...

- (IBAction)btnSubmit:(id)sender
{
  [self.delegate dismiss];
}
@end
Run Code Online (Sandbox Code Playgroud)

上课AbcViewController.h

#import <Foundation/Foundation.h> …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

0
推荐指数
1
解决办法
1765
查看次数

在 Swift 中完成下载后设置文件名

我正在尝试为 iPhone 开发下载管理器应用程序。我正在使用这个类进行下载操作:

import UIKit
import Foundation

typealias CompleteHandlerBlock = () -> ()

class newDownloadObject: NSObject,NSURLSessionDelegate, NSURLSessionDownloadDelegate {
    var session: NSURLSession!
    var handlerQueue: [String : CompleteHandlerBlock]!

    class var sharedInstance: newDownloadObject {
        struct Static {
            static var instance : newDownloadObject?
            static var token : dispatch_once_t = 0
        }

        dispatch_once(&Static.token) {
            Static.instance = newDownloadObject()
            Static.instance!.handlerQueue = [String : CompleteHandlerBlock]()
        }

        return Static.instance!
    }

    //MARK: session delegate
    func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) {
        println("session error: \(error?.localizedDescription).")
    }

    func URLSession(session: NSURLSession, didReceiveChallenge challenge: …
Run Code Online (Sandbox Code Playgroud)

ios swift

0
推荐指数
1
解决办法
4445
查看次数