• 締切済み

【Objective-c 】XMLパースについて

皆様 いつもお世話になります。 早速ですが、質問させて頂きます。 xmlをパースするために「XML-to-NSDictionary」というライブラリを使いたいと思っています。 (ライブラリ:https://github.com/bcaccinolo/XML-to-NSDictionary) インポートし、ビルドしたところ以下の場所にエラーが出てしまいます。 【エラー】 XmlReader.h の NSError **errorPointer; のところに 「Pointer to non-const type 'NSError *' with no explicit ownership」 XML-to-NSDictionaryの導入/実行に関しては、 XmlReader.hをAppDelegate.hにimportし、AppDelegate.mで以下ソースを記述しました。 【ソース】 NSError *parseError = nil; NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:dataString error:&parseError]; NSLog(@"%@", xmlDictionary); googleで調べたところ、「__autoreleasing」を入れればいいということがわかり、 NSError **errorPointer; を NSError __autoreleasing **errorPointer; としたところ、 さらにエラーが増えてしまいました。 どなたかお詳しいかたご教授のほど宜しくお願い致します! 環境: MacOSX10.8.5 XCode5.0

みんなの回答

回答No.1

__autoreleasing NSError **errorPointer;

takachipo
質問者

お礼

ご回答有り難うございます! 教えて頂いた方法で行ったのですが、エラー内容は変わりませんでした。。 また機会がありましたら是非宜しくお願い致します。

takachipo
質問者

補足

以下のサイトを参考に解決致しました。 http://qiita.com/myaaaaa_chan/items/3572369217e4398c8b52 ARCを有効にしていると出るエラーだということが分かりました。

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • Objective-cでNSLogが使えない

    Objective-cのNSLogで標準出力に出力したいのですが、 どうにもうまくいきません。 ソース $ cat oshiete.m #import <Foundation/Foundation.h> int main(int argc,const char * argv[]) {   NSLog(@"Hello World!");   return 0; } コンパイル $ clang -lgnustep-base -lobjc -I/usr/include/GNUstep -I/usr/lib/gcc/i486-linux-gnu/4.4/include -g -Wall oshiete.m -o oshiete 実行 $ ./oshiete Segmentation fault OSはUbuntu 10.04.1 LTSで、コンパイラはclangを使用しています。 gdbでステップ実行すると、NSLog実行時に以下のエラーが得られました。 Program received signal SIGSEGV, Segmentation fault. 0xb7c52e46 in __objc_get_forward_imp () from /usr/lib/libobjc.so.2 Objective-cが良く理解できてないのですが、Gnustepライブラリとリンクして 動作しているはずなので、そこの動きがよくない?? コンパイルでのエラーや警告は0件です。 自力での解決が困難です。 どなたかお力添えをお願いいたします。

  • objectiv-cで困っています。教えてください

    objectiv-cの勉強を始めたばかりです。ネットで調べながら進めているのですが、プロジェクト内のテキストファイルではなく、サーバにあるテキストファイルの内容を読み込み、NSLogに出力しようとしているのですが、うまくいきません。xxxxxxxxxxxの部分にテキストファイルのあるURLを入れています。 -----------------textloadViewController.h------------------------------ #import <UIKit/UIKit.h> @interface textloadViewController : UIViewController @end -----------------textloadViewController.m------------------------------ #import "textloadViewController.h" @interface textloadViewController () @end @implementation textloadViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. NSError *error = nil; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"xxxxxxxxxxx" ofType:@"txt"]; NSString *string = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error]; NSLog(@"%@", string); } @end 外部のテキストファイルを読み込む方法を教えてください。よろしくお願いします。

  • objective-C(Xcode)に関して質問があります。

    objective-C(Xcode)に関して質問があります。 新規プロジェクトからview-base Applicationテンプレートを使用してプロジェクト(TestClass.xcodeproj)を作成します。 そうすると、TestClassAppDelegate.m, TestClassAppDelegate.h, TestClassViewController.h, TestClassViewController.mが Classesフォルダーに作成されます。このプロジェクトに自分で作成するクラス(MyTestClass)を追加するにはどうすれば良いのでしょうか? 下記のコードではエラーはでませんが、tc.counterにint 10が代入さず、0(nil)が出力されます。 (interfacebuilder でボタンのみ設置、ボタンを押すとpushが呼ばれ、logを残す) ===MyTestClass.h===== #import <Foundation/Foundation.h> @interface TestClass : NSObject { int counter; } @property int counter; @end ===MyTestClass.m===== #import "TestClass.h" @implementation TestClass @synthesize counter; -(int)calcPlus{ return counter = counter+10; } @end ===TestClassViewController.h==== #import <UIKit/UIKit.h> #import "TestClass.h" @interface TestClassViewController : UIViewController { TestClass *tc; } -(IBAction) push; -(void)calc; @end ===TestClassViewController.m=== #import "TestClassViewController.h" #import "TestClass.h" @implementation TestClassViewController -(IBAction)push{ tc.counter = 10; NSLog(@"%d", tc.counter); } サンプルコード(iPhoneUnitTests ((calc)))をみても、特別なことはなく、ヘッダーの読み込みさえ出来てれば クラスが使えそうなのですが・・・。 コメントをいただければ、幸いです。

  • objective-c

    初心者です。よかったら、どなたかお答えをおねがいします。 #import <Foundation/Foundation.h> int main (void) { const char *words[] = {"asldkfj",";ljasdf",";lkasj","ioisdji"}; /ここ/ int charsize; charsize = sizeof(words) / sizeof(words[0]); int i; for(i = 0; i < charsize ;i++){ NSLog(@"%s is %d characters long",words[i],strlen(words[i])); } return 0; } 上記のソースでは、wordsがポインタ変数になってますが、配列で、 const char words[] = {"asldkfj",";ljasdf",";lkasj","ioisdji"}; にするとエラーがでます。 配列にすると、要素数は判別できるが、文字数は判別できないってことでしょうか? そうだとしたら、理由を教えてください。 よろしくお願いします。

  • [Objective-c] NSlogとループ

    Objective-cの勉強を始めたばかりです。 ループ処理内のNSlogについて質問させてください。 下の方にあるソースコードにて実行すると、 何回かに1回なのですがループが最後まで回らずNSlogにて 最後まで出力されない。 ( 変数aの値は32です のように途中までしか出力されない、  一番最後までループすれば 変数aの値は1024です が出力されて  ループを抜けるはずです。) MacOSX10.7.4 Core i5 2.2GHz Xcode 4.3.2 そこで下記複数質問があります。 1.内部でどんなエラーが起こっているのでしょうか?  (メモリー確保・解放ができていない?   前回処理が完了する前に次の処理を実行しようとしている?) 2.下部ソースのコメントアウトにインターバル(sleepForTimeInterval)を  もうける処理がありますが、これをコメントはずして実行すると、  何度実行しても最後まで出力されるようになりました。  このような処理を入れるのが当たり前なのでしょうか? #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... int a=1; for(;a<1000;a=a*2) { // [NSThread sleepForTimeInterval:0.005]; NSLog(@"変数aの値は%dです\n",a); } } return 0; } 以上、よろしくお願いいたします。

  • Objective-Cでのエラー

    よろしくお願いします。「Xcode5ではじめるObjective-Cプログラミング(大津真著)」という本を購入し、Objective-Cの勉強をはじめました。Objective-Cが初めてのプログラミング初心者です。 本に記載されたコードを入力しているのですが、下記でエラーが出て困っています。 何度も見なおしたのですが本との違いを見つけることができませんでした。 どこがおかしいのかお分かりの方がおられましたらどうか教えて下さい。 ●エラー more '%' conversions than data arguments が、下記の2箇所で出ます。(いずれも生年月日の前の@ に矢印がでています。) >NSLog(@"%@ 生年月日:%@, 身長:%.1fcm"), >NSLog(@"%@ 生年月日:%@, 身長:%.1fcm"), 実行すると Thread 1:EXC_BAD_ACCESS(code=EXC_1386_GPFLT) とでます。 ---------- // main.m #import <Foundation/Foundation.h> #import "Person.h" int main(int argc, const char * argv[]) { @autoreleasepool { Person *personA = [[Person alloc]init]; [personA setName:@"吉田一郎"]; NSDate *dateA = [NSDate dateWithString:@"1979-11-12 00:00:00 +0900"]; [personA setBirthday:dateA]; [personA setHeight:180.5]; NSLog(@"%@ 生年月日:%@, 身長:%.1fcm"), [personA name], [personA birthday], [personA height]; Person *personB = [[Person alloc]init]; [personB setName:@"山田太郎"]; NSDate *dateB = [NSDate dateWithString:@"1981-03-01 00:00:00 +0900"]; [personB setBirthday:dateB]; [personB setHeight:172.3]; NSLog(@"%@ 生年月日:%@, 身長:%.1fcm"), [personB name], [personB birthday], [personB height]; } return 0; } ---------- // Person.h #import <Foundation/Foundation.h> @interface Person : NSObject -(void)setName:(NSString *)name; -(NSString *)name; -(void)setBirthday:(NSDate *)birthday; -(NSDate *)birthday; -(double)height; -(void)setHeight:(double)newValue; @end ---------- // Person.m #import "Person.h" @implementation Person { NSString *_name; NSDate *_birthday; double _height; } -(void)setName:(NSString *)aName { _name = aName; } -(NSString *)name { return _name; } -(void)setBirthday:(NSDate *)aBirthday { _birthday = aBirthday; } -(NSDate *)birthday { return _birthday; } -(void)setHeight:(double)aHeight { _height = aHeight; } -(double)height { return _height; } @end

  • objective-c のインスタンスについて教えていただきたいのですが

    初心者なのですみません。 ご存知の方教えていただきたいのですが、 例えばaインスタンスがbクラスをインスタンス化して bインスタンスがcクラスをインスタンス化して aインスタンスがcクラスをインスタンス化しないで bインスタンスがインスタンス化したcインスタンスに メソッド送信のようなことが したいのですがうまくいきません。 どのようにすればよいですか? よろしくお願いします (aインスタンスがcクラスをインスタンス化した場合、bインスタンスがcクラスをインスタンス化したものと同じもの(アドレスが同じ?)なものなのでしょうか?違いますよね?ようするにストレージクラスやNSDataなどインスタンスの中のデータを複数のインスタンスから取り出したいのです) 面倒でスミマセン。 以下は確認のために簡易的に作ったものです。 文字数多すぎなのでinterfaceは省きました #import "Aobject.h" #import "Bobject.h" #import "Cobject.h" @implementation Aobject - (IBAction)callb:(id)sender { id Bobj = [[Bobject alloc]init]; [Bobj make]; [Cobj log]; //ここでエラーが出ます(`Cobj' undeclared (first use in this function) (Each undeclared identifier is reported only once for each function it appears in.)) } @end //-------------------------------------- #import "Bobject.h" #import "Cobject.h" @implementation Bobject - (void)make { id cobj = [[Cobject alloc]init]; } @end //-------------------------------------- #import "Cobject.h" @implementation Cobject - (void)log { NSLog(@"ok"); } @end

    • ベストアンサー
    • Mac
  • Objective-c 画像処理

    Cについては、全くの素人です。 「Xcodeプログラミング大全」という書籍を参考に、開発を進めているのですが、行き詰まってしまったので、質問させて下さい。 ImageKitを使ったイメージブラウザを作成して、取り込んだ画像を別名で別の場所に保存するプログラムを作成しています。 前半部は文字数の関係で省略します。 ボタンをクリックして画像を保存します。 - (IBAction)myButton:(id)sender; { // imagebrowserに保存した画像を順番に処理 for(int i=0; i< [myImages count]; i++){ NSData *data = nil; NSString *errorDescription; //NSPasteboard *pasteboard = [myImages objectAtIndex:i]; if([[[myImages objectAtIndex:i] types] containsObject:NSFilenamesPboardType]) data = [[myImages objectAtIndex:i] dataForType:NSFilenamesPboardType]; if(data){ NSArray *filenames = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:kCFPropertyListImmutable format:nil errorDescription:&errorDescription]; for(int j=0;j< [filenames count];j++){ //NSLog(@"%@",[filenames objectAtIndex:j]); NSBitmapImageRep* bitmap = [myImages objectAtIndex:i]; // 画像保存 NSData* outdata = [bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES); NSString* path = [NSString stringWithFormat:@"%@/test.png",[paths objectAtIndex:0], nil]; [outdata writeToFile:path atomically:YES]; / } } } } @end エラーは発生しないのですが、コンソールに「[MyImageObject types]: unrecognized selector sent to instance 0xf722590」と表示されます。 また、画像は全く保存されません。 どなたか、ご教授をお願いします。

  • Objective-C,viewが動作しない

    IBを使わないカメラアプリを作っています。 AppDelegate.m内のapplication didFinishLaunchingメソッド内で生成したwindowとviewはコンパイルして表示確認できたのですが、viewControllerで書いたUIImagePickerViewControllerのviewが出てきません。 そもそもviewController.mのloadViewメソッドやviewDidLoadメソッドが動いていません。(メソッド内にNSLogを書いてコンパイルしてもログに出ない) viewController.h #import <UIKit/UIKit.h> @interface CameraViewController : UIViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate> { @private UIImagePickerController* _imagePicker; } @property(nonatomic,retain) UIImagePickerController *imagePicker; @end viewController.m #import "CameraViewController.h" @implementation CameraViewController @synthesize imagePicker=_imagePicker; - (void)dealloc { [super dealloc]; } #pragma mark - View lifecycle - (void)loadView { [super loadView]; //UIImagePickerControllerの作成 if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ return; } UIImagePickerController* imagePicker; imagePicker = [[UIImagePickerController alloc] init]; [imagePicker autorelease]; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.allowsEditing=NO; imagePicker.delegate = self; //imagePickerのviewを最上部に [self presentModalViewController:imagePicker animated:YES]; //シャッターを切る [self.imagePicker takePicture]; } @end viewControllerが機能しない原因としてそういった可能性が考えられるのでしょうか? あれこれ調べてみましたが煮詰まっています。よろしくお願いします

  • Objective-C グローバル変数 値変更反映

    当方、Objective-Cに関して1年にも満たない経験を持つ初心者です。 初歩的な内容だとは思いますが行き詰まってしまったため質問させて下さい。 複数の.hと.mファイルで定義された複数クラス間で一つの変数を共通で利用し、あるクラスのメソッド内で値を変更した際にそれ以外のクラスですぐに反映出来る様にしたいのですが、どの様に書いても値が反映されず初期値のまま出力されてしまいます。恐らく各クラス内のメソッドが呼ばれる順番に起因すると思うのですが、上手く解決出来ません。 現在書いているコードとして、 -xxxAppDelegate.h (at)interface xxxAppDelegate : NSObject <UIApplicationDelegate> { ... int globalNum; } (at)property(nonatomic, assign)int globalNum; (at)end -xxxAppDelegate.m ... (at)implementation xxxAppDelegate (at)synthesize globalNum; ... (at)end -A.h ... (at)interface AController : UIViewController { xxxAppDelegate *appDelegate; } ... -(void)changeNum; -(IBAction)changeController; (at)end -A.m ... (at)implementation AController ... - init(){ appDelegate = (xxxAppDelegate *)[[UIApplication sharedApplication] delegate]; } ... -(void)changeNum{ //ここでglobalNumの値を変更; appDelegate.globalNum=...; } ... //配置したボタンを押すとA->BにviewControllerを切り替える -(IBAction)changeController{ BController *B = [[BController alloc] initWithNibName:(at)"BController" bundle:nil]; B.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:B animated:YES]; [B release]; } ... (at)end -B.h ... (at)interface BController : UIViewController { xxxAppDelegate *appDelegate; } ... -(void)readNum; (at)end -B.m ... (at)implementation BController ... - init(){ appDelegate = (xxxAppDelegate *)[[UIApplication sharedApplication] delegate]; } ... -(void)readNum{ //globalNumの値を見る; NSLog((at)"%d" , appDelegate.globalNum); } ... (at)end となっています。( (at)=アットマークです。 ) xxxAppDelegateおよびxxxViewControllerよりAControllerを呼び出し、AクラスのchangeNumメソッドでglobalNumの値を変更した後、ボタンを押下してviewControllerをBControllerに切り替え、Bクラス内のreadNumメソッドでglobalNumの値を確認すると、変更が反映されていない事が分かります。 この方法以外にも色々と試してみたのですが、すっきりとしたコードが書けず、解決に至りませんでした。 申し訳ありませんが、皆さんの知恵をお貸し下さい。 よろしくお願いします。

このQ&Aのポイント
  • ELECOM ウイルス対策USB MF-TRU**GBKを使用している際、動作時間が異常にかかる問題が発生しています。解決方法はありますか?
  • ELECOM ウイルス対策USB MF-TRU**GBKを使用している際の動作が遅い問題について、解決方法を教えてください。
  • ELECOM ウイルス対策USB MF-TRU**GBKの動作時間が異常に長くなってしまう問題が発生しています。解決策を教えてください。
回答を見る