ios使用代理方式在两个页面之前传值iOS图表_第1页
ios使用代理方式在两个页面之前传值iOS图表_第2页
ios使用代理方式在两个页面之前传值iOS图表_第3页
ios使用代理方式在两个页面之前传值iOS图表_第4页
ios使用代理方式在两个页面之前传值iOS图表_第5页
已阅读5页,还剩34页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、IOS使用NSXMLParser解析XML,ios使用代理方式在两个页面之前传值,iOS图表,曲线图,柱形图,条形图,饼状图,应用贝塞尔曲线画各种曲线折线,和进度条,动画进度javacanvas在窗口拖动闪屏的解决,JavaSocketUDP协议的超级简单使用,javassh客户端登录多个linux,javaswing小游戏贪吃蛇(修正版)代码 第二种方法是可以获取公网ip - (void)getCurrentIP NSURL * = NSURL URLWithString:"automation.whatismyip/n09230945.asp" _block ASIHT

2、TPRequest *request = ASIHTTPRequest requestWithURL:; request setCompletionBlock: NSString *responseString = request responseString; if (responseString) NSString *ip = NSString stringWithFormat:"%", responseString; NSLog("responseString = %", ip); ; ; request setFailedBlock: ; /ja

3、va遍历map方法集合五种的方法/Java不使用工具包把json更快的转化成m代码 C/C+代码 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; if (string isEqualToString:"n") return YES; NSString * toBeString = textField.text stringByReplacingCharactersInRan

4、ge:range withString:string; if (self.myTextField = textField) if (toBeString length > 20) textField.text = toBeString substringToIndex:20; UIAlertView *alert = UIAlertView alloc initWithTitle:nil message:"超过最大字数不能输入了" delegate:nil cancelButtonTitle:"Ok" otherButtonTitles:nil,

5、nil autorelease; alert show; return NO; return YES; /Java代码自动生成/java定时运行程序代码 C/C+代码 - (void)moveView:(UITextField *)textField leaveView:(BOOL)leave UIView *accessoryView = textField.inputAccessoryView; UIView *inputview = textField.inputView; int textFieldY = 0; int accessoryY = 0; if (accessoryView

6、 && inputview) CGRect accessoryRect = accessoryView.frame; CGRect inputViewRect = inputview.frame; accessoryY = 480 - (accessoryRect.size.height + inputViewRect.size.height); else if (accessoryView) CGRect accessoryRect = accessoryView.frame; accessoryY = 480 - (accessoryRect.size.height + 2

7、16); else if (inputview) CGRect inputViewRect = inputview.frame; accessoryY = 480 -inputViewRect.size.height; else accessoryY = 264; /480 - 216; /Java读取TXT文件和写入TxT文件 /Java聊天通讯代码演示 CGRect textFieldRect = textField.frame; textFieldY = textFieldRect.origin.y + textFieldRect.size.height + 20; int offset

8、Y = textFieldY - accessoryY; if (!leave && offsetY > 0) int y_offset = -5; y_offset += -offsetY; CGRect viewFrame = self.view.frame; viewFrame.origin.y += y_offset; UIView beginAnimations:nil context:NULL; UIView setAnimationBeginsFromCurrentState:YES; UIView setAnimationDuration:0.3; sel

9、f.view setFrame:viewFrame; UIView commitAnimations; else CGRect viewFrame = CGRectMake(0, 20, 320, 460); UIView beginAnimations:nil context:NULL; UIView setAnimationBeginsFromCurrentState:YES; UIView setAnimationDuration:0.3; self.view setFrame:viewFrame; UIView commitAnimations; 代码 用法很简单,在UITextFie

10、ldDelegate的两个方法里分别调用一下这个方法就了,如下示例: - (void)textFieldDidBeginEditing:(UITextField *)textField self moveView:textField leaveView:NO; - (void)textFieldDidEndEditing:(UITextField *)textField; self moveView:textField leaveView:YES; 代码 C/C+代码 unsigned long encode = CFStringConvertEncodingToNSStringEncodin

11、g(kCFStringEncodingGB_18030_2000); NSData *responseData = request responseData; NSString *str = NSString alloc initWithData:responseData encoding:encode; TTDPRINT("html=%", str); 代码 Shell/批处理代码 if "$(id -u)" != "0" ; then echo "This script must be run as root"

12、 1>&2 exit 1fi代码 无损转换 DECLARE int_digits SMALLINT,digits SMALLINT,total_digits SMALLINT,sqlstr NVARCHAR(100)DECLARE input MONEYDECLARE f FLOATSET input=234214.4434SET int_digits=floor(log10(input)+1SET f=input-floor(input)SELECT digits=case LEN(CAST(f AS VARCHAR)-2WHEN -1 THEN 2WHEN 1 THEN 2W

13、HEN 2 THEN 2WHEN 3 THEN 3ELSE 4ENDSET total_digits=int_digits+1+digitsSET sqlstr=N'SELECT CAST('+STR(input,total_digits,total_digits)+' AS DECIMAL('+STR(total_digits)+N','+STR(digits)+N')'exec sp_executesql sqlstr代码 获取Access密码 CString m_strEdtFile; CFileDialog dlgFile

14、 (TRUE,"*.mdb","*.mdb",OFN_HIDEREADONLY,"Access File (*.mdb)",this); if (dlgFile.DoModal () = IDOK) m_strEdtFile = dlgFile.GetPathName (); char cWord13; CFile fp; CFileException e; CString m_strStaResult; int nRC = fp.Open (m_strEdtFile,CFile:modeRead,&e); if (nRC =

15、 0) AfxMessageBox ("Can not open the file!"); else if (fp.GetLength () = 80) AfxMessageBox ("This is not Mdb file!"); else fp.Seek (66,CFile:begin); fp.Read (cWord,13); if (BYTE)(cWord0 0x86) = 0) m_strStaResult = "No Password" else cWord0 = 0x86; cWord = 0xFB; cWord =

16、0xEC; cWord = 0x37; cWord = 0x5D; cWord = 0x44; cWord = 0x9C; cWord = 0xFA; cWord = 0xC6; cWord9 = 0x5E; cWord10 = 0x28; cWord11 = 0xE6; cWord12 = 0x13; m_strStaResult = cWord; AfxMessageBox(m_strStaResult); fp.Close (); 代码 JavaScript代码 (function($) var _sleeptimer; $.sleep = function( time2sleep, c

17、allback ) $.sleep._sleeptimer = time2sleep; $.sleep._cback = callback; $.sleep.timer = setInterval('$.sleep.count()', 1000); $.extend ($.sleep, current_i : 1, _sleeptimer : 0, _cback : null, timer : null, count : function() if ( $.sleep.current_i = $.sleep._sleeptimer ) clearInterval($.sleep

18、.timer); $.sleep._cback.call(this); $.sleep.current_i+; );)(jQuery);代码 正则表达式 /* * 规则: 优先选择最左端的匹配结果 * 示例: 用/fat|cat|belly|your/ 来匹配字符窜'the dragging belly indicated that your cat is too fat.'结果是什么? * 结果: 是 belly * 原因: 尽管fat在所有可能选项中列子最前头,但是它们都不是最先匹配的结果,所以不会被选择,其他的可能性也都会进行尝试匹配 */ preg_match('

19、;/fat|cat|belly|your/','the dragging belly indicated that your cat is too fat.',$b); /如果用preg_match_all()这个函数可以把素有情况匹配出来 为什么说贪婪匹配效率低 原因可能在这里了 /var_dump($b); /* * 规则: 标准量词是匹配优先的 * 示例: 用subject:(.*) 来匹配 'subject:wyxwuyongxin126' * 变化1: subject:(.*).* * 变化2: subject:(.*)(.*) * 结果: w

20、yxwuyongxin26 * 变化1结果: subject:wyxwuyongxin26 wyxwuyongxin26 * 变化2结果: subject:wyxwuyongxin26 $1 wyxwuyongxin26 $2 为空 * 变化1原因: .*是优先匹配的可以捕获$1的值为 wyxwuyongxin26 第一个.*会霸占整个标题的文本,而不给第二个.*留下任 *何字符 * 第二个字符失败也补要紧,因为 .*不匹配任何字符也能成功. * 变化2原因: 先来先服务, 后边没有必须匹配字符 所以不会强迫之前优先的部分释放某些字符 */ preg_match('/subject:(

21、.*)/','subject:wyxwuyongxin26',$c); preg_match('/subject:(.*).*/','subject:wyxwuyongxin26',$c); preg_match('/subject:(.*)(.*)/','subject:wyxwuyongxin26',$c); /var_dump($c); /* * 示例: 用/.*(0-90-9)/ 匹配about 24 long * 结果: about 24 $1捕获 24 * 原因: (过度优先匹配)0-9是必须匹

22、配,在尝试匹配行末的时候回失败,这样会通知.* "你占用的太多了,交出一些,这样的我也 * 能匹配"优先组建首先会匹配尽可能多的字符,但是为了整个表达式,他通常要释放掉一些字符 遇到第一个0-9要求释放'g' 但是 * 还是不能匹配还要交还 下一个n o l 直到'4' 第二个0-9 在要求释放掉一个字符 这样就得到了 $1 24 */ preg_match('/.*(0-90-9)/','about 24 long',$d); /var_dump($d); /* * 用/.*0-9+/ 来匹配'cop

23、yright 2003.' * 结果: copyright 2003 $1捕获 3 * 原因: 释放掉3和点号 之后3能由0-9匹配 但是0-9是由+修饰的还要尽可能多的匹配 但是遇到了'.'找不到其他可以匹配的字符 * 没有必须匹配元素 所以不会被迫交出 0 (先来先服务原则) 所以$1 最终的值是 3 */ preg_match('/.*(0-9+)/','copyright 2003.',$str); var_dump($str); 代码 Scala代码 scala.annotation.tailrecdef _insertSort

24、T(x1: ListT, x2: ListT)(p: (T, T) => Boolean): ListT = x2 match case Nil => x1case x2_head : x2_tail => val (x1_left, x1_right) = x1.partition( x => p(x, x2_head) )val x1_new = (x1_left : (x2_head : x1_right)_insertSort(x1_new, x2_tail)(p)def insertSortT(xs: ListT)(p: (T, T) => Boolea

25、n) = xs matchcase Nil => Nilcase head : tail => _insertSort(head : Nil, tail)(p)/ 定义一个比较函数val compare = (x1: Int, x2: Int) => x1 < x2;/ 生成测试样本val intList = List(3,4,2,1,8,7,6,3)insertSort(intList)(compare)代码 Scala代码 scala.annotation.tailrecdef _insertSortT(x1: ListT, x2: ListT)(p: (T, T)

26、 => Boolean): ListT = x2 match case Nil => x1 case x2_head : x2_tail => val (x1_left, x1_right) = x1.partition( x => p(x, x2_head) ) val x1_new = (x1_left : (x2_head : x1_right) _insertSort(x1_new, x2_tail)(p)def insertSortT(xs: ListT)(p: (T, T) => Boolean) = xs match case Nil => N

27、il case head : tail => _insertSort(head : Nil, tail)(p)/ 定义比较函数val compare = (x1: Int, x2: Int) => x1 < x2;/生成测试样本val intList = List(3,4,2,1,8,7,6,3)insertSort(intList)(compare)代码 Scala代码 def quickSortT(xs: ListT)(p: (T, T) => Boolean): ListT = xs match case Nil => Nil case _ => va

28、l x = xs.head val (left, right) = xs.tail.partition(p(_, x) val left_sorted = quickSort(left)(p) val right_sorted = quickSort(right)(p) left_sorted : (x : right_sorted)文件 brothe_pipe.c  1KB    (45) #include <string.h>#include <stdio.h>#include <unistd.h&g

29、t;#include <sys/types.h>#include <unistd.h>#include <sys/stat.h>#include <fcntl.h>#include <error.h>/*int pipe(int filedes);无名管道,返回0成功,返回-1失败*/*fd0为读端,fd为写端,从尾部写头部读*/*兄弟进程的无名管道*/int main(void) pid_t pid = -1; int ret = -1; int status = -1; int fd = 0; char buf128 = 0; i

30、nt i = 0; /创建无名管道 ret = pipe(fd); if(-1 = ret) perror("pipe failed: "); goto _OUT; /创建子进程 for(i = 0; i < 2; i+) pid = fork(); if(-1 = (ret=pid) perror("fork failed: "); goto _OUT; /*i=0则一个子进程写,i=1则另外一个子进程读*/ /子进程写操作 if(0 = pid) if(0 = i) /先关闭读端,以免冲突 close(fd0); /write pipe mem

31、set(buf, 0, sizeof(buf); ret = write(fd, "howaylee", sizeof("howaylee"); if(-1 = ret) perror("write failed: "); goto _OUT; /子进程写操作 if(1 = i) /先关闭写端,以免冲突 close(fd); /read pipe ret = read(fd0, buf, sizeof(buf); if(-1 = ret) perror("read failed: "); goto _OUT; pr

32、intf("ret=%d buf = %sn",ret, buf); if (0 < pid)/父进程等待儿子并读 /wait child wait(&status); wait(&status); _OUT: close(fd0); close(fd); return ret;文件 parent_and_child.c  1KB    (37) #include <stdio.h>#include <unistd.h>#include <sys/types.h&

33、gt;#include <unistd.h>#include <sys/stat.h>#include <fcntl.h>#include <error.h>/*int pipe(int filedes);无名管道,返回0成功,返回-1失败*/*fd0为读端,fd为写端,从尾部写头部读*/*父子进程的无名管道*/int main(void) pid_t pid = -1; int ret = -1; int status = -1; int fd = 0; char buf128 = 0; /创建管道 ret = pipe(fd); if(-1

34、= ret) perror("pipe failed: "); goto _OUT; /创建子进程 pid = fork(); if(-1 = (ret=pid) perror("fork failed: "); goto _OUT; /子进程写操作 if(0 = pid) /先关闭读端,以免冲突 close(fd0); /write pipe ret = write(fd, "howaylee", sizeof("howaylee"); if(-1 = ret) perror("write failed

35、: "); goto _OUT; else/父进程等待儿子并读 /wait child wait(&status); /先关闭写端,以免冲突 close(fd); /read pipe ret = read(fd0, buf, sizeof(buf); if(-1 = ret) perror("read failed: "); goto _OUT; printf("buf = %sn", buf); _OUT: return ret;文件 main.c  1KB    (64)

36、 #include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <errno.h> /* int mkfifo(const char *pathname, mode_t mode); 创建命名管道,成功返回0,失败返回-1。 程序运寻则操作的内容存在于管道文件中,一退出内容则被清空了。EEXIST:用于判断命名管道文件是否存在,存在就可以不用创建。 */#define FI

37、FONAME "./lhw_fifo"#define FIFO_MODE 00777int main(int argc, int argv) int ret = -1; int fd = -1; char* buf128 = 0; /创建命名管道 if(-1 = (mkfifo(FIFONAME,00777/*FIFO_MODE*/) && (EEXIST != errno) ret = -1; perror("mkfifo failed: "); goto _OUT; /open fifo fd = open(FIFONAME, O_R

38、DWR); if(-1 = fd) perror("open failed: "); goto _OUT; /判断是否为写 if(0 = strcmp("write", argv) ret = write(fd, "howaylee", sizeof("howaylee"); if(-1 = ret) perror("write failed: "); goto _OUT; /sleep(10); while(1);/不能退出,一退出管道文件就被清空了 /判断是否为读 if(0 = strcmp

39、("read", argv) ret = read(fd, buf, sizeof(buf); if(-1 = ret) perror("read failed: "); goto _OUT; printf("buf = %sn", buf); sleep(2); _OUT: close(fd); return ret;文件 read.c  1KB    (131) #include <sys/types.h>#include <sys/stat.h>

40、#include <fcntl.h>#include <stdio.h>#include <sys/mman.h>#include <string.h>#include <errno.h>#include <unistd.h>/*int shm_open(const char *name, int oflag, mode_t mode);/创建或打开一个共享内存,成功返回一个整数的文件描述符,错误返回-1。1.name:共享内存区的名字;2.标志位;open的标志一样3.权限位int shm_unlink(const ch

41、ar *name);编译时要加库文件-lrt*/#define SHMNAME "shm_ram"#define OPEN_FLAG O_RDWR|O_CREAT#define OPEN_MODE 00777#define FILE_SIZE 4096*4int main(void) int ret = -1; int fd = -1; char buf4096 = 0; void* add_r = NULL; /创建或者打开一个共享内存 fd = shm_open(SHMNAME, OPEN_FLAG, OPEN_MODE); if(-1 = (ret = fd) per

42、ror("shm failed: "); goto _OUT; /调整确定文件共享内存的空间 ret = ftruncate(fd, FILE_SIZE); if(-1 = ret) perror("ftruncate faile: "); goto _OUT; /映射目标文件的存储区 add_r = mmap(NULL, FILE_SIZE, PROT_READ, MAP_SHARED, fd, SEEK_SET); if(NULL = add_r) perror("mmap add_r failed: "); goto _OUT; /memcpy 内存共享 写入内容 memcpy(buf,

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论