Archive for the 'Cocoa' Category

how to – 用php抓取iTunes Store的搜索结果

星期六, 八月 6th, 2011

从iTunes Store中copy出来的链接无法直接在浏览器中打开,google之,有人已经用php+curl做了相关工作,只要在http header中加上一个参数即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function htmlForiTunesStoreURL($path)
// Download and return the HTML for an iTunes Store page at the given URL.
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $path);
 
    // The following header is what causes the server to think we are iTunes.app.
    // This header in particular is for the China Store.
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Apple-Store-Front: 143465-19,12'));
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $html = curl_exec($ch);
 
    return trim($html);
}

其中X-Apple-Store-Front: 143465-19,12,143465是中国的iTunes Store代码,-19,12不知道什么意思,这是用截取http封包的工具截出来的,-19的位置是语言代码,但网上搜索不到中文代码是什么,也许就是19

以下是其他国家的代码:

United States 143441
Argentina 143505
Australia 143460
Belgium 143446
Brazil 143503
Canada 143455
Chile 143483
China 143465
Colombia 143501
Costa Rica 143495
Croatia 143494
Czech Republic 143489
Denmark 143458
Deutschland 143443
El Salvador 143506
Espana 143454
Finland 143447
France 143442
Greece 143448
Guatemala 143504
Hong Kong 143463
Hungary 143482
India 143467
Indonesia 143476
Ireland 143449
Israel 143491
Italia 143450
Korea 143466
Kuwait 143493
Lebanon 143497
Luxembourg 143451
Malaysia 143473
Mexico 143468
Nederland 143452
New Zealand 143461
Norway 143457
Osterreich 143445
Pakistan 143477
Panama 143485
Peru 143507
Phillipines 143474
Poland 143478
Portugal 143453
Qatar 143498
Romania 143487
Russia 143469
Saudi Arabia 143479
Schweitz/Suisse 143459
Singapore 143464
Slovakia 143496
Slovenia 143499
South Africa 143472
Sri Lanka 143486
Sweden 143456
Taiwan 143470
Thailand 143475
Turkey 143480
United Arab Emirates 143481
United Kingdom 143444
Venezuela 143502
Vietnam 143471
Japan 143462

关于第二位数字的解释
1: English
2: English (slightly different texts)
3: French
4: German
5: French (slightly different texts)

现在可以就可以正常获得数据了,如

1
2
3
echo htmlForiTunesStoreURL(
"http://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/advancedSearch?startIndex=180&entity=software&media=software&page=2&restrict=true&free=1&genreIndex=10"
);

How to – install Apache, PHP and Mysql on Mac XOS

星期三, 七月 27th, 2011

本文采用的方式是使用Mac OS X 10.5.6自带的Apache和PHP,安装MySQL的dmg版本,以下操作非特殊说明均以root用户在命令行下进行。

  启用root用户

  1.打开“目录实用工具”,它位于“应用程序”文件夹的“实用工具”文件夹中。

  2.点按锁图标以进行更改。您将需要输入管理员名称和密码。

  3.选取“编辑”>“启用 Root 用户”。

  4.为 root 用户输入安全密码,然后在“验证”栏再次输入它,最后点按“好”。

  启用Apache

  Mac OS X 10.5.6自带了Apache 2.2.9,直接在命令行运行apachectl start,Apache就搞定了。

  现在Apache的主目录就是/Libary/WebServer/Documents/,你可以在这目录里放置文件测试了。

  启用PHP

  Mac OS X 10.5.6自带了PHP 5.2.6,我们需要做的就是将PHP加入Apache中。

  修改/etc/apache2/httpd.conf中的

  #loadModule php5_module libexec/apache2/libphp5.so

  为

  loadModule php5_module libexec/apache2/libphp5.so然后将/etc/php.ini.default复制为/etc/php.ini。

  cp /etc/php.ini.default /etc/php.ini之后就可以按照自己的习惯修改php.ini的配置

  比如将error_reporting = E_ALL & ~E_NOTICE

  修改为

  error_reporting = E_ALL最后,重启Apache,可以在/Libary/WebServer/Documents/目录中建立个phpinfo.php来测试了。

  apachectl restart

安装Mysql

How to – build libcurl in xcode4 for iphone

星期二, 七月 26th, 2011

Download CURL source from:http://curl.haxx.se/download.html

1
2
3
4
5
6
7
tar -xvzf curl-7.21.2.tar.gz
cd curl-7.21.2
export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.0.1
export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk"
export LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk"
export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10

By configuring with isysroot and syslibroot set the correct SDK, the CURL_SIZEOF_LONG and SIZEOF_LONG will get set to the correct value (4).
In Xcode, choose File->New Project->iOS->Library->Cocoa Touch Static Library.
Add->Existing Files (select curl’s “src” folder)
Add->Existing Files (select curl’s “lib” folder)
Remove “src/macos” folder from project. (Delete->Delete references)
Unselect Makefile and Makefile.inc checkboxes for target.
In “Build” tab search for OTHER_CFLAGS and add the following options:
-DHAVE_CONFIG_H -I/ca/dev/code/lib/curl/curl-latest/include -I/ca/dev/code/lib/curl/curl-latest/lib
Replace /ca/dev/code/lib/curl/curl-latest with the path at which you untarred the CURL source.
Build both Simulator/Release and Device/Release.
To make a universal library for both the simulator and the device, execute lipo from the command line of the Xcode project folder:

lipo -create build/Release-iphonesimulator/libcurl.a build/Release-iphoneos/libcurl.a -output libcurl.a
The last step is to add libCURL to your app by right-clicking (or option-clicking) Frameworks->Add->Add Existing Frameworks…->Other and choosing the libCURL.a file created by lipo.
In attachment You can find project and compiled lib.
the original resource – http://www.creativealgorithms.com/blog/content/building-libcurl-ios-42
Source code: Download

注意替换相应的路径
编译后的文件在
~/Library/Developer/Xcode/DerivedData/curl-aaqusppogmokgpgnggbgmkotqydh/Build/Products
(假设你的target名字是curl)
另外这里没写的
1.在search path里把curl/include加进去
2.修改build scheme,将build类型改成release

原文:http://blog.ideas-world.com/2011/03/14/building-libcurl-for-ios-4-2/(须翻墙)
还有一篇:http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/

pokeb / asi-http-request

星期日, 七月 24th, 2011

https://github.com/pokeb/asi-http-request/tree

enormego.com

星期日, 七月 24th, 2011

http://developers.enormego.com/

enormego cocoa helper

星期日, 七月 24th, 2011

https://github.com/enormego/cocoa-helpers

SVSegmentedControl

星期日, 七月 24th, 2011

https://github.com/samvermette/SVSegmentedControl

TapKuLibrary

星期日, 七月 24th, 2011

这是一个IOS UI库,有一些UI界面的解决方案

https://github.com/devinross/tapkulibrary#readme

在Project中使用

Clone the TapkuLibrary git repository: `git clone git://github.com/devinross/tapkulibrary.git`. Make sure you store the repository in a permanent place because Xcode will need to reference the files every time you compile your project.
Locate the src/TapkuLibrary.xcodeproj and src/TapkuLibrary.bundle and add these to your XCode project (Figure 1). (use ‘Add files to project’ from ‘File’ menu instead of dragging and dropping, to prevent crash when adding target dependency in next step. c.f. Xcode 4 bug)

Figure 1
Select your main Xcode project from the sidebar in Xcode and then select the project target. Select the Build Phases tab.
Under the Target Dependencies group, click the plus button, select TapkuLibrary from the menu, and choose Add. (Figure 2)
Under the Link Binary With Libraries group, click the plus button, select libTapkuLibrary.a from the menu, and choose Add. Also add MapKit and QuartzCore. (Figure 2)

Figure 2
Choose the Build Settings tab. Make sure All in the top left of the bar under the tabs. Add the path to the src folder to Header Search Path (do not click the Recursive checkbox). Add -all_load -ObjC to Other Linker Flags.

UIPageControl例子

星期三, 七月 20th, 2011

http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
PageControlExample

how to – 自定义NavigationBar

星期五, 七月 8th, 2011

http://stackoverflow.com/questions/2259929/iphone-navigationbar-custom-background

https://discussions.apple.com/thread/1649012?threadID=1649012&tstart=0