小编Lan*_*tly的帖子

如何修复Interface-Builder fubar的项目

帮助我在XCode4中使用un-fubar接口构建器.

我在interface-builder中创建了一个按钮,并在视图的代码中为它定义了一个IBAction方法.它运行正常.然后我使用XCode的重构/重命名工具重命名了按钮的动作方法.它运行正常.

然后我通过选择按钮并点击删除键删除了界面构建器中的按钮.当我重建项目时,按钮仍在模拟器中.回到界面构建器,按钮消失了.没有引用代码中的按钮,但按钮的IBAction方法仍然存在.

更糟糕的是,按钮的原始操作方法被调用,当然会抛出未找到的选择器的运行时异常.当我在项目中搜索原始操作方法的名称时,找不到任何内容,但运行时仍在尝试调用它.我做了一个"干净"的重建但没有快乐.

如果我尝试将.xib文件作为ASCII属性列表打开,它会告诉我数据已损坏.(我想出来了.)

除了删除.xib文件和创建新视图之外,还有什么方法可以解决这个问题吗?

如果它不删除二进制文件,"干净"会做什么?

谢谢你的帮助!

interface-builder xcode4

6
推荐指数
1
解决办法
1061
查看次数

如果没有替换,Python字符串替换文件而不触及文件

如果没有进行字符串替换,Python的string.replace会返回什么?即使没有进行任何更改,Python的file.open(f,'w')是否始终触摸该文件?

使用Python,我试图在一组文件中用'newtext'替换'oldtext'的出现.如果文件包含'oldtext',我想进行替换并保存文件.否则,什么也不做,所以文件保持旧的时间戳.

以下代码工作正常,除非所有文件都被写入,即使没有进行字符串替换,并且所有文件都有新的时间戳.

for match in all_files('*.html', '.'):  # all_files returns all html files in current directory     
  thefile = open(match)
  content = thefile.read()              # read entire file into memory
  thefile.close()
  thefile = open(match, 'w')             
  thefile.write(content.replace(oldtext, newtext))  # write the file with the text substitution
  thefile.close()
Run Code Online (Sandbox Code Playgroud)

在这段代码中,我只是在发生字符串替换时尝试执行file.write,但是,所有文件都获得了新的时间戳:

count = 0
for match in all_files('*.html', '.'):       # all_files returns all html files in current directory
    thefile = open(match)
    content = thefile.read()                 # read entire file into memory
    thefile.close()
    thefile = open(match, 'w') …
Run Code Online (Sandbox Code Playgroud)

python file-io replace

5
推荐指数
1
解决办法
4712
查看次数

phpMyAdmin导出/导入导致重复的主键错误

我想用一个新的站点URL全局替换Wordpress MySQL数据库中我的站点url的所有实例.为此,我使用phpMyAdmin将数据库导出到.sql文件,然后在文本编辑器中进行全局替换,然后使用phpMyAdmin导入.sql文件.

在导入期间,我遇到主键错误的重复条目.试图调试这个,我导出文件,然后导入相同的文件,没有做任何更改,我仍然得到相同的错误.

我感谢任何帮助解决这个问题.

--
-- Dumping data for table `wp_comments`
--
INSERT INTO  `wp_comments` 
  (`comment_ID`, `comment_post_ID`, `comment_author`, `comment_author_email`
  ,`comment_author_url`, `comment_author_IP`, `comment_date`, `comment_date_gmt` 
  ,`comment_content`, `comment_karma`, `comment_approved`, `comment_agent` 
  ,`comment_type`, `comment_parent`, `user_id`) 
VALUES (1, 1, 'Mr WordPress', ''
       ,'http://wordpress.org/', '', '2011-04-28 00:49:55', '2011-04-28 00:49:55'
       ,'Hi, this is a comment.<br />To delete a comment, 
         just log in and view the post&#039;s comments. 
         There you will have the option to edit or delete them.'
       , 0, 'post-trashed',  '',  '', 0, 0 ) ;

MySQL …
Run Code Online (Sandbox Code Playgroud)

mysql wordpress insert phpmyadmin

3
推荐指数
1
解决办法
3万
查看次数