ホーム » Xcode

Xcode」カテゴリーアーカイブ

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,350 アクセス



Xcode include

MFC や Windows に依存しないコードのテスト.
今 mac に入っているのは,Xcode Version 6.4.


Project Navigator で,対象のプロジェクトを選択.
検索の所に Search と入力して絞り込み.
Header Search Paths の /Applications/… となっている所をダブルクリック.
「+」で,/Users/Iwao/Public/Dropbox/Develop/_.SRC/__CPR_ などを追加.


VC では,「アクティブプロジェクトに設定」や「スタートアッププロジェクトの設定」にあたるもの.
ビルドや実行対象の変更は,メニューの「Product」-「Scheme」にある.
 以前と変わった?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

xcode + glut

「Command Line Tool」としてプロジェクトを作成.
「GLUT」を追加.


10.9 になったこと?により出力される次の様なワーニングをでない様にするために 10.8 に.
/Users/Iwao/…/main.cpp:116:2: ‘glutInit’ is deprecated: first deprecated in OS X 10.9

インクルードパス設定場所は,「Build Settings」−「Search Paths」−「Header Search Paths」
glut.h のインクルードは以下の様にしている.
  #ifdef __APPLE_CC__
    #include <GLUT/glut.h>
  #else
    #include <GL/glut.h>
  #endif

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

iPhone 3D – 5

110 ページまでやってのエラー.
/…/S_Wire/ApplicationEngine.cpp:57:14: Assigning to ‘ISurface *’ from incompatible type ‘Cone *’

/…/S_Wire/ApplicationEngine.cpp:62:14: Assigning to ‘ISurface *’ from incompatible type ‘MobiusStrip *’
  ParametricSurface.hpp の ParametricSurface の定義で public ISurface が抜けていた.


ApplicationEngine.cpp::: Reference to type ‘const std::vector’ could not bind to an rvalue of type ‘Visual *’
  どうも,107 ページで与えているのが Visual になってるが,vector<Visual> となる様に変更.
  void ApplicationEngine::Render () const {
    vector<Visual> visuals ;
    Visual visual ;
    visual.Color = m_Spinning ? vec3(1,1,1) : vec3(0,1,1) ;
    visual.LowerLeft = ivec2(0,48) ;
    visual.ViewportSize = ivec2(320,432) ;
    visual.Orientation = m_Orientation ;
  // m_RenderingEngine->Render(&visual) ;
    visuals.push_back(visual) ;
    m_RenderingEngine->Render(visuals) ;
  }


今度はリンクエラー   “ES1::CreateRenderingEngine()”, referenced from:
これは,タイプミス.e が抜けている.
IRenderingEngine* CreateRenderingEngine () {
return new RenderingEngine() ;
}

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

iPhone 3D – 4

だいぶ時間が経ったが,
81 ページまでやっていて Cone が表示されない.

モデルビュー行列の設定で,”Modelview” が “ModelView” と大文字のタイプミス.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

typedef … BOOL ;

iOS のプロジェクトでビルドすると,BOOL の定義(typedef int BOOL ;)で,
  /…/i_Define.hxx:30:18: Typedef redefinition with different types (‘int’ vs ‘signed char’)
iPhoneSimulator6.1/usr/include/objc/objc.h に以下が定義されている.
  typedef signed char BOOL;


以下の様に OBJC_BOOL_DEFINED で振り分け.
  #ifdef OBJC_BOOL_DEFINED
  #else
    typedef int BOOL ;
  #endif


i_define.hxx


他にも,Mac 64-bit でビルドすると,long のビット長の問題で幾つかワーニングになる.
いい対応方法が思いつかないので,ひとまず幾つかはそのままとする.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Xcode でのデバッグ?

Xcode でのデバッグ
::To_tstring_rz で,str[index] = sp としていたため.
  sp はデフォルトでは _T(‘\0’) で,_T(‘ ‘) なども指定できるようにしている.
  対応としては,return する前に c_str() とすることにした.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ostrstream の利用でメモリリーク

次の様なコードでメモリリーク.freeze(false) がなかったのが原因.


tstring To_tstring (const double v,const int w=0,const int p=6,const long f=0) {
  tstring str ;
  std::ostrstream strBuf ;
  if (f != 0) {
    strBuf.flags(f) ;
    }
  {
    strBuf.width(w) ;
    strBuf.precision(p) ;
    }
  {
    strBuf << v ;
    strBuf << std::ends ;
    }
  {
    str = strBuf.str() ;
  // strBuf.rdbuf()->freeze(false) ;
    }
  return str ;
  }


Detected memory leaks!
Dumping objects ->
{385} normal block at 0x00038168, 512 bytes long.
Data: < 1.05 > 20 20 31 2E 30 35 00 CD CD CD CD CD CD CD CD CD
{363} normal block at 0x00037F20, 512 bytes long.
Data: <233.50 > 32 33 33 2E 35 30 00 CD CD CD CD CD CD CD CD CD
{339} normal block at 0x00037C70, 512 bytes long.
Data: < 967 > 20 20 20 39 36 37 00 CD CD CD CD CD CD CD CD CD
{315} normal block at 0x00037A28, 512 bytes long.
Data: < 875 > 20 20 20 38 37 35 00 CD CD CD CD CD CD CD CD CD
{291} normal block at 0x000377E0, 512 bytes long.
Data: < 997 > 20 20 20 39 39 37 00 CD CD CD CD CD CD CD CD CD
{269} normal block at 0x00037598, 512 bytes long.
Data: < 1.08 > 20 20 31 2E 30 38 00 CD CD CD CD CD CD CD CD CD
{245} normal block at 0x00037350, 512 bytes long.
Data: < 955 > 20 20 20 39 35 35 00 CD CD CD CD CD CD CD CD CD
{223} normal block at 0x00037108, 512 bytes long.
Data: < 1.15 > 20 20 31 2E 31 35 00 CD CD CD CD CD CD CD CD CD
{201} normal block at 0x00036EC0, 512 bytes long.
Data: < 1.02 > 20 20 31 2E 30 32 00 CD CD CD CD CD CD CD CD CD
{169} normal block at 0x000369B8, 512 bytes long.
Data: < 1.06 > 20 20 31 2E 30 36 00 CD CD CD CD CD CD CD CD CD
{143} normal block at 0x00036770, 512 bytes long.
Data: < 1003 > 20 20 31 30 30 33 00 CD CD CD CD CD CD CD CD CD
Object dump complete.
スレッド 0xDEC 終了、終了コード 0 (0x0)。
プログラム ‘C:\…\DmpFS\Debug\DmpFS.exe’ はコード 0 (0x0) で終了しました。


MSDN strstreambuf::freeze


2013/08/26
上のコードを Xcode でビルドすると,strBuf.flags(f) の所で
    /Volumes/…/t_string.hxx:47:10: No matching member function for call to ‘flags’
  利用する前に fmtflags 型にして利用する様に変更.
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;


2013/08/28
_UNICODE に対応できなかったので,ostringstream を利用する様に変更.
  tstring To_tstring (const double v,const int w=0,const int p=6,const unsigned f_=std::ios::fixed) {
    tstring str ;
  #ifdef _UNICODE
    std::wostringstream strBuf ;
  #else
    std::ostringstream strBuf ;
  #endif
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;
    if (f != 0) { strBuf.flags(f) ; }
    strBuf.width(w) ;
    strBuf.precision(p) ;
    strBuf << v ;
    str = strBuf.str() ;
    return str ;
    }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

CPoint と CGPoint

以前作成した MemoryStatus クラスを利用して,Win , iOS で書いてみた.
MemoryStatus の配列として,MemoryStatusAry を作成.
また,float の配列をそれぞれの点配列に変換する ::GraphGetPoint を用意.


Win
  void CMemSSDView::OnPaint()
  {
    CPaintDC dc(this);
    CRect rect ;
    GetClientRect(rect) ;
    {
      std::vector<float> grphF = MemSA.GetGraph(MemoryStatusAry::WinPhysF) ;
      std::vector<float> grphT = MemSA.GetGraph(MemoryStatusAry::WinPhysT) ;
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::WinPageF) ;
      std::vector<CPoint> pntsF = ::GraphGetPoint(grphF,rect) ;
      std::vector<CPoint> pntsT = ::GraphGetPoint(grphT,rect) ;
      std::vector<CPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      {
        CPen penGreen(PS_SOLID,1,RGB(0,192,0)) ;
        CPen* oldPen = dc.SelectObject(&penGreen) ;
        dc.Polyline(&pntsF[0],pntsF.size()) ;
        CPen penRed(PS_SOLID,1,RGB(192,0,0)) ;
        oldPen = dc.SelectObject(&penRed) ;
        dc.Polyline(&pntsT[0],pntsT.size()) ;
        CPen penBlue(PS_SOLID,1,RGB(0,0,192)) ;
        oldPen = dc.SelectObject(&penBlue) ;
        dc.Polyline(&pntsP[0],pntsP.size()) ;
        dc.SelectObject(oldPen) ;
        }
      }
    }


iOS
  - (void)drawRect:(CGRect)rect
  {
    _context = UIGraphicsGetCurrentContext() ;
    {
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::MacPFree) ;
      std::vector<float> grphA = MemSA.GetGraph(MemoryStatusAry::MacInact) ;
      std::vector<float> grphW = MemSA.GetGraph(MemoryStatusAry::MacWired) ;
      std::vector<CGPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      std::vector<CGPoint> pntsA = ::GraphGetPoint(grphA,rect) ;
      std::vector<CGPoint> pntsW = ::GraphGetPoint(grphW,rect) ;
      {
        [self setColor_r:0 g:192 b:0] ;
        CGContextAddLines (_context,&pntsP[0],pntsP.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:0 g:0 b:192] ;
        CGContextAddLines (_context,&pntsA[0],pntsA.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:192 g:0 b:0] ;
        CGContextAddLines (_context,&pntsW[0],pntsW.size()) ;
        CGContextStrokePath (_context) ;
        }
      }
    }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

UIView のサイズ

MFC の CWnd::GetClientRect にあたるもの?
  drawRect の引数の rect
  self.bounds , self.frame
画面の向きに対して自動的に反映させるには
  self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ;


MoveTo , LineTo
  CGContextMoveToPoint , CGContextAddLineToPoint
  CGPathMoveToPoint , CGPathAddLineToPoint
Polyline
  CGContextAddLines
  CGPathAddLines

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

iPhone 3D – 3

サンプルコードの一部が,ビルド,実行できないでいた.
特に困っていたわけではないが設定箇所と思われる所を見つけたのでメモ.
iPhone 3D
iOS 6.0 に変更することで対応.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

iPhone 3D – 2

71 ページのプロジェクトの名称の変更の場所がわからなかったので,

右上のプロジェクト名の部分を「HelloArrow」から「HelloCone」に打ち直す.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

iPhone 3D

iPhone 3D プログラミング」を読みながら,
29 ページまででビルドすると,
 …/HelloArrow/IRenderingEngine.hpp:26:2: Unknown type name ‘virtual’
   main.m -> main.mm
 実行時,EXC_BAD_ACCESS (code=1, address= 0x60000008)
  P.25 GLView.mm initWithFrame
   displayLink = [CADisplayLink … @selector(drawView:)] ;
   ”:” が抜けていた.
 それでもまだ,三角形は表示されてない.
 続きは後日やる予定


2012/10/08 追記
三角形は表示されず,実行するとピンクの状態.
iPhone 3D pink
デバッガで追いかけると,それなりにコードは通っている.
原因は, RenderingEngine1::Initialize の glBindFramebufferOES が GL_FRAMEBUFFER_OES でなかった.
iPhone 3D Arrow
やっと表示されたが,形状が違う.
これは頂点データの定義のタイプミスなのですぐわかった.


基本的な部分がわかってないので,だいぶ時間がかかってしまった.


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Cocoa Programming for Mac OS X 3 – 3

156 ページのコードを入力してビルドすると,
 int row = [a indexOfObjectIdenticalTo:p] ;
 /…/〜.m:145:12: Implicit conversion loses integer precision: ‘NSUInteger’ (aka ‘unsigned long’) to ‘int’
 最近は,C++ ばかりだったので int() でくくるとエラー.
 int row = int([a indexOfObjectIdenticalTo:p]) ;
 C の (int) とすれば OK.
 int row = (int)[a indexOfObjectIdenticalTo:p] ;


indexOfObjectIdenticalTo を右クリックして「Jump to Definition」
 - (NSUInteger)indexOfObjectIdenticalTo:(id)anObject;
さらに NSUInteger に飛ぶと,
 #if __LP64__ || (…) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
  typedef long NSInteger;
  typedef unsigned long NSUInteger;
 #else
  typedef int NSInteger;
  typedef unsigned int NSUInteger;
 #endif


ソースの拡張子を m から mm に変更することによって,int ( … ) も可能となるみたい.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Mountain Lion ダウンロードとインストール

コンテンツコードは先日取得してあったので,ダウンロードを開始してみた.
OS X 10.8 ダウンロード
30 分位だったか?


ダウンロードが終わるとすぐ,インストールの開始画面となり,そこで止めている状態
OS X 10.8 インストール開始
Install OS X Mountain Lion.app のバックアップを取ろうと思って気が付いたことが,
~.app て,Windows などから見るとフォルダだった?


インストール開始直後,35 分位の表示だったと思うが,結局 1 時間程かかった.
OS X 10.8 インストール終了


2012/09/02 追記
Xcode 4.3 を利用しようとすると,
Xcode 4.4
4.4 が必要なのか?


4.4 にアップデートして,先週やってた exe がビルド,実行できることは確認した.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Cocoa Programming for Mac OS X 3 – 2

「6.7 チャレンジ:デリゲートを作成する」で,追加したクラスを結びつける方法がわからず.
休日のみで身に付けようとすると,ちょっときつい(完全に忘れてしまってる).


ダイアログ上のコントロールとコードを結びつけるのは理解できてるつもり.
VC の「クラスウィザード」などと同じように考えれば良いと思われる.
NSObject のサブクラスがまだ理解できてない.
本で書かれている場所は,91 ページ 「5.3 xib ファイルのレイアウトを行う」.
Xcode xib NSObject
参考にさせてもらったページ
Cocoa Programming: Helper Objects – Challenge: Make a Delegate

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Cocoa Programming for Mac OS X 3

「Mac OS X Cocoa ブログラミング 第 3 版」を読みながら試していて,
14 〜 15 ベージの,「ブランクウィンドウ」の表示方法がわからなかった.
RandomApp BlankWindow


私が今手間取っている情報が書かれてる所があったのでそのリンクです.
http://a-tak.com/blog/2011/08/16/xcode-develop01/
http://a-tak.com/blog/2011/08/22/xcode-develop02/


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

addSubview

iPhone 関係のいい本がわからず,4.3 対応ではないのはわかってたが購入.
UIView を利用して,drawRect に描画コードを記述する様なスタイル.
実行すると何も表示されない.
デバッガで追いかけると,drawRect の部分は呼び出されてる.
追加した UIVew と,ViewController とを関連付ける部分が異なるみたい.
検索すると,UIViewを使って簡単に線を描画する があったので,ここを参考にさせてもらった.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

MFC などと iOS のパーツ

目的が似ていると思われるもの

CStatic   UIView
CHtmlView   UIWebView
MSXML.dll   NSXMLParser
レジストリ   NSUserDefault
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Objective-C

買った本を参考にしながら,NSArray を使用.
NSArray* ary = [NSArray arrayWithObject:[…],[…],…,nil] ;
と入力して,複数の要素を指定しているという様なエラー.
よーく確認すると,本の方は arrayWithObjects と最後に s が付いた複数指定のタイプ.
Xcode が補完してくれるのはいいが,間違って選択してエラーになると,原因を見つけるのがちょっと大変?


他にもタイマの利用で,タイマ処理関数名の直後の ” : ” も抜けていた.
  [NSTimer scheduledTimerWithTimeInterval:0.05 target:self
     selector:@selector(moveLabel:) userInfo:nil repeats:YES ] ;


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Xcode での設定?

ヘッダなどのインクルードパスの設定.
 プロジェクトを選択して,Search Path に Header と Library の設定がある.
 VC 6 などの様な,「ツール」−「オプション」−「ディレクトリ」タブにある共通の設定の有無や方法は不明.
Xcode Search Path


デバッグ時のブレイクポイントの設定やステップ実行など.
 ソースの左の方の行番号付近のクリック.
 「fn」+F6 , F7 , F8 はまだいいが,継続の実行がちょっといまいち.
    「control」+「command」+「Y」

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.