Automatic Reference Counting (ARC) in Xcode 4.2

September 3rd, 2011 aspgod No comments

ARC = Automatic Reference Counting is a new feature that come with Xcode 4.2. From the Apple iOS 5 developer page wrote “Automatic Reference Couning (ARC) for Objective-C makes memory management the job of the compiler. By enabling ARC with the new Apple LLVM compiler, you will never need to type retain or release again, dramatically simplifying the development process, while reducing crashes and memory leaks. The compiler has a complete understanding of your objects, and releases each object the instant it is no longer used, so apps run as fast as ever, with predictable, smooth performance.“.

So that mean you don’t have to release object anymore. But the problem is “If I want to manage the memory by myself. What should I do?” Let’s follow this.

1. Click on the Project.
2. Click on the target.
3. Select build phases tab.
4. Select the multiple files in which you want to turn off ARC
5. Press ENTER / Hit Enter key
6. Type “-fno-objc-arc” ( without quotes, as shown in image ).

Or see this video.

Hope this article be useful to you.

credits:
http://sugartin.info/2011/08/10/ios5-how-to-turn-off-arc-on-individual-files/
http://developer.apple.com/technologies/ios5/

 

Using JSON with Google Data APIs

August 10th, 2011 aspgod No comments

สำหรับบางคนที่ต้องการเขียนโปรแกรมไปเรียกใช้ API ของ Google หรือ Youtube ก็ตาม สามารถเรียกข้อมูลมาเป็น XML หรือ JSON ก็ได้
ตัวอย่างข้อมูล Link ที่ใช้เรียก API เช่น

https://gdata.youtube.com/feeds/api/users/dreamusic/uploads

ให้เราใส่ query string ตามหลังไป ?alt= โดยพารามิเตอร์ก็จะมี atom, rss, json, json-in-script, and jsonc. ในที่นี้ให้ใช้ json

https://gdata.youtube.com/feeds/api/users/dreamusic/uploads?alt=json

ก็จะได้ข้อมูลออกมาเป็น json แต่สำหรับใครที่เรียกใช้งาน API นี้ด้วย Javascript ก็จะติดปัญหา Cross Domain ให้แก้ด้วยการใส่เป็น json-in-script

https://gdata.youtube.com/feeds/api/users/dreamusic/uploads?alt=json-in-script

สามารถดูตัวอย่างโค๊ดที่เรียกใช้งานได้ตามนี้ครับ http://code.google.com/apis/gdata/docs/json.html

Categories: API Tags: , ,

Get Youtube Videos uploaded by a specific user

July 18th, 2011 aspgod No comments

user uploaded youtube api

มาว่ากันด้วยเรื่องของ Youtube API กันต่อ มาคราวนี้เป็นการเรียกดูว่า user คนนี้ได้เคย upload วีดีโออะไรไว้บ้าง เช่น เราอยากจะรู้ว่า user ที่ชื่อว่า dreamusic เคย upload อะไรไว้ ก็สามารถ feed ข้อมูลได้จาก

https://gdata.youtube.com/feeds/api/users/username/uploads

ให้เปลี่ยน username เป็นชื่อ user ที่เราต้องการ

https://gdata.youtube.com/feeds/api/users/dreamusic/uploads

แล้วก็เขียนโปรแกรมเข้าไปอ่าน xml ได้ตามสะดวก

 

Categories: API, Internet Technology Tags: ,

Retrieve Single Youtube Video Information

July 14th, 2011 aspgod No comments

Youtube API from Facebook wall

ต่อเนื่องมาจากการใช้งาน Youtube API นี่เป็นวิธีการในดึงข้อมูลของ Youtube Video มาใช้งาน เช่น title, description, thumbnail etc. คล้ายๆกับการเอา link ดูวีดีโอของ youtube ไป comment ใน facebook

ให้ลองเรียก url นี้ดูครับ

https://gdata.youtube.com/feeds/api/videos/videoid?v=2

โดยเปลี่ยน videoid เป็น _sMoVgdplPc (youtube video id)

https://gdata.youtube.com/feeds/api/videos/_sMoVgdplPc?v=2

ถ้าเปิดด้วย firefox จะเห็นได้ชัดกว่านะครับ จะเป็น xml มีรายละเอียดของ video นั้นๆครบครับ เอาไปใช้งานได้ตามแต่ใจต้องการเลย

 

Categories: API, Internet Technology Tags: , ,

Youtube API for Developer

July 14th, 2011 aspgod No comments

Youtube API Google Code

เมื่อเร็วๆนี้ได้รับมอบหมายให้ศึกษาเกี่ยวกับ Youtube API จึงได้ลองหาข้อมูลดู ก็พบว่ามีอะไรหลายๆอย่างน่าเอาไปใช้เล่น โดยการเขียนโค๊ดเพื่อไปเรียก Youtube API แล้วได้ข้อมูลต่างๆมา เช่น Single Video Information, Categories Information etc. สามารถหาข้อมูลเพิ่มเติมได้ตามนี้เลยครับ Youtube API

เขียนไว้กันลืม แต่ถ้ามีประโยชน์กับใคร ก็ยินดีครับ ^ ^

Categories: API, Internet Technology Tags: ,

Xcode Keyboard Shortcuts

July 7th, 2011 aspgod No comments

สิ่งหนึ่งที่ programmer ควรจดจำไว้เวลาเขียนโปรแกรม เพื่อให้การพัฒนาเป็นไปด้วยความรวดเร็วมากยิ่งขึ้น คงจะหนีไม่พ้นคำว่า Shortcuts อย่างแน่นอน ไม่ว่าเราจะใช้ Microsoft Visual Studio / EditPlus / eclipse สำหรับครั้งนี้ขอเสนอ Shortcuts สำหรับผู้พัฒนาที่ใช้ Xcode ลองดูจากภาพ แล้วศึกษาดูนะครับ อาจช่วยให้การเขียนโปรแกรมมีความสุขขึ้น ไม่มากก็น้อยล่ะครับ

 

Xcode Shortcuts

Credits : http://cocoasamurai.blogspot.com/2008/02/complete-xcode-keyboard-shortcut-list.html

Categories: Apple Tags: ,

Hello World! from iPhone

July 7th, 2011 aspgod No comments
Hello World iPhone

Hello World iPhone

ในที่สุดก็ได้ say “Hello World!” ในเวอร์ชั่นนี้ซักที ต่อไปนี้ก็เป็นเรื่องของการฝึกฝนและความพยายามแล้วล่ะ แล้วรอชมผลงานถัดไปนะครับ
ป.ล.ซื้อ iPhone กันเถอะครับ 55+

 

Categories: Apple Tags: ,

Setup Timestamp to Table in SQL Server

June 3rd, 2011 aspgod No comments

ปกติแล้วเกือบทุก table จะต้องการใช้ Timestamp ส่วนมากจะ insert ใส่กันไปเองด้วย coding หรือ stored procedure แต่ก็มีวิธีที่ทำให้เราไม่ต้องเข้าไปยุ่งกับมันเลย เพราะยังไงเวลาที่ต้องการ stamp ก็คือเวลาปัจจุบันอยู่แล้ว

1. เริ่มแรกให้เราสร้าง field ที่เป็นประเภท datetime

2. เซ็ต Column Properties ให้ Default Value เป็น getdate() เพื่อเป็นการ auto timestamp

3. ให้ลอง insert ข้อมูลโดยไม่ใส่ create_date ก็จะพบว่าผลลัพธ์ถูกใส่ timestamp มาให้แล้วโดยอัตโนมัติ

หวังว่าข้อมูลนี้คงมีประโยชน์ไม่มากก็น้อยนะครับ

Categories: SQL Server Tags: , ,

jQuery Validator Configure Manual Message and Rule

April 29th, 2010 aspgod 4 comments

ปกติแล้ว jQuery Validator มี default message สำหรับกรณีต่างๆไว้อยู่แล้ว แต่แน่นอนว่าการใช้งานโดยทั่วไปของหลายๆคน ต้องการใช้ข้อความในการเตือนที่แตกต่างกันไป

jQuery Validator Manual Message Rule

Read more…

Configure MIME types to Support FLV Files (windows server)

April 18th, 2010 aspgod No comments

เหตุมันเกิดเมื่อ windows server ไม่สามารถแสดงผลไฟล์ประเภท .flv ได้ จึงต้องทำการ configure MIME types เพื่อให้ support .flv

มีวิธีการดังต่อไปนี้
1. เปิด IIS ขึ้นมา (Start > All Programs > Administrative Tools > Internet Information Services (IIS) Manager)
2. คลิกขวาที่ local computer -> properties จากนั้นกดปุ่ม MIME Types…

MIME FLV

3. จะมีหน้าต่างขึ้นมาใหม่ ดูที่กล่อง Registered MIME Types (file extensions) ว่ามี .flv หรือไม่ ถ้าไม่มีให้คลิก New… จากนั้นใส่ข้อมูลตามนี้
Extensions: .flv
MIME type: flv-application/octet-stream

MIME types FLV

4. ไปที่ Services (Go Start > All Programs > Administrative Tools > Services) เพื่อ restart “World Wide Web Publishing Service”

MIME types FLV

5. รอจน restart เสร็จ จากนั้นก็ใช้งาน .flv ได้ละครับ

ขอบคุณ
dvdvideosoft

หวังว่าข้อมูลนี้จะมีประโยชน์นะครับ

Categories: Windows Server Tags: ,