-(id) 就是 Objective-C 中的 object, 本身就是帶一個 pointer 所以不用再加 *
-(id)initWithName:(NNString *)name andAge:(int)age{
id result = [super init];
if(result){
self.name = name;
self.age = age;
local sm = require("statemachine") | |
local process = sm.new(function(self, time) | |
local txt = display.newText( "Press Me", display.contentCenterX, display.contentCenterY, native.systemFont, 32) | |
txt:addEventListener("touch", function(evt) | |
self:continue() | |
end) | |
self:waiting() | |
txt.text = "Hello!" | |
end) |
local sm = require("statemachine") | |
local process = sm.new(function(self, time) | |
self:sleep(100) | |
print("hello") | |
self:sleep(100) | |
print("hehe...") | |
self:sleep(100) | |
print("end") | |
end) |
--[[ | |
statemachine.lua | |
Copyright (c) 2013 Erin Lin | |
erinylin.blogspot.com | |
Licensed under the MIT license. | |
Usage: | |
local sm = require("statemachine") | |
local process = sm.new(function(self, time) |
//http://me.dt.in.th/page/SpreadsheetToJSONP | |
function onEdit(e) { | |
var value = SpreadsheetApp.getActiveSpreadsheet().getSheets() | |
.filter(function(sheet) { return sheet.getName() != "JS" }) | |
.map(function(sheet) { | |
return { name: sheet.getName(), | |
values: sheet.getDataRange().getValues() }; | |
}); | |
SpreadsheetApp.getActiveSpreadsheet() | |
.getSheetByName("JS").getRange("B1").setValue(JSON.stringify(value)); |
var content = ''; | |
var boundary = '---------------------------170062046428149'; | |
content += '--'+ boundary + '\r\n'; | |
content += 'Content-Disposition: form-data; name="uploadToken"\r\n'; | |
content += '\r\n'; | |
content += upload_token + '\r\n'; | |
content += '--'+ boundary + '\r\n'; | |
content += 'Content-Disposition: form-data; name="destFolderPath"\r\n'; | |
content += '\r\n'; |
var login = function(args){ | |
xhr.open( 'GET', args.url ); | |
xhr.setRequestHeader('Accept', 'application/json'); | |
xhr.setRequestHeader('Content-Type', 'application/json'); | |
//TODO | |
var txt = Ti.Utils.base64encode( args.username + ':' + args.password).getText(); | |
xhr.setRequestHeader('Authorization','Basic '+ txt); |
------------------------------------- | |
-- group slide event | |
-- Erin Lin | |
------------------------------------- | |
local isActive = true | |
local slide = function(event) | |
if not isActive then return end | |
local W = display.contentWidth * .5 | |
local dis = 40 | |
local pos = (event.xStart < W and "L") or "R" |
------------------------------------------------- | |
-- | |
-- extends Group example | |
-- | |
------------------------------------------------- | |
local group = {} | |
local group_mt = { __index = group } -- metatable | |
------------------------------------------------- |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Solarized-erin (dark)</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |